I'm creating a simple Roslyn Source Generator. The generator seems to work well in debug, correctly generating the desired class. However, when referencing it from another project in the solution, a red icon is shown near it with the "Ignored" tooltip and no output is produced:

The generator code is very simple:
namespace CompetencesSourceGenerator
{
using Microsoft.CodeAnalysis;
[Generator]
public class CompetenceNamesGenerator: CompetenceGeneratorBase
{
public override void Execute(GeneratorExecutionContext context)
{
context.AddSource(
"CompetenceNames.g.cs",
@"namespace Foo { public class Bar { } }"
);
}
}
}
I checked the following:
Microsoft.CodeAnalysis.CSharp and Microsoft.CodeAnalysis.Analyzers in generator project are up to dateWhy does it not work?
So apparently, the issue was caused by three factors, the combination of which resulted in a very confusing UX:
Worth mentioning that in Rider everything works just as expected, so I hope they fix this behavior in VS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With