Disallow null checking discard parameters#58952
Merged
RikkiGibson merged 3 commits intodotnet:mainfrom Jan 20, 2022
Merged
Conversation
53 tasks
davidwengier
approved these changes
Jan 20, 2022
jcouv
reviewed
Jan 20, 2022
|
|
||
| class C | ||
| { | ||
| Action<string> lambda = _ => |
Member
There was a problem hiding this comment.
Please test the scenario with two underscores. A single underscore is not a discard.
https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/lambda-discard-parameters.md #Closed
Member
Author
There was a problem hiding this comment.
Have added the test, thanks.
jcouv
reviewed
Jan 20, 2022
| { | ||
| public C() | ||
| { | ||
| Func<string, int> f = ([||]_) => { return 0; }; |
Member
Author
There was a problem hiding this comment.
See TestOnDiscardLambdaParameter2
jcouv
approved these changes
Jan 20, 2022
Member
jcouv
left a comment
There was a problem hiding this comment.
Compiler side LGTM Thanks (iteration 2). Some IDE test suggestions
Member
cston
reviewed
Jan 20, 2022
| // (8,51): error CS8990: Discard parameter cannot be null-checked. | ||
| // public Action<string, string> action3 = (_!!, _!!) => { }; // 3, 4 | ||
| Diagnostic(ErrorCode.ERR_DiscardCannotBeNullChecked, "_").WithLocation(8, 51)); | ||
| } |
Contributor
cston
approved these changes
Jan 20, 2022
333fred
added a commit
to 333fred/roslyn
that referenced
this pull request
Jan 21, 2022
* upstream/main: (1035 commits) Add missing header Mark IVSTypeScriptFormattingServiceImplementation as optional, but require it in the constructor Fix Go To Base for a symbol with a single metadata location (dotnet#58965) [EnC] Store entire spans instead of line deltas (dotnet#58831) Delete CodeAnalysisRules.ruleset (dotnet#58968) Allow xml docs to still be created when 'emit metadata only' is on. (dotnet#57667) Fix ParseVBErrorOrWarning (dotnet#47833) Update parameter nullability to match implementation Ensure CSharpUseParameterNullCheckingDiagnosticAnalyzer works with nullable parameters Add tests for issues fixed by previous PR (dotnet#58764) Update src/Features/CSharp/Portable/Completion/CompletionProviders/ExplicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs Disallow null checking discard parameters (dotnet#58952) Add extension method Escape type arguments Few fixes Update tests. Add Analyzers layer to CODEOWNERS Add formatting analyzer test for param nullchecking (dotnet#58936) Move reading HideAdvancedMembers option up (dotnet#58747) List patterns: Slice value is assumed to be never null (dotnet#57457) ...
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.
Related to #36024