Expose ParseOptions on generator context#46919
Conversation
|
@dotnet/roslyn-compiler for review please |
There was a problem hiding this comment.
Can you add tests for the added public API?
Also, just for my context, can you clarify where those parse options come from (how are they computed)?
There was a problem hiding this comment.
Added a test. The options are passed to the generator driver at construction time. In CSC we pass them here:
Which come directly from the command line args.
jcouv
left a comment
There was a problem hiding this comment.
Done with review (iteration 1). Needs tests
|
Ping @dotnet/roslyn-compiler for a second review please :) |
|
I'm not sure why this is necessary: if an analyzer author cares about the parse options, they have access to the compilation. They can either get a ParseOptions off one of the trees, or more likely, answer any questions by calling methods on the Compilation directly. |
|
@333fred suggested we just add the My thought is that generally on a compilation they aren't that interesting, as you can just ask questions of the compilation about 'what was parsed'. With generators though the parse options become more interesting, because it's saying 'how is the compiler going to parse this text I give it'. We could move it to the compilation, but given the above, I don't see that it's particularly useful anywhere other than in a generator, so I think we should just keep the option on the context. (You can also always just go and get the options via the trees if you need to. This PR just makes it simpler/more obvious for generators to do so). |
9801fa9 to
2e0427b
Compare
|
Hrmm... can you clarify how this would work? ParseOptions are specific to a tree, not the full compilation. So how can you expose something at teh compilation level? |
…-only-errors * upstream/master: (236 commits) Fix bug when "End statement" is used in single-line if (dotnet#47062) Solution asset cache refactoring (dotnet#46948) add specific tests to validate behavior between keys and snapshots Extract into separate files rename parameters rename parameters rename parameters rename parameters Add CancellationToken parameters to SyntaxTreeOptionsProvider Reuse nullable override checks for delegate conversions (dotnet#46953) Introduce warning for multiple entry points (sync + async) (dotnet#46832) Switch from throwing NotImplementedException and return E_NOTIMPL Delete Building for Core CLR.md (dotnet#47146) Adjust PrintMembers to avoid boxing and avoid extra space (dotnet#47095) Track asynchronous operation in InProcLanguageServer Use Task.FromCanceled where appropriate Apply suggestions from code review Address feedback Expose ParseOptions on generator context (dotnet#46919) Remove redundant statement in added tests ...
Small PR that exposes the parse options that will be used to the consuming generator