Track duplicate hintNames as they are added#55905
Merged
chsienki merged 4 commits intodotnet:mainfrom Sep 1, 2021
Merged
Conversation
Member
Author
|
@dotnet/roslyn-compiler for review please :) |
jaredpar
reviewed
Aug 26, 2021
| Assert.Equal(2, outputCompilation.SyntaxTrees.Count()); | ||
| } | ||
|
|
||
| [ConditionalFact(typeof(MonoOrCoreClrOnly), Reason = "Desktop CLR displays argument exceptions differently")] |
Member
There was a problem hiding this comment.
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.
Member
Author
There was a problem hiding this comment.
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.
jaredpar
approved these changes
Aug 26, 2021
Member
|
@RikkiGibson PTAL |
RikkiGibson
reviewed
Aug 31, 2021
| 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) |
Member
There was a problem hiding this comment.
Do we have any test which verifies the case-insensitive comparison for hintNames?
Member
Author
There was a problem hiding this comment.
No, thats a good one to add, thanks.
Member
Author
There was a problem hiding this comment.
RikkiGibson
approved these changes
Aug 31, 2021
Member
Author
|
Rebase + force to fix conflicts |
2e1275c to
c042eb5
Compare
chsienki
added a commit
to chsienki/roslyn
that referenced
this pull request
Sep 1, 2021
* Track duplicate hintNames as they are added
jaredpar
pushed a commit
that referenced
this pull request
Sep 1, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.