Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

216
Views
Can a Roslyn Source Generator discover the IDE's spacing/etc preferences?

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?)

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

As observed by the conversation, there's no good way to do this (or at least not as of this writing). A generator could try to use the values from an .editorconfig to know the formatting settings if you want to piece it together, but you'd have to write some of that yourself at this point. My suggestion would be until we build in support for this, just don't worry about it, and feel free to direct user complaints to this or the bug.

No matter what, the debugging problem makes things tricky: the file open in the IDE needs to match the file that was produced during the build, since the debugger expects that to line up. The .editorconfig at least means both sides can see the same value.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!