@neocompose/cli 0.88.0 → 0.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/neo-runtime.mjs +7941 -2412
- package/dist/test-worker.mjs +14562 -11386
- package/package.json +1 -1
- package/skills/neocompose-cli/SKILL.md +1 -1
- package/skills/neocompose-cli/references/cli-development.md +1 -1
- package/skills/neocompose-cli/references/declarations/extensions.md +46 -0
- package/skills/neocompose-cli/references/neoscript/collections.md +40 -0
- package/skills/neocompose-cli/references/neoscript/neoscript.md +1 -0
- package/skills/neocompose-cli/references/sync/unity-export.md +16 -0
package/package.json
CHANGED
|
@@ -109,7 +109,7 @@ The marker near the top of `SKILL.md` must exactly match the package version,
|
|
|
109
109
|
and this quoted copy is checked too:
|
|
110
110
|
|
|
111
111
|
```html
|
|
112
|
-
<!-- reviewed-through-cli: 0.
|
|
112
|
+
<!-- reviewed-through-cli: 0.89.0 -->
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
Keep this skill on current behavior. Upgrade steps, rollout prerequisites,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Extensions
|
|
2
|
+
|
|
3
|
+
Declare functions and computed properties in top-level extension blocks. Each
|
|
4
|
+
member has its own `@id`; the block has no identity. Blocks can share any
|
|
5
|
+
`.neo` definition file. Pull retains member file placement and otherwise uses
|
|
6
|
+
`Extensions/<Receiver>Extensions.neo`.
|
|
7
|
+
|
|
8
|
+
```neo
|
|
9
|
+
extension Person {
|
|
10
|
+
@id("person-full-name")
|
|
11
|
+
public string FullName => $"{this.FirstName} {this.LastName}";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
extension List<Item> {
|
|
15
|
+
@id("item-best")
|
|
16
|
+
Item? Best() => this.OrderByDescending((i) => i.Quality).FirstOrDefault();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
extension<T> List<T> {
|
|
20
|
+
@id("list-first-value")
|
|
21
|
+
T? FirstValue => this.FirstOrDefault();
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Always use `this` to access the extended instance. Interface receivers are
|
|
26
|
+
supported and use the ordinary writable-member rules. Extensions add no
|
|
27
|
+
stored fields, constructors, inheritance, or operators. They are visible
|
|
28
|
+
project-wide. Applicable declared members take priority over extensions;
|
|
29
|
+
applicable extensions take priority over built-ins. Ambiguous candidates are
|
|
30
|
+
errors. Receiver type parameters must appear in the receiver and cannot have
|
|
31
|
+
defaults. Functions may also declare their own type parameters.
|
|
32
|
+
|
|
33
|
+
Computed properties support getters and explicit `set(Type value)` bodies.
|
|
34
|
+
Static extensions have no `this` and are called through the receiver type.
|
|
35
|
+
Extensions cannot be listener or spy/mock targets or use builder bodies.
|
|
36
|
+
|
|
37
|
+
Use `neo script check --all` to check local declarations. For direct checks,
|
|
38
|
+
select an extension with `--member <stable-member-id>`. Do not pass `--this`.
|
|
39
|
+
Direct evaluation accepts `--this-value <valueId>` only for a closed class or
|
|
40
|
+
interface receiver. Static extensions reject `--this-value`. Evaluate scalar,
|
|
41
|
+
collection, receiver-generic, and explicitly generic calls in an ordinary
|
|
42
|
+
`neo script eval --source '...'` expression. Evaluate setters through ordinary
|
|
43
|
+
assignments in source.
|
|
44
|
+
|
|
45
|
+
Both evaluators support extension members independently of the generated C#
|
|
46
|
+
version. See [Unity export](../sync/unity-export.md) for wrapper availability.
|
|
@@ -96,3 +96,43 @@ Put type arguments on the call, never the qualifier: `List<int>.Repeat` is an
|
|
|
96
96
|
error and bare `List` is not a value. `count` must be an `int`; a negative
|
|
97
97
|
count throws at runtime. The value and then the count evaluate exactly once,
|
|
98
98
|
so a reference-typed value repeats the same reference.
|
|
99
|
+
|
|
100
|
+
## Sequences and generators
|
|
101
|
+
|
|
102
|
+
Built-in collections implement `IEnumerable<T>` for their exact value type.
|
|
103
|
+
A dictionary enumerates its values. `GetEnumerator()` creates an independent
|
|
104
|
+
`IEnumerator<T>` with `MoveNext()`, `Current`, and `Dispose()`. Built-in cursors
|
|
105
|
+
snapshot membership when acquired. `Current` requires a successful `MoveNext`.
|
|
106
|
+
|
|
107
|
+
```neo
|
|
108
|
+
public IEnumerable<int> Neighbors(int cell) {
|
|
109
|
+
yield return cell - 1;
|
|
110
|
+
yield return cell + 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public List<int> Collect(IEnumerable<int> values) => values;
|
|
114
|
+
public IEnumerator<int> Cursor(List<int> values) => values;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Typed assignments, parameters, and returns acquire a cursor or collect a list
|
|
118
|
+
implicitly. Collecting a cursor consumes its remaining values, excluding its
|
|
119
|
+
current value, and disposes it. Element types must match exactly. A collection
|
|
120
|
+
itself does not own an iteration position.
|
|
121
|
+
|
|
122
|
+
A generator returns non-nullable `IEnumerable<T>` or `IEnumerator<T>`. Arguments
|
|
123
|
+
are evaluated when called; its body starts on the first `MoveNext`. Use
|
|
124
|
+
`yield return value` and `yield break`. `foreach` disposes its cursor on normal
|
|
125
|
+
completion, `break`, `return`, and catchable errors. A suspended generator runs
|
|
126
|
+
entered `finally` blocks when disposed. Yields cannot appear in catch/finally
|
|
127
|
+
blocks or a try block with catches; generators cannot invoke async functions.
|
|
128
|
+
|
|
129
|
+
`start..end` is an ascending, upper-exclusive int sequence. Reversed bounds are
|
|
130
|
+
empty. `foreach (var i in 0..count)` uses a counted loop without allocating a
|
|
131
|
+
cursor. Ranges require safe integer bounds.
|
|
132
|
+
|
|
133
|
+
`IEnumerator<T>` and derived cursor interfaces cannot occur in stored member
|
|
134
|
+
shapes, including Session storage, nested collection entries, or tuples. Use
|
|
135
|
+
computed properties and callable signatures for cursors; store `List<T>` data
|
|
136
|
+
explicitly. Stored enumerable interface members accept authored class rows.
|
|
137
|
+
Runtime sequences are shown as unenumerated and are not expanded for previews.
|
|
138
|
+
`ToSet()` rejects enumerable/cursor interface elements.
|
|
@@ -102,6 +102,7 @@ Read only the leaf the task needs:
|
|
|
102
102
|
Related branches:
|
|
103
103
|
|
|
104
104
|
- [References](../values/references.md): `Reference<T>` handles and slots.
|
|
105
|
+
- [Extensions](../declarations/extensions.md): typed receiver functions and computed properties.
|
|
105
106
|
- [Overloads](../declarations/overloads.md): declaring and calling overloads.
|
|
106
107
|
- [Constructors](../declarations/constructors.md) and
|
|
107
108
|
[initializers](../declarations/initializers.md): construction order and
|
|
@@ -45,3 +45,19 @@ an export go into the next batch. It never pulls or pushes.
|
|
|
45
45
|
|
|
46
46
|
Pull, push, branch, merge, resolve, init, and export take turns through
|
|
47
47
|
`.neo/workspace.lock`; a lock whose process died is taken over.
|
|
48
|
+
|
|
49
|
+
## C# target and extension wrappers
|
|
50
|
+
|
|
51
|
+
Set `codegen.csharpVersion` in `neo.json` to a numeric language version such as
|
|
52
|
+
`"14"`. `latest` and `preview` are rejected. Without an override, export uses
|
|
53
|
+
the supported Unity compiler mapping or the SDK's C# 9 baseline. It reads
|
|
54
|
+
`codegen.unityVersion` first, then the linked Unity project's
|
|
55
|
+
`ProjectSettings/ProjectVersion.txt`. `neo doctor` reports the effective target
|
|
56
|
+
and its source. An unrecognized Unity version produces a baseline warning.
|
|
57
|
+
|
|
58
|
+
Closed instance extension functions can generate classic C# extension methods.
|
|
59
|
+
Interface receivers, open receiver types, static extensions, and computed
|
|
60
|
+
extension properties require C# 14. Export omits an unavailable wrapper and
|
|
61
|
+
reports its member ID, receiver, and missing capability. It keeps the member
|
|
62
|
+
available to the NeoScript evaluators and SDK direct invocation API. Changing
|
|
63
|
+
the target regenerates wrappers and removes obsolete owned wrapper files.
|