@needle-tools/needle-component-compiler 3.0.2 → 3.0.3
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 +12 -0
- package/dist/impl/csharp-compiler.js +24 -4
- package/package.json +1 -1
package/Changelog.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to this package will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [3.0.3] - 2026-03-11
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- Fix `Promise<T>` return types passing through as `Promise` instead of resolving to `void`
|
|
11
|
+
- Fix unknown/web-only types (e.g. user-defined interfaces) in method parameters passing through instead of becoming `object`
|
|
12
|
+
- Fix `@nonSerialized` comment directive not being respected on methods (only worked on fields before)
|
|
13
|
+
- Fix `void` in union return types not being filtered out (e.g. `void | boolean` now correctly resolves to `bool`)
|
|
14
|
+
- Fix enum types in method parameters and return types becoming `object` instead of preserving the enum name
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- `@type` override on methods: `// @type ReturnType` overrides the return type, `// @type paramName ParamType` overrides a specific parameter's type
|
|
18
|
+
|
|
7
19
|
## [3.0.1] - 2026-03-04
|
|
8
20
|
|
|
9
21
|
### Fixed
|
|
@@ -275,6 +275,25 @@ var CSharpWriter = /** @class */ (function (_super) {
|
|
|
275
275
|
// @contextmenu on method → add attribute
|
|
276
276
|
var contextMenuComment = comments === null || comments === void 0 ? void 0 : comments.find(function (c) { return c.startsWith("@contextmenu "); });
|
|
277
277
|
var contextMenu = contextMenuComment ? contextMenuComment.substring("@contextmenu ".length).trim() : null;
|
|
278
|
+
// @type overrides: "@type ReturnType" for return, "@type paramName ParamType" for params
|
|
279
|
+
var returnTypeOverride;
|
|
280
|
+
var paramTypeOverrides = {};
|
|
281
|
+
if (comments) {
|
|
282
|
+
for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
|
|
283
|
+
var c = comments_1[_i];
|
|
284
|
+
if (!c.startsWith("@type "))
|
|
285
|
+
continue;
|
|
286
|
+
var parts = c.substring("@type ".length).trim().split(/\s+/);
|
|
287
|
+
if (parts.length >= 2) {
|
|
288
|
+
// "@type paramName Type" → param override
|
|
289
|
+
paramTypeOverrides[parts[0]] = parts.slice(1).join(" ");
|
|
290
|
+
}
|
|
291
|
+
else if (parts.length === 1) {
|
|
292
|
+
// "@type Type" → return type override
|
|
293
|
+
returnTypeOverride = parts[0];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
278
297
|
// Only emit public methods and lifecycle methods (which are always public)
|
|
279
298
|
var lifecycleName = LIFECYCLE_METHODS[name];
|
|
280
299
|
if (visibility !== base_compiler_1.Visibility.Public && !lifecycleName)
|
|
@@ -285,7 +304,10 @@ var CSharpWriter = /** @class */ (function (_super) {
|
|
|
285
304
|
var paramList = (_a = args === null || args === void 0 ? void 0 : args.map(function (arg) {
|
|
286
305
|
var _a;
|
|
287
306
|
var csharpType;
|
|
288
|
-
if (
|
|
307
|
+
if (paramTypeOverrides[arg.name]) {
|
|
308
|
+
csharpType = paramTypeOverrides[arg.name];
|
|
309
|
+
}
|
|
310
|
+
else if (!arg.type || arg.type.includes("{")) {
|
|
289
311
|
csharpType = "object";
|
|
290
312
|
}
|
|
291
313
|
else {
|
|
@@ -293,9 +315,7 @@ var CSharpWriter = /** @class */ (function (_super) {
|
|
|
293
315
|
}
|
|
294
316
|
return "".concat(csharpType, " @").concat(arg.name);
|
|
295
317
|
}).join(", ")) !== null && _a !== void 0 ? _a : "";
|
|
296
|
-
var csReturnType = returnType
|
|
297
|
-
? ((_b = this.resolveKnownCSharpTypeName(returnType)) !== null && _b !== void 0 ? _b : "void")
|
|
298
|
-
: "void";
|
|
318
|
+
var csReturnType = returnTypeOverride !== null && returnTypeOverride !== void 0 ? returnTypeOverride : (returnType ? ((_b = this.resolveKnownCSharpTypeName(returnType)) !== null && _b !== void 0 ? _b : "void") : "void");
|
|
299
319
|
if (contextMenu)
|
|
300
320
|
this.writer.writeLine("[UnityEngine.ContextMenu(\"".concat(contextMenu, "\")]"));
|
|
301
321
|
this.writer.writeLine("public ".concat(csReturnType, " ").concat(methodName, "(").concat(paramList, ") {}"));
|