Skip to content

Conversation

@chsienki
Copy link
Member

@chsienki chsienki commented Jun 15, 2022

If the parse options change after initialize has been called, we were not re-parsing the post init trees, leading to System.ArgumentException: Inconsistent language versions being thrown.

This tracks when the parse options change, and re-parses the init trees in the next generation pass if they have.

@chsienki
Copy link
Member Author

@dotnet/roslyn-compiler for review please.

@chsienki
Copy link
Member Author

chsienki commented Jul 7, 2022

Ping @dotnet/roslyn for review please :)


public GeneratorDriver WithUpdatedParseOptions(ParseOptions newOptions) => newOptions is object
? FromState(_state.With(parseOptions: newOptions))
? FromState(_state.With(parseOptions: newOptions, parseOptionsChanged: true))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While ParseOptions doesn't implement any equality all of the derived types do implement equality. Yet here we're unconditionally saying it changed. Do these changes happen frequently enough that we should plumb this through the derived types to let them say if the new ParseOptions are different than the current ones?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have to implement equality checking in #62219 to make that approach work there, so if we don't do it here this may not last long. I have new bits to test that PR with so will hopefully know soon enough if it works or needs that change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but re-parsing the init trees is cheap, and doesn't happen often enough that it'll be an issue. I think we should not block on this here, and can always improve it at a later date if we need to.

driver = driver.AddAdditionalTexts(ImmutableArray<AdditionalText>.Empty);

driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out compilation, out diagnostics);
diagnostics.Verify();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be diagnostics at this stage though because the language version is csharp 1. Believe we should validate these diagonstics show up here, likely by just grabbing the diagnostics off the syntax tree in the compilation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the generator diagnostics. I'll add a check for the compilation.

@genlu
Copy link
Member

genlu commented Aug 25, 2022

@chsienki Any update on this one? This is the top NFW for our .NET 6 remote host in dev17.4

@CyrusNajmabadi CyrusNajmabadi added the Priority:0 Work that we can't release without label Aug 25, 2022
@CyrusNajmabadi
Copy link
Member

Upping priority. @chsienki can you please prioritize accordingly? Thanks!

@chsienki chsienki force-pushed the source-generators/post-init-reparse branch from ce9a293 to 0f3deae Compare September 1, 2022 20:40
@chsienki chsienki enabled auto-merge (squash) September 1, 2022 23:05
@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@chsienki chsienki merged commit 0676bd0 into dotnet:main Sep 2, 2022
@ghost ghost added this to the Next milestone Sep 2, 2022
@Cosifne Cosifne modified the milestones: Next, 17.4 P3 Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Feature - Source Generators Source Generators Priority:0 Work that we can't release without

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants