Move attribute types to source generation, remove lib/ from package#193
Move attribute types to source generation, remove lib/ from package#193fm39hz wants to merge 1 commit into
Conversation
Attribute types (SceneTree, Autoload, Notify, etc.) were compiled into lib/netstandard2.0/ causing runtime assembly resolution failures for their Scriban/Microsoft.CodeAnalysis dependencies. Fix: emit all attribute types via RegisterPostInitializationOutput (AttributeTypeEmitter), so consuming projects get them as generated source code. Set IncludeBuildOutput=false so the analyzer DLL ships only in analyzers/dotnet/cs/, not lib/.
|
Hi. As a source generator, the dll and dependencies shouldn't be required or even copied to the build output folder. I tried creating a fresh project in Godot 4.6.3, adding GodotSharp.SourceGenerators 2.7.0 via nuget and adding [SceneTree] to the main scene. It built and ran ok from within the Godot Editor and the dll wasn't copied. Could you pls upload a minimal build that causes the problem (or instructions to replicate)? Thanks :) |
|
Repro setup that triggers it:
With That said, the PR already fixes the root cause — removing |
Problem
Attribute types (SceneTree, Autoload, Notify, etc.) are compiled into
lib/netstandard2.0/, creating a runtime dependency onGodotSharp.SourceGenerators.dll. When the assembly is loaded at runtime, the CLR tries to resolve its dependencies (Scriban, Microsoft.CodeAnalysis, CsvTextFieldParser), which fail because they are build-time-only analyzer dependencies. This produces 'Failed loading Assembly' warnings in the Godot console.Solution
Emit all attribute types and supporting types (Scope, ResG, ResI, Generate, IResourceTreeConfig, ICodeComments) via
RegisterPostInitializationOutputas generated source code in consuming projects. This eliminates the need forlib/netstandard2.0/in the NuGet package.Changes
[Generator]that emits all attribute types before incremental generators runIncludeBuildOutput=false, suppress NU5128Result
analyzers/dotnet/cs/lib/netstandard2.0/→ no runtime dependency