Unsafe evolution: avoid unnecessary diagnostics on params collection declarations#83641
Open
jjonescz wants to merge 1 commit intodotnet:mainfrom
Open
Unsafe evolution: avoid unnecessary diagnostics on params collection declarations#83641jjonescz wants to merge 1 commit intodotnet:mainfrom
jjonescz wants to merge 1 commit intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts C# compiler collection-expression validation so that params collection parameter declarations don’t surface “unsafe member must be used in an unsafe context” diagnostics for the implicit constructor/add/builder members that would only be used by expanded call-site binding. Tests are updated accordingly to expect diagnostics only at relevant call sites / collection expressions.
Changes:
- Thread an
isParamsModifierValidationflag through collection-expression helper checks to suppressReportDiagnosticsIfUnsafeMemberAccessduringparams-modifier validation. - Update
SourceComplexParameterSymbolparams-type validation to passisParamsModifierValidation: trueinto the relevant helper checks. - Update Unsafe Evolution tests to remove now-unexpected diagnostics reported on
paramsparameter declarations.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Compilers/CSharp/Test/CSharp15/UnsafeEvolutionTests.cs | Removes expected diagnostics previously reported on params parameter declarations for unsafe collection builder/ctor/add members. |
| src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs | Passes isParamsModifierValidation: true when validating params collection types, avoiding unsafe-member diagnostics during declaration validation. |
| src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs | Updates call sites for HasCollectionExpressionApplicableConstructor/AddMethod with the new flag parameter. |
| src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs | Updates collection-expression conversion checks to pass isParamsModifierValidation: false. |
| src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs | Updates the debug assertion call to HasCollectionExpressionApplicableAddMethod with isParamsModifierValidation: false. |
| src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs | Adds isParamsModifierValidation plumbing and suppresses unsafe-member diagnostics in constructor/add/builder validation when validating a params modifier. |
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.
See #83452 (comment).
Test plan: #81207
Microsoft Reviewers: Open in CodeFlow