I'm writing a Roslyn source generator, and as a matter of principle I'd like to make sure the generated source (which is now visible, debuggable, etc) adheres at least somewhat to the user's configuration of tabs vs spaces, brace locations, etc. I don't plan on supporting everything, but the obvious ones: sure.
So; I'm implementing ISourceGenerator
and ISyntaxReceiver
, which means I have access to the GeneratorInitializationContext
, GeneratorExecutionContext
and SyntaxNode
APIs. However, I cannot find any way to get these IDE settings from here. Is this possible?
This might not even be possible because of the reality that I'm talking about IDE settings and there isn't always an IDE - for example, the user could just be running dotnet build
at the command line.
(or perhaps alternatively; is it possible to trigger a "format document" equivalent on the generated code before handing it back to the caller?)
dotnet build
can also run generators (head explodes) – Family