Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AoT] Compile error if only one StaticContext exist and in global namespace #1031

Open
dogdie233 opened this issue Jan 16, 2025 · 0 comments

Comments

@dogdie233
Copy link

Describe the bug
In the project, if there is a unique class with YamlStaticContext attribute, and this class is in the global namespace, while there are other classes with YamlSerializable attribute, the compilation will fail.

To Reproduce

  1. Create a C# console project and enable NativeAoT publish. ( Dont trigger Do not use top-level statements)
  2. Add necessary package from nuget. (YamlDotNet and Vecc.YamlDotNet.Analyzers.StaticGenerator)
  3. Delete all template content in Program.cs
  4. Paste code.
Console.WriteLine("Hello world");

[YamlDotNet.Serialization.YamlSerializable]
public class Model {}

[YamlDotNet.Serialization.YamlStaticContext]
public partial class YamlContext : YamlDotNet.Serialization.StaticContext {}

Build output here

$ dotnet build
Restore complete (2.2s)
  BugReproduceProject failed with 1 error(s) (0.4s)
C:\BugReproduceProject\obj\Debug\net9.0\YamlDotNet.Analyzers.StaticGenerator\YamlDotNet.Analyzers.StaticGenerator.TypeFactoryGenerator\YamlDotNetAutoGraph.g.cs(8,10): error CS1001: Identifier expected

Build failed with 1 error(s) in 2.9s
dogdie233 added a commit to dogdie233/YamlDotNet that referenced this issue Jan 16, 2025
dogdie233 added a commit to dogdie233/YamlDotNet that referenced this issue Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant