# 4.16.0+ component generator regression

**URL:** <https://forum.needle.tools/t/4-16-0-component-generator-regression/2806>\
**Category:** 🌵 Needle Engine\
**Tags:** bug\
**Created:** [March 11, 2026, 3:13pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806 "2026-03-11T15:13:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 11, 2026, 3:13pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/1 "2026-03-11T15:13:16Z")

</div>

Hi @Marcel_Wiessler1 ,

trying to upgrade to 4.16.0 (mainly for the editor sync) and now the new compgen seems to pick up more members and do more work than before.

Here’s what breaks the cs compiler:

## Public methods returning a Promise

```ts
override async start(): Promise<void> {

```

Is now generating:

```cs
public Promise Start() {}

```

Before this became `void`:

```cs
public void start(){}

```

## Implementing `IEditorModification`

```ts
onEditorModification(modification: EditorModification): void | undefined | boolean { return false; }
onAfterEditorModification?(mod: EditorModification): void {

```

Is now generating:

```cs
public void onEditorModification(EditorModification @modification) {}
public void onAfterEditorModification(EditorModification @mod) {}

```

Before it stripped the web-only type:

```cs
public void onEditorModification(object @modification){}
public void onAfterEditorModification(object @mod){}

```

## Using other web-only types

I guess the IEditorModification thing above is actually the same issue but it also applies to user-defined types. As a bonus, in this case it is also combined with the Promise-issue 😉

```ts
export interface Bar { ... }

export class Foo extends Behaviour {
  async doStuff(bar: Bar): Promise<any> {

```

Is now generating:

```cs
public Promise doStuff(Bar @bar) {}

```

Before:

```cs
public void doStuff(object @bar){}

```

* * *

I think most of this could be fixed by a opt-out for methods, properties, types to not be compgen’ed. And/or replace unavailable types with object (or void in case of returned Promises) again.  
In fact, I do not want/need the methods above to have a cs counterpart. It’s just that it did not break before so I didn’t bother 🙂

Just relying on a member’s visibility in ts-land is not sufficient: I need to be able to make members accessible from other ts classes but they do not be have to (or even _should not_) be accessible from cs.

Hope I’m not doing something wrong/weird on my end causing all this.

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [March 11, 2026, 3:13pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/2 "2026-03-11T15:13:16Z")

</div>

Thank you for reaching out with your issue, krizzl0r. It sounds like there is a regression in the Needle Engine component generator in version 4.16.0 that is causing the changes you’ve observed. Let’s clarify and address your concerns step by step:

### Understanding the Regression

1. **Public Methods Returning a Promise:**

2. **Implementing `IEditorModification`:**

3. **Using Other Web-Only Types:**

### Solution Approach

From the documentation and your examples, it appears that the C# generator is now more strict about what is generated and may be including type information that isn’t compatible with C#.

#### Option 1: Opt-Out for Methods and Properties

You can use the `// @dont-generate-component` comment to skip generating C# components for specific classes or methods.

```ts
export class MyComponent extends Behaviour {
  // @dont-generate-component
  override async start(): Promise<void> {
    // ...
  }

  // @dont-generate-component
  onEditorModification(modification: EditorModification): void | undefined | boolean { return false; }
  onAfterEditorModification?(mod: EditorModification): void { 
    // ...
  }
  
  async doStuff(bar: Bar): Promise<any> {
    // ...
  }
}

```

This will ensure that the methods and their associated properties are not included in the generated C# component.

#### Option 2: Replace Unavailable Types with `Object` or `void`

Alternatively, you can use the `// @type` comment to replace web-only types with `Object` or `void` where needed.

```ts
export class MyComponent extends Behaviour {
  // @type Object
  onEditorModification(modification: any): void | undefined | boolean { return false; }
  onAfterEditorModification?(mod: any): void { 
    // ...
  }
  
  // @type void
  async doStuff(bar: any): Promise<void> {
    // ...
  }
}

```

This will instruct the generator to treat `EditorModification` and `Bar` as `Any` types in C#, which should resolve the compilation issues.

### Clarifying Your Needs

1. **Visibility and Accessibility:**

2. **Version Control:**

### Further Steps

- **Save the TypeScript File:**
  - Ensure you save the changes to your `.ts` file.

- **Component Generation:**
  - The generator should now produce the correct C# stubs in `Assets/Needle/Components.codegen/`.
  - Verify that the C# component appears in Unity’s Add Component menu and can be attached to Game Objects.

### Conclusion

Given the regression, either opting out the methods or replacing the web-only types with `Object` or `void` should solve your build issues. If you continue to face problems, feel free to provide more details or examples, and we can further refine the solution.

Sources: [Needle Engine Docs](https://engine.needle.tools/docs/reference/faq.html#:~:text=While%20generating%20C%23%20components%20does%20technically%20run%20with%20vanilla%20javascript%20too) (59%), [Needle Engine Docs](https://engine.needle.tools/docs/explanation/core-concepts/component-compiler.html#:~:text=See%20the%20code%20tabs%20above%20for%20an%20example%20of%20how%20to%20extend%20the%20generated%20component) (57%), [Needle Engine API](https://engine.needle.tools/docs/api/classes/Built-in_Components.ChangeMaterialOnClick.html#:~:text=variantMaterial%3F%3A%20Material%20The%20material%20that%20will%20be%20switched%20to%20get%20%22%5C%5B%24compone) (56%), [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/fundamentals/for-unity-developers.html#:~:text=Continue%20here%20to%20translate%20your%20C%23%20knowledge%20to%20TypeScript%3A%20Value%20types%20vs%20refer) (56%), [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/fundamentals/unity-integration.html#:~:text=Add%20Custom%20Behavior%3A%20Create%20Components%20-%20Write%20interactive%20code%20C%23%20to%20TypeScript) (55%), [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/fundamentals/typescript-essentials.html#:~:text=%2F%2F%20Export%20a%20class%20export%20class%20MyComponent%20extends%20Behaviour%20%7B%20%2F%2F%20..) (55%), [Needle Engine Docs](https://engine.needle.tools/docs/community/contributions/marwie/code-contribution-example/#:~:text=Overview%20View%20on%20Github%20This%20is%20mostly%20a%20basic%20example%20on%20how%20to%20contribute) (55%), [Needle Engine Docs](https://engine.needle.tools/docs/unity/getting-started.html#:~:text=Example%3A%20import%20%7B%20Behaviour%2C%20serializable%20%7D%20from%20%22%40needle-tools%2Fengine%22%3B%20import) (55%), [Needle Engine Docs](https://engine.needle.tools/docs/how-to-guides/scripting/create-components.html#:~:text=While%20generated%20C%23%20components%20use%20the%20type%20name%20to%20produce%20stable%20GUIDs%2C%20we%20reco) (55%)

_1 replies left_ - **[Become PRO](https://needle.tools/pricing)** for more replies.  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 11, 2026, 3:19pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/3 "2026-03-11T15:19:29Z")

</div>

Well there is of course `// @nonSerialized`… It just is not respected by the generator (codegen runs but still generates the members):

e.g.

```ts
// @nonSerialized
onEditorModification(modification: EditorModification): void | undefined | boolean { return false; }

```

still produces

```cs
public void onEditorModification(EditorModification @modification) {}

```

(For public fields it works though)

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [March 11, 2026, 5:47pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/4 "2026-03-11T17:47:48Z")

</div>

Hi, thanks for the reports. We’ve upgraded the compiler to use the same codebase as Blender and added more testing - seems like I’ve missed these cases.

Will see if I can fix these tonight. Another benefit of the new approach is that the compiler is not installed per project anymore but we can roll out updates to fix cases like yours more easily.

I will report back once the update is available (you don’t need to do anything for it but you can try to trigger a re-compile when it’s out)

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 11, 2026, 6:35pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/5 "2026-03-11T18:35:56Z")

</div>

Great, thanks!

> [@Marcel\_Wiessler1](#):
>
> you can try to trigger a re-compile when it’s out

Speaking of which. Had some trouble downgrading back to 4.15.0 and a way to trigger a full recompile/regenerate would‘ve helped. Is there one?

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [March 11, 2026, 9:32pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/6 "2026-03-11T21:32:37Z")

</div>

There isnt a way to recompile everything, no (you have to touch the TS scripts to trigger it)

Do you not have the components in git / sourcecontrol? That’s definitely recommended (having the codegen output in Unity be in git)

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [March 11, 2026, 9:54pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/7 "2026-03-11T21:54:49Z")

</div>

I’ve pushed a new version with tests+fixes for the issues you reported. Let me know if there’s anything else missing/unexpected once you upgrade again (when you do maybe first check the scripts that caused problems before to make your life easier IF you have to downgrad again - but as said, if these are in git then you should be able to just discard the changes including the needle engine change and it should work just as before)

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 13, 2026, 12:53pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/8 "2026-03-13T12:53:35Z")

</div>

Hi and thanks for the fixes.

But how do I update the compgen package now? I’ve already tried it the old way and updated the exporter and engine, running `npm install`.  
But the package seems to be stuck on the cached 3.0.1 (tested running `npx --yes @needle-tools/needle-component-compiler@3.x --version` using the command tester thingie on the compgen component).

The web project has the correct 3.0.3 installed but it does not get executed by Unity.

🤷

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 13, 2026, 1:19pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/9 "2026-03-13T13:19:21Z")

</div>

Ok so setting `"@needle-tools/needle-component-compiler": "3.0.3",` in the exporter’s package.json works because that’s where the 3.x is coming from.

AI says 3.x does not resolve to the installed 3.0.3-f6b855c because that’s viewed as a prerelease version. Dependency hell is real.

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 13, 2026, 3:35pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/10 "2026-03-13T15:35:31Z")

</div>

I’m currently toying around with a modified version of your GroundProjection.ts which serialized accessors like this:

```ts
    @serializable()
    set radius(val: number) {
        this._radius = val;
        if (this._projection) this.updateProjection();
    }
    get radius(): number { return this._radius; }
    private _radius: number = 50;

```

As they have the decorator, are they expected to have cs counterparts generated?

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [March 13, 2026, 4:25pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/11 "2026-03-13T16:25:16Z")

</div>

Yes the version you sent is prerelease and won’t update with 3.x but there is a stable 3.0.3 version on npm which should be installed with 3.x automatically

[https://www.npmjs.com/package/@needle-tools/needle-component-compiler/v/3.0.3](https://www.npmjs.com/package/@needle-tools/needle-component-compiler/v/3.0.3)

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [March 13, 2026, 4:25pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/12 "2026-03-13T16:25:54Z")

</div>

Yes, are they not?

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 13, 2026, 4:40pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/13 "2026-03-13T16:40:19Z")

</div>

Ok but look:

```auto
myapp
└─┬ @needle-tools/helper@2.0.0-next.faf57e6
  └── @needle-tools/needle-component-compiler@3.0.3-f6b855c

```

and engine 4.16.2’s package.json has this specific helper version as a dev dep:

```auto
    "@needle-tools/helper": "2.0.0-next.faf57e6",

```

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 13, 2026, 4:41pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/14 "2026-03-13T16:41:18Z")

</div>

> [@Marcel\_Wiessler1](#):
>
> Yes, are they not?

Nope 🙂

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [March 13, 2026, 5:00pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/15 "2026-03-13T17:00:16Z")

</div>

The compiler package is not direct dependency anymore/not used as such anymore. It is run via npx so doesnt need to be installed in any web project and it doesn’t affect it.

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [March 13, 2026, 5:00pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/16 "2026-03-13T17:00:53Z")

</div>

Ok thanks, will add a test and fix it if it reproduces

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 14, 2026, 2:30pm UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/17 "2026-03-14T14:30:39Z")

</div>

> [@Marcel\_Wiessler1](#):
>
> The compiler package is not direct dependency anymore/not used as such anymore. It is run via npx so doesnt need to be installed in any web project and it doesn’t affect it.

But the 3.0.3-f6b855c _is_ installed in the web project due to the dependency chain and npx favours the installed version if run in the web project’s context. Which it is: `var workingDir = Path.GetFullPath(projectDirectory);` in `ComponentGeneratorRunner.Run`.

(Interestingly, npx has 3.0.1 cached somewhere and does bother to update to the newer 3.0.3 release, I guess because the cached 3.0.1 still satisfies the 3.x requirement.)

So to make it truly independent of the web project, you need to fix (or remove) the dependency on it via the helpers package and maybe even change the version of the exporter’s package.json to something else than “3.x” if you want users to automatically use the newest version of the component generator.

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [March 15, 2026, 9:12am UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/18 "2026-03-15T09:12:29Z")

</div>

Hi, good catch. The component compiler npx command should not execute in the web project as a working directory to avoid having these conflicts and always updating to the latest stable 3.x version. I’ll fix this in the next Unity package update / make sure it works as expected 🙂

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 16, 2026, 8:51am UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/19 "2026-03-16T08:51:15Z")

</div>

Yep, “latest” helps, thanks.

---

<div class="post-metadata">

**Author:** ![krizzl0r](https://forum.needle.tools/user_avatar/forum.needle.tools/krizzl0r/32/4262_2.png) [@krizzl0r](https://forum.needle.tools/u/krizzl0r)\
**Post date:** [March 16, 2026, 8:52am UTC](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806/20 "2026-03-16T08:52:53Z")

</div>

Just confirmed accessor serialization used to be working pre 3.0.0

[Next page](https://forum.needle.tools/t/4-16-0-component-generator-regression/2806.md?page=2)
