Convert to local function: ensure unique names for multiple discard parameters#83644
Conversation
|
|
||
| if (multipleDiscardParameters && IsDiscardParameter(parameterNode)) | ||
| { | ||
| var newName = generator.Identifier($"_{discardParameterIndex++}"); |
There was a problem hiding this comment.
I tried using NameGenerator.EnsureUniqueness instead of explicitly generating names, but IMO it got pretty complicated when trying to avoid doing unnecessary work, so I stuck with this approach.
There was a problem hiding this comment.
what got complicated? NameGenerator.EnsureUniqueness is def the righ way to go.
There was a problem hiding this comment.
it just looked to me that the code got unnecessary harder to read, but I will give it another shot, thanks
There was a problem hiding this comment.
Yes, i'd def like to see with NameGenerator.EnsureUniqueness, since it was defined for cases like these. Thanks :)
There was a problem hiding this comment.
I rewrote this using NameGenerator to ensure unique names in general, not just for multiple discard parameters, which fixes more (non-compiling) cases. But let me know if this feels like overkill and I should revert to multiple discards case only.
There was a problem hiding this comment.
I would prefer this to be scoped to just multiple discard parameters -- not sure I'd expect that behavior for a case like Func<int, int, int> x = (a, a) => 1;
There was a problem hiding this comment.
@akhera99 Thanks, reverted to this case only
f207505 to
a9f2d39
Compare
a9f2d39 to
2f9098c
Compare
|
/azp run roslyn-CI |
|
Azure Pipelines successfully started running 1 pipeline(s). |
2f9098c to
98140ee
Compare
98140ee to
e66a1a0
Compare
|
Looks good, thank you for your contribution! |
Fixes #83144
Microsoft Reviewers: Open in CodeFlow