-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Track duplicate hintNames as they are added #55905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track duplicate hintNames as they are added #55905
Conversation
|
@dotnet/roslyn-compiler for review please :) |
| Assert.Equal(2, outputCompilation.SyntaxTrees.Count()); | ||
| } | ||
|
|
||
| [ConditionalFact(typeof(MonoOrCoreClrOnly), Reason = "Desktop CLR displays argument exceptions differently")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: what is the diff here?
Did you consider using an #if to assert diff between the platforms.
Minor feedback though, don't think it's critical here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CoreCLR has the (param name = '') stuff at the end. We already have a test that does the same thing above, so I just copied it.
src/Compilers/Core/Portable/SourceGeneration/AdditionalSourcesCollection.cs
Outdated
Show resolved
Hide resolved
|
@RikkiGibson PTAL |
| driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation, out var generatorDiagnostics); | ||
| outputCompilation.VerifyDiagnostics(); | ||
| generatorDiagnostics.Verify( | ||
| Diagnostic("CS8785").WithArguments("PipelineCallbackGenerator", "ArgumentException", "The hintName 'test.cs' of the added source file must be unique within a generator. (Parameter 'hintName')").WithLocation(1, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any test which verifies the case-insensitive comparison for hintNames?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, thats a good one to add, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Rebase + force to fix conflicts |
2e1275c to
c042eb5
Compare
* Track duplicate hintNames as they are added
Fixes #54185
In V1 we threw an exception at the point where a duplicate hint name was added. In V2 we were not throwing until we combined all the outputs, meaning a generator had no way of catching and responding to it.
This change restores the immediate exception behavior within the same output node. This means V1 generators will function as before, as the emulation layer executes them within a single node.
V2 generators will have a slightly different behaviour, as we don't know about duplicates until we combine all the outputs (and some may be cached etc). But the author won't see any difference until they have multiple output nodes, so even most ports to V2 should continue to work as written.