From 12529d1855a0c82d7ca1555fe47c4e7a7a71eba6 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 4 Oct 2024 10:23:10 -0700 Subject: [PATCH 1/6] Remove !! parsing logic from the parser --- .../CSharp/Portable/Parser/LanguageParser.cs | 117 ++---------------- 1 file changed, 7 insertions(+), 110 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs b/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs index 1b2c4707840fb..b6205c45c0847 100644 --- a/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs +++ b/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs @@ -4697,10 +4697,7 @@ private ParameterSyntax ParseParameter() this.EatToken())); } - ParseParameterNullCheck(ref identifier, out var equalsToken); - - // If we didn't already consume an equals sign as part of !!=, then try to scan one out now. - equalsToken ??= TryEatToken(SyntaxKind.EqualsToken); + var equalsToken = TryEatToken(SyntaxKind.EqualsToken); return _syntaxFactory.Parameter( attributes, @@ -4710,52 +4707,6 @@ private ParameterSyntax ParseParameter() equalsToken == null ? null : _syntaxFactory.EqualsValueClause(equalsToken, this.ParseExpressionCore())); } - /// - /// Parses the !! as skipped tokens following a parameter name token. If the parameter name - /// is followed by !!= or ! !=, then the final equals will be returned through . - /// - private void ParseParameterNullCheck( - ref SyntaxToken identifier, - out SyntaxToken? equalsToken) - { - equalsToken = null; - - if (this.CurrentToken.Kind is SyntaxKind.ExclamationEqualsToken) - { - // split != into two tokens. - var exclamationEquals = this.EatToken(); - - // treat the '!' as '!!' and give the feature unsupported error - identifier = AddTrailingSkippedSyntax( - identifier, - this.AddError(SyntaxFactory.Token(exclamationEquals.GetLeadingTrivia(), SyntaxKind.ExclamationToken, "!", "!", trailing: null), ErrorCode.ERR_ParameterNullCheckingNotSupported)); - - // Return the split out `=` for the consumer to handle. - equalsToken = SyntaxFactory.Token(leading: null, SyntaxKind.EqualsToken, exclamationEquals.GetTrailingTrivia()); - } - else if (this.CurrentToken.Kind is SyntaxKind.ExclamationToken) - { - // We have seen at least '!' - // We check for a following '!' or '!=' to see if the user is trying to use '!!' (so we can give an appropriate error). - identifier = AddTrailingSkippedSyntax(identifier, this.AddError(this.EatToken(), ErrorCode.ERR_ParameterNullCheckingNotSupported)); - if (this.CurrentToken.Kind is SyntaxKind.ExclamationToken) - { - identifier = AddTrailingSkippedSyntax(identifier, this.EatToken()); - } - else if (this.CurrentToken.Kind is SyntaxKind.ExclamationEqualsToken) - { - // split != into two tokens. - var exclamationEquals = this.EatToken(); - - identifier = AddTrailingSkippedSyntax( - identifier, - SyntaxFactory.Token(exclamationEquals.GetLeadingTrivia(), SyntaxKind.ExclamationToken, trailing: null)); - equalsToken = SyntaxFactory.Token(leading: null, SyntaxKind.EqualsToken, exclamationEquals.GetTrailingTrivia()); - } - } - } - /// /// Merges two successive tokens into a single token with the given . If the two tokens /// have no trivia between them, then the final token will be trivially generated, properly passing on the right @@ -12150,13 +12101,8 @@ private bool ScanParenthesizedImplicitlyTypedLambda(Precedence precedence) // case 2: ( x ) => if (IsTrueIdentifier(this.PeekToken(1))) { - // allow for a) => or a!!) => + // allow for a) => var skipIndex = 2; - if (PeekToken(skipIndex).Kind == SyntaxKind.ExclamationToken - && this.PeekToken(skipIndex + 1).Kind == SyntaxKind.ExclamationToken) - { - skipIndex += 2; - } // Must have: ) => if (this.PeekToken(skipIndex).Kind == SyntaxKind.CloseParenToken @@ -12199,18 +12145,9 @@ bool isParenVarCommaSyntax() { return true; } - - var token3 = this.PeekToken(3); - // ( x!! , [...] - // https://github.com/dotnet/roslyn/issues/58335: https://github.com/dotnet/roslyn/pull/46520#discussion_r466650228 - if (token2.Kind == SyntaxKind.ExclamationToken - && token3.Kind == SyntaxKind.ExclamationToken - && this.PeekToken(4).Kind == SyntaxKind.CommaToken) - { - return true; - } } } + return false; } } @@ -12263,9 +12200,7 @@ private bool ScanExplicitlyTypedLambda(Precedence precedence) // eat the parameter name. var identifier = this.IsTrueIdentifier() ? this.EatToken() : CreateMissingIdentifierToken(); - // eat a !! if present. - this.ParseParameterNullCheck(ref identifier, out var equalsToken); - equalsToken ??= TryEatToken(SyntaxKind.EqualsToken); + var equalsToken = TryEatToken(SyntaxKind.EqualsToken); // If we have an `=` then parse out a default value. Note: this is not legal, but this allows us to // to be resilient to the user writing this so we don't go completely off the rails. @@ -12523,25 +12458,6 @@ private bool IsPossibleLambdaExpression(Precedence precedence) return true; } - var token2 = this.PeekToken(2); - var token3 = this.PeekToken(3); - - if ((token1.Kind, token2.Kind, token3.Kind) is - - // x!! => - // - // Def a lambda (though possibly has errors). - (SyntaxKind.ExclamationToken, SyntaxKind.ExclamationToken, SyntaxKind.EqualsGreaterThanToken) - - // Broken case but error will be added in lambda function (!=>). - or (SyntaxKind.ExclamationEqualsToken, SyntaxKind.GreaterThanToken, _) - - // Broken case but error will be added in lambda function (!!=>). - or (SyntaxKind.ExclamationToken, SyntaxKind.ExclamationEqualsToken, SyntaxKind.GreaterThanToken)) - { - return true; - } - using var _ = this.GetDisposableResetPoint(resetOnDispose: true); // A lambda could be starting with attributes, attempt to skip past them and check after that point. @@ -13358,28 +13274,12 @@ LambdaExpressionSyntax parseLambdaExpressionWorker() { // Unparenthesized lambda case // x => ... - // x!! => ... var identifier = (this.CurrentToken.Kind != SyntaxKind.IdentifierToken && this.PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken) ? this.EatTokenAsKind(SyntaxKind.IdentifierToken) : this.ParseIdentifierToken(); - ParseParameterNullCheck(ref identifier, out var equalsToken); - - SyntaxToken arrow; - if (equalsToken != null) - { - // we only get an equals token if we had !!=> or !=> (enforced by IsPossibleLambdaExpression). - // So we must have a greater than token following. If not, some invariant is badly broken. - - var greaterThan = this.EatToken(); - Debug.Assert(greaterThan.Kind == SyntaxKind.GreaterThanToken); - arrow = MergeAdjacent(equalsToken, greaterThan, SyntaxKind.EqualsGreaterThanToken); - } - else - { - // Case x=>, x => - arrow = this.EatToken(SyntaxKind.EqualsGreaterThanToken); - } + // Case x=>, x => + var arrow = this.EatToken(SyntaxKind.EqualsGreaterThanToken); var parameter = _syntaxFactory.Parameter( attributeLists: default, modifiers: default, type: null, identifier, @default: null); @@ -13470,10 +13370,9 @@ private ParameterSyntax ParseLambdaParameter() : null; var identifier = this.ParseIdentifierToken(); - ParseParameterNullCheck(ref identifier, out var equalsToken); // Parse default value if any - equalsToken ??= TryEatToken(SyntaxKind.EqualsToken); + var equalsToken = TryEatToken(SyntaxKind.EqualsToken); return _syntaxFactory.Parameter( attributes, @@ -13512,7 +13411,6 @@ private bool ShouldParseLambdaParameterType() // (a) // (a => // (a { - // (a !! or (a !!= // (a = // // In all other cases, parse out a type. @@ -13521,7 +13419,6 @@ private bool ShouldParseLambdaParameterType() peek1.Kind != SyntaxKind.CloseParenToken && peek1.Kind != SyntaxKind.EqualsGreaterThanToken && peek1.Kind != SyntaxKind.OpenBraceToken && - peek1.Kind != SyntaxKind.ExclamationToken && peek1.Kind != SyntaxKind.EqualsToken) { return true; From 9ace195549577cafad6b1a2f855f1eb33e8f1cf3 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 4 Oct 2024 10:32:17 -0700 Subject: [PATCH 2/6] Update tests --- .../CSharp/Portable/Errors/ErrorCode.cs | 2 +- .../CSharp/Portable/Errors/ErrorFacts.cs | 1 - .../IncrementalParsingTests.cs | 10 +- .../Syntax/Parsing/DeclarationParsingTests.cs | 91 +++++++++---------- .../Parsing/LambdaParameterParsingTests.cs | 84 +++-------------- 5 files changed, 59 insertions(+), 129 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs index 7c07bb82d271e..bbc226d58c461 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs @@ -2029,7 +2029,7 @@ internal enum ErrorCode ERR_ScopedMismatchInParameterOfPartial = 8988, // param-nullchecking feature removed from C# 11 - ERR_ParameterNullCheckingNotSupported = 8989, + // ERR_ParameterNullCheckingNotSupported = 8989, // ERR_DiscardCannotBeNullChecked = 8990, // ERR_MustNullCheckInImplementation = 8991, // ERR_NonNullableValueTypeIsNullChecked = 8992, diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs index 4c8a7e03fa39c..0c288831b7ae8 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs @@ -2223,7 +2223,6 @@ or ErrorCode.ERR_ListPatternRequiresLength or ErrorCode.ERR_ScopedMismatchInParameterOfTarget or ErrorCode.ERR_ScopedMismatchInParameterOfOverrideOrImplementation or ErrorCode.ERR_ScopedMismatchInParameterOfPartial - or ErrorCode.ERR_ParameterNullCheckingNotSupported or ErrorCode.ERR_RawStringNotInDirectives or ErrorCode.ERR_UnterminatedRawString or ErrorCode.ERR_TooManyQuotesForRawString diff --git a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs index 6673c199fa691..0b87ce04af249 100644 --- a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs @@ -69,14 +69,8 @@ public void M(string? x !!) { }"; var oldTree = this.ParsePreview(text); var newTree = oldTree.WithReplaceFirst("?", ""); - oldTree.GetDiagnostics().Verify( - // (4,30): error CS8989: The 'parameter null-checking' feature is not supported. - // public void M(string? x !!) { - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(4, 30)); - newTree.GetDiagnostics().Verify( - // (4,29): error CS8989: The 'parameter null-checking' feature is not supported. - // public void M(string x !!) { - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(4, 29)); + oldTree.GetDiagnostics().Verify(); + newTree.GetDiagnostics().Verify(); var diffs = SyntaxDifferences.GetRebuiltNodes(oldTree, newTree); TestDiffsInOrder(diffs, diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs index f727bfd113093..061386f466a55 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs @@ -7250,9 +7250,9 @@ class C where T : struct? {} public void TestMethodDeclarationNullValidation() { UsingStatement(@"void M(string name!!) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7285,9 +7285,9 @@ public void TestMethodDeclarationNullValidation() public void TestMethodDeclarationNullValidation_SingleExclamation() { UsingStatement(@"void M(string name!) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { @@ -7323,9 +7323,9 @@ public void TestMethodDeclarationNullValidation_SingleExclamation_ExtraTrivia() { UsingStatement(@"void M(string name /*comment1*/!/*comment2*/) { }", options: TestOptions.RegularPreview, - // (2,29): error CS8989: The 'parameter null-checking' feature is not supported. - // /*comment1*/!/*comment2*/) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(2, 29)); + // (1,19): error CS1003: Syntax error, ',' expected + // void M(string name + Diagnostic(ErrorCode.ERR_SyntaxError, "").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { @@ -7360,9 +7360,9 @@ public void TestMethodDeclarationNullValidation_SingleExclamation_ExtraTrivia() public void TestOptParamMethodDeclarationWithNullValidation() { UsingStatement(@"void M(string name!! = null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!! = null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7402,10 +7402,7 @@ public void TestOptParamMethodDeclarationWithNullValidation() [Fact] public void TestOptParamMethodDeclarationWithNullValidationNoSpaces() { - UsingStatement(@"void M(string name!!=null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. - // void M(string name!!=null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + UsingStatement(@"void M(string name!!=null) { }", options: TestOptions.RegularPreview); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7586,9 +7583,9 @@ public void TestNullCheckedArgList5() // (1,19): error CS1001: Identifier expected // void M(__arglist[]!!= null) { } Diagnostic(ErrorCode.ERR_IdentifierExpected, "!").WithLocation(1, 19), - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(__arglist[]!!= null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7741,9 +7738,9 @@ public void TestArgListWithDefaultValue() public void TestNullCheckedArgWithLeadingSpace() { UsingStatement(@"void M(string name !!=null) { }", options: TestOptions.RegularPreview, - // (1,20): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,20): error CS1003: Syntax error, ',' expected // void M(string name !!=null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 20)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 20)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7784,9 +7781,9 @@ public void TestNullCheckedArgWithLeadingSpace() public void TestNullCheckedArgWithLeadingNewLine() { UsingStatement(@"void M(string name!!=null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!=null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7827,9 +7824,9 @@ public void TestNullCheckedArgWithLeadingNewLine() public void TestNullCheckedArgWithTrailingSpace() { UsingStatement(@"void M(string name!!= null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!= null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7870,9 +7867,9 @@ public void TestNullCheckedArgWithTrailingSpace() public void TestNullCheckedArgWithTrailingNewLine() { UsingStatement(@"void M(string name!!=null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!=null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7912,10 +7909,7 @@ public void TestNullCheckedArgWithTrailingNewLine() [Fact] public void TestNullCheckedArgWithSpaceInbetween() { - UsingStatement(@"void M(string name! !=null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. - // void M(string name! !=null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + UsingStatement(@"void M(string name! !=null) { }", options: TestOptions.RegularPreview); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7957,9 +7951,9 @@ public void TestNullCheckedArgWithSpaceInbetween() public void TestNullCheckedArgWithSpaceAfterParam() { UsingStatement(@"void M(string name !!=null) { }", options: TestOptions.RegularPreview, - // (1,20): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,20): error CS1003: Syntax error, ',' expected // void M(string name !!=null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 20)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 20)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8000,9 +7994,9 @@ public void TestNullCheckedArgWithSpaceAfterParam() public void TestNullCheckedArgWithSpaceAfterBangs() { UsingStatement(@"void M(string name! ! =null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name! ! =null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8044,9 +8038,9 @@ public void TestNullCheckedArgWithSpaceAfterBangs() public void TestNullCheckedArgWithSpaceBeforeBangs() { UsingStatement(@"void M(string name ! !=null) { }", options: TestOptions.RegularPreview, - // (1,20): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,20): error CS1003: Syntax error, ',' expected // void M(string name ! !=null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 20)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 20)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8088,9 +8082,9 @@ public void TestNullCheckedArgWithSpaceBeforeBangs() public void TestNullCheckedArgWithSpaceAfterEquals() { UsingStatement(@"void M(string name!!= null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!= null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8131,12 +8125,9 @@ public void TestNullCheckedArgWithSpaceAfterEquals() public void TestMethodDeclarationNullValidation_ExtraEquals() { UsingStatement(@"void M(string name!!= = null) { }", options: TestOptions.RegularPreview, - // (1,19): error CS8989: The 'parameter null-checking' feature is not supported. - // void M(string name!!= = null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19), - // (1,23): error CS1525: Invalid expression term '=' + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!= = null) { } - Diagnostic(ErrorCode.ERR_InvalidExprTerm, "=").WithArguments("=").WithLocation(1, 23)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { @@ -8191,9 +8182,9 @@ class C { public void M(string x!!) { } }", options: TestOptions.RegularPreview, - // (4,27): error CS8989: The 'parameter null-checking' feature is not supported. + // (4,27): error CS1003: Syntax error, ',' expected // public void M(string x!!) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(4, 27)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(4, 27)); N(SyntaxKind.CompilationUnit); { N(SyntaxKind.ClassDeclaration); @@ -8242,9 +8233,9 @@ class C { public C(string x!!) { } }", options: TestOptions.RegularPreview, - // (4,22): error CS8989: The 'parameter null-checking' feature is not supported. + // (4,22): error CS1003: Syntax error, ',' expected // public C(string x!!) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(4, 22)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(4, 22)); N(SyntaxKind.CompilationUnit); { N(SyntaxKind.ClassDeclaration); @@ -8292,9 +8283,9 @@ class Box return 2; } }", options: TestOptions.RegularPreview, - // (4,39): error CS8989: The 'parameter null-checking' feature is not supported. + // (4,39): error CS1003: Syntax error, ',' expected // public static int operator+ (Box b!!, Box c) - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(4, 39)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(4, 39)); N(SyntaxKind.CompilationUnit); { @@ -8362,15 +8353,15 @@ public void TestAnonymousDelegateNullChecking() UsingTree(@" delegate void Del(int x!!); Del d = delegate(int k!!) { /* ... */ };", options: TestOptions.RegularPreview, - // (2,24): error CS8989: The 'parameter null-checking' feature is not supported. + // (2,24): error CS1003: Syntax error, ',' expected // delegate void Del(int x!!); - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(2, 24), + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(2, 24), // (3,1): error CS8803: Top-level statements must precede namespace and type declarations. // Del d = delegate(int k!!) { /* ... */ }; Diagnostic(ErrorCode.ERR_TopLevelStatementAfterNamespaceOrType, "Del d = delegate(int k!!) { /* ... */ };").WithLocation(3, 1), - // (3,23): error CS8989: The 'parameter null-checking' feature is not supported. + // (3,23): error CS1003: Syntax error, ',' expected // Del d = delegate(int k!!) { /* ... */ }; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(3, 23)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(3, 23)); N(SyntaxKind.CompilationUnit); { N(SyntaxKind.DelegateDeclaration); diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs index ea4c3db0cb8de..f8bbc2a5e98b5 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs @@ -775,10 +775,7 @@ public void Arglist_03() [Fact] public void TestLambdaWithNullValidation() { - UsingDeclaration("Func func1 = x!! => x + \"1\";", options: TestOptions.RegularPreview, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = x!! => x + "1"; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + UsingDeclaration("Func func1 = x!! => x + \"1\";", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -835,10 +832,7 @@ public void TestLambdaWithNullValidation() [Fact] public void TestLambdaWithNullValidationParams() { - UsingDeclaration("Func func1 = (x!!, y) => x == y;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = (x!!, y) => x == y; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32)); + UsingDeclaration("Func func1 = (x!!, y) => x == y;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -910,10 +904,7 @@ public void TestLambdaWithNullValidationParams() [Fact] public void TestNullCheckedSingleParamInParens() { - UsingDeclaration("Func func1 = (x!!) => x;", options: TestOptions.RegularPreview, - // (1,26): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = (x!!) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 26)); + UsingDeclaration("Func func1 = (x!!) => x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -967,10 +958,7 @@ public void TestNullCheckedSingleParamInParens() [Fact] public void TestNullCheckedSingleParamNoSpaces() { - UsingDeclaration("Func func1 = x!!=>x;", options: TestOptions.RegularPreview, - // (1,25): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = x!!=>x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 25)); + UsingDeclaration("Func func1 = x!!=>x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1019,10 +1007,7 @@ public void TestNullCheckedSingleParamNoSpaces() [Fact] public void TestNullCheckedTypedSingleParamInParen() { - UsingDeclaration("Func func1 = (int x!!) => x;", options: TestOptions.RegularPreview, - // (1,30): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = (int x!!) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 30)); + UsingDeclaration("Func func1 = (int x!!) => x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1080,10 +1065,7 @@ public void TestNullCheckedTypedSingleParamInParen() [Fact] public void TestNullCheckedTypedManyParams() { - UsingDeclaration("Func func1 = (int x!!, int y) => x;", options: TestOptions.RegularPreview, - // (1,35): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = (int x!!, int y) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 35)); + UsingDeclaration("Func func1 = (int x!!, int y) => x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1155,13 +1137,7 @@ public void TestNullCheckedTypedManyParams() [Fact] public void TestManyNullCheckedTypedParams() { - UsingDeclaration("Func func1 = (int x!!, int y!!) => x;", options: TestOptions.RegularPreview, - // (1,35): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = (int x!!, int y!!) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 35), - // (1,44): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = (int x!!, int y!!) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 44)); + UsingDeclaration("Func func1 = (int x!!, int y!!) => x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1285,10 +1261,7 @@ public void TestNullCheckedNoParams() [Fact] public void TestNullCheckedDiscard() { - UsingDeclaration("Func func1 = (_!!) => 42;", options: TestOptions.RegularPreview, - // (1,26): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = (_!!) => 42; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 26)); + UsingDeclaration("Func func1 = (_!!) => 42;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1342,10 +1315,7 @@ public void TestNullCheckedDiscard() [Fact] public void TestNullCheckedSyntaxCorrection0() { - UsingDeclaration("Func func0 = x!=> x;", options: TestOptions.RegularPreview, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func0 = x!=> x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + UsingDeclaration("Func func0 = x!=> x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1397,10 +1367,7 @@ public void TestNullCheckedSyntaxCorrection0() [Fact] public void TestNullCheckedSyntaxCorrection1() { - UsingDeclaration("Func func1 = x !=> x;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func1 = x !=> x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32)); + UsingDeclaration("Func func1 = x !=> x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1452,13 +1419,7 @@ public void TestNullCheckedSyntaxCorrection1() [Fact] public void TestNullCheckedSyntaxCorrection2() { - UsingDeclaration("Func func2 = x != > x;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func2 = x != > x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32), - // (1,33): error CS1003: Syntax error, '=>' expected - // Func func2 = x != > x; - Diagnostic(ErrorCode.ERR_SyntaxError, "=").WithArguments("=>").WithLocation(1, 33)); + UsingDeclaration("Func func2 = x != > x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1610,10 +1571,7 @@ public void TestNullCheckedSyntaxCorrection4() [Fact] public void TestNullCheckedSyntaxCorrection5() { - UsingDeclaration("Func func5 = x !!=> x;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func5 = x !!=> x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32)); + UsingDeclaration("Func func5 = x !!=> x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1664,13 +1622,7 @@ public void TestNullCheckedSyntaxCorrection5() [Fact] public void TestNullCheckedSyntaxCorrection6() { - UsingDeclaration("Func func6 = x !!= > x;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func6 = x !!= > x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32), - // (1,34): error CS1003: Syntax error, '=>' expected - // Func func6 = x !!= > x; - Diagnostic(ErrorCode.ERR_SyntaxError, "=").WithArguments("=>").WithLocation(1, 34)); + UsingDeclaration("Func func6 = x !!= > x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1722,10 +1674,7 @@ public void TestNullCheckedSyntaxCorrection6() [Fact] public void TestNullCheckedSyntaxCorrection7() { - UsingDeclaration("Func func7 = x!! => x;", options: TestOptions.RegularPreview, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func7 = x!! => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + UsingDeclaration("Func func7 = x!! => x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1776,10 +1725,7 @@ public void TestNullCheckedSyntaxCorrection7() [Fact] public void TestNullCheckedSyntaxCorrection8() { - UsingDeclaration("Func func8 = x! !=> x;", options: TestOptions.RegularPreview, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. - // Func func8 = x! !=> x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + UsingDeclaration("Func func8 = x! !=> x;", options: TestOptions.RegularPreview); N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); From e0b0c0fc4395a1c999c3f94f67977bf5076b6175 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 7 Oct 2024 10:23:54 -0700 Subject: [PATCH 3/6] Update tests --- .../IncrementalParsingTests.cs | 10 +- .../Syntax/Parsing/DeclarationParsingTests.cs | 144 +- .../Parsing/LambdaParameterParsingTests.cs | 1213 +++++++++-------- 3 files changed, 713 insertions(+), 654 deletions(-) diff --git a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs index 0b87ce04af249..fa72f15c6145d 100644 --- a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs @@ -69,8 +69,14 @@ public void M(string? x !!) { }"; var oldTree = this.ParsePreview(text); var newTree = oldTree.WithReplaceFirst("?", ""); - oldTree.GetDiagnostics().Verify(); - newTree.GetDiagnostics().Verify(); + oldTree.GetDiagnostics().Verify( + // (4,30): error CS1003: Syntax error, ',' expected + // public void M(string? x !!) { + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(4, 30)); + newTree.GetDiagnostics().Verify( + // (4,29): error CS1003: Syntax error, ',' expected + // public void M(string x !!) { + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(4, 29)); var diffs = SyntaxDifferences.GetRebuiltNodes(oldTree, newTree); TestDiffsInOrder(diffs, diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs index 061386f466a55..87783228a995d 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs @@ -7363,6 +7363,7 @@ public void TestOptParamMethodDeclarationWithNullValidation() // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!! = null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7380,14 +7381,6 @@ public void TestOptParamMethodDeclarationWithNullValidation() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7397,12 +7390,17 @@ public void TestOptParamMethodDeclarationWithNullValidation() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] public void TestOptParamMethodDeclarationWithNullValidationNoSpaces() { - UsingStatement(@"void M(string name!!=null) { }", options: TestOptions.RegularPreview); + UsingStatement(@"void M(string name!!=null) { }", options: TestOptions.RegularPreview, + // (1,19): error CS1003: Syntax error, ',' expected + // void M(string name!!=null) { } + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7420,14 +7418,6 @@ public void TestOptParamMethodDeclarationWithNullValidationNoSpaces() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7437,6 +7427,7 @@ public void TestOptParamMethodDeclarationWithNullValidationNoSpaces() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] @@ -7586,6 +7577,7 @@ public void TestNullCheckedArgList5() // (1,19): error CS1003: Syntax error, ',' expected // void M(__arglist[]!!= null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7620,14 +7612,6 @@ public void TestNullCheckedArgList5() M(SyntaxKind.IdentifierToken); } M(SyntaxKind.IdentifierToken); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7741,6 +7725,7 @@ public void TestNullCheckedArgWithLeadingSpace() // (1,20): error CS1003: Syntax error, ',' expected // void M(string name !!=null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 20)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7758,14 +7743,6 @@ public void TestNullCheckedArgWithLeadingSpace() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7775,6 +7752,7 @@ public void TestNullCheckedArgWithLeadingSpace() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] @@ -7784,6 +7762,7 @@ public void TestNullCheckedArgWithLeadingNewLine() // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!=null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7801,14 +7780,6 @@ public void TestNullCheckedArgWithLeadingNewLine() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7818,6 +7789,7 @@ public void TestNullCheckedArgWithLeadingNewLine() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] @@ -7827,6 +7799,7 @@ public void TestNullCheckedArgWithTrailingSpace() // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!= null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7844,14 +7817,6 @@ public void TestNullCheckedArgWithTrailingSpace() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7861,6 +7826,7 @@ public void TestNullCheckedArgWithTrailingSpace() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] @@ -7870,6 +7836,7 @@ public void TestNullCheckedArgWithTrailingNewLine() // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!=null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7887,14 +7854,6 @@ public void TestNullCheckedArgWithTrailingNewLine() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7904,12 +7863,17 @@ public void TestNullCheckedArgWithTrailingNewLine() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] public void TestNullCheckedArgWithSpaceInbetween() { - UsingStatement(@"void M(string name! !=null) { }", options: TestOptions.RegularPreview); + UsingStatement(@"void M(string name! !=null) { }", options: TestOptions.RegularPreview, + // (1,19): error CS1003: Syntax error, ',' expected + // void M(string name! !=null) { } + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7927,14 +7891,6 @@ public void TestNullCheckedArgWithSpaceInbetween() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7954,6 +7910,8 @@ public void TestNullCheckedArgWithSpaceAfterParam() // (1,20): error CS1003: Syntax error, ',' expected // void M(string name !!=null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 20)); + + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7971,14 +7929,6 @@ public void TestNullCheckedArgWithSpaceAfterParam() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -7988,6 +7938,7 @@ public void TestNullCheckedArgWithSpaceAfterParam() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] @@ -7997,6 +7948,7 @@ public void TestNullCheckedArgWithSpaceAfterBangs() // (1,19): error CS1003: Syntax error, ',' expected // void M(string name! ! =null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8014,14 +7966,6 @@ public void TestNullCheckedArgWithSpaceAfterBangs() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -8041,6 +7985,7 @@ public void TestNullCheckedArgWithSpaceBeforeBangs() // (1,20): error CS1003: Syntax error, ',' expected // void M(string name ! !=null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 20)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8058,14 +8003,6 @@ public void TestNullCheckedArgWithSpaceBeforeBangs() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -8085,6 +8022,7 @@ public void TestNullCheckedArgWithSpaceAfterEquals() // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!= null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8102,14 +8040,6 @@ public void TestNullCheckedArgWithSpaceAfterEquals() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } } N(SyntaxKind.CloseParenToken); } @@ -8119,6 +8049,7 @@ public void TestNullCheckedArgWithSpaceAfterEquals() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] @@ -8129,6 +8060,7 @@ public void TestMethodDeclarationNullValidation_ExtraEquals() // void M(string name!!= = null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); + N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8146,22 +8078,6 @@ public void TestMethodDeclarationNullValidation_ExtraEquals() N(SyntaxKind.StringKeyword); } N(SyntaxKind.IdentifierToken, "name"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleAssignmentExpression); - { - M(SyntaxKind.IdentifierName); - { - M(SyntaxKind.IdentifierToken); - } - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } - } } N(SyntaxKind.CloseParenToken); } diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs index f8bbc2a5e98b5..6a715e65d95ac 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs @@ -775,446 +775,485 @@ public void Arglist_03() [Fact] public void TestLambdaWithNullValidation() { - UsingDeclaration("Func func1 = x!! => x + \"1\";", options: TestOptions.RegularPreview); + UsingDeclaration("""Func func1 = x!! => x + "1";""", options: TestOptions.RegularPreview, + // (1,34): error CS1003: Syntax error, ',' expected + // Func func1 = x!! => x + "1"; + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 34)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); { N(SyntaxKind.GenericName); - N(SyntaxKind.IdentifierToken, "Func"); - N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.LessThanToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.StringKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); + N(SyntaxKind.IdentifierToken, "Func"); + N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.StringKeyword); + N(SyntaxKind.LessThanToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.StringKeyword); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.StringKeyword); + } + N(SyntaxKind.GreaterThanToken); } - N(SyntaxKind.GreaterThanToken); } - } - N(SyntaxKind.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.VariableDeclarator); { - N(SyntaxKind.Parameter); - { - N(SyntaxKind.IdentifierToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.AddExpression); + N(SyntaxKind.IdentifierToken, "func1"); + N(SyntaxKind.EqualsValueClause); { - N(SyntaxKind.IdentifierName); - { - N(SyntaxKind.IdentifierToken); - } - N(SyntaxKind.PlusToken); - N(SyntaxKind.StringLiteralExpression); + N(SyntaxKind.EqualsToken); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.StringLiteralToken); + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.ExclamationToken); } } } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestLambdaWithNullValidationParams() { - UsingDeclaration("Func func1 = (x!!, y) => x == y;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func1 = (x!!, y) => x == y;", options: TestOptions.RegularPreview, + // (1,39): error CS1003: Syntax error, ',' expected + // Func func1 = (x!!, y) => x == y; + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 39)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); { N(SyntaxKind.GenericName); - N(SyntaxKind.IdentifierToken, "Func"); - N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.LessThanToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.BoolKeyword); - } - N(SyntaxKind.GreaterThanToken); - } - } - N(SyntaxKind.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); - { - N(SyntaxKind.ParameterList); + N(SyntaxKind.IdentifierToken, "Func"); + N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.LessThanToken); + N(SyntaxKind.PredefinedType); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IntKeyword); } N(SyntaxKind.CommaToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.PredefinedType); { - N(SyntaxKind.IdentifierToken, "y"); + N(SyntaxKind.IntKeyword); } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.EqualsExpression); - { - N(SyntaxKind.IdentifierName); + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); { - N(SyntaxKind.IdentifierToken); + N(SyntaxKind.BoolKeyword); } - N(SyntaxKind.EqualsEqualsToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.GreaterThanToken); + } + } + N(SyntaxKind.VariableDeclarator); + { + N(SyntaxKind.IdentifierToken, "func1"); + N(SyntaxKind.EqualsValueClause); + { + N(SyntaxKind.EqualsToken); + N(SyntaxKind.TupleExpression); { - N(SyntaxKind.IdentifierToken); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Argument); + { + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.ExclamationToken); + } + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.Argument); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "y"); + } + } + N(SyntaxKind.CloseParenToken); } } } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedSingleParamInParens() { - UsingDeclaration("Func func1 = (x!!) => x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func1 = (x!!) => x;", options: TestOptions.RegularPreview, + // (1,30): error CS1003: Syntax error, ',' expected + // Func func1 = (x!!) => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 30)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); { N(SyntaxKind.GenericName); - N(SyntaxKind.IdentifierToken, "Func"); - N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.LessThanToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); + N(SyntaxKind.IdentifierToken, "Func"); + N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.IntKeyword); + N(SyntaxKind.LessThanToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.GreaterThanToken); } - N(SyntaxKind.GreaterThanToken); } - } - N(SyntaxKind.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.VariableDeclarator); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.IdentifierToken, "func1"); + N(SyntaxKind.EqualsValueClause); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.EqualsToken); + N(SyntaxKind.ParenthesizedExpression); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.CloseParenToken); } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); - { - N(SyntaxKind.IdentifierToken); } } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedSingleParamNoSpaces() { - UsingDeclaration("Func func1 = x!!=>x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func1 = x!!=>x;", options: TestOptions.RegularPreview, + // (1,28): error CS1525: Invalid expression term '>' + // Func func1 = x!!=>x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 28)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); { N(SyntaxKind.GenericName); - N(SyntaxKind.IdentifierToken, "Func"); - N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.LessThanToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); + N(SyntaxKind.IdentifierToken, "Func"); + N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.IntKeyword); + N(SyntaxKind.LessThanToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.GreaterThanToken); } - N(SyntaxKind.GreaterThanToken); } - } - N(SyntaxKind.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.VariableDeclarator); { - N(SyntaxKind.Parameter); - { - N(SyntaxKind.IdentifierToken, "x"); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.IdentifierToken, "func1"); + N(SyntaxKind.EqualsValueClause); { - N(SyntaxKind.IdentifierToken); + N(SyntaxKind.EqualsToken); + N(SyntaxKind.NotEqualsExpression); + { + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.ExclamationEqualsToken); + N(SyntaxKind.GreaterThanExpression); + { + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.GreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + } + } } } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedTypedSingleParamInParen() { - UsingDeclaration("Func func1 = (int x!!) => x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func1 = (int x!!) => x;", options: TestOptions.RegularPreview, + // (1,25): error CS1525: Invalid expression term 'int' + // Func func1 = (int x!!) => x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(1, 25), + // (1,29): error CS1026: ) expected + // Func func1 = (int x!!) => x; + Diagnostic(ErrorCode.ERR_CloseParenExpected, "x").WithLocation(1, 29), + // (1,29): error CS1003: Syntax error, ',' expected + // Func func1 = (int x!!) => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "x").WithArguments(",").WithLocation(1, 29)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); { N(SyntaxKind.GenericName); - N(SyntaxKind.IdentifierToken, "Func"); - N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.LessThanToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); + N(SyntaxKind.IdentifierToken, "Func"); + N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.IntKeyword); + N(SyntaxKind.LessThanToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.GreaterThanToken); } - N(SyntaxKind.GreaterThanToken); } - } - N(SyntaxKind.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.VariableDeclarator); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.IdentifierToken, "func1"); + N(SyntaxKind.EqualsValueClause); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.EqualsToken); + N(SyntaxKind.ParenthesizedExpression); { + N(SyntaxKind.OpenParenToken); N(SyntaxKind.PredefinedType); { N(SyntaxKind.IntKeyword); } - N(SyntaxKind.IdentifierToken, "x"); + M(SyntaxKind.CloseParenToken); } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); - { - N(SyntaxKind.IdentifierToken); } } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedTypedManyParams() { - UsingDeclaration("Func func1 = (int x!!, int y) => x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func1 = (int x!!, int y) => x;", options: TestOptions.RegularPreview, + // (1,30): error CS1525: Invalid expression term 'int' + // Func func1 = (int x!!, int y) => x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(1, 30), + // (1,34): error CS1026: ) expected + // Func func1 = (int x!!, int y) => x; + Diagnostic(ErrorCode.ERR_CloseParenExpected, "x").WithLocation(1, 34), + // (1,34): error CS1003: Syntax error, ',' expected + // Func func1 = (int x!!, int y) => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "x").WithArguments(",").WithLocation(1, 34), + // (1,39): error CS1001: Identifier expected + // Func func1 = (int x!!, int y) => x; + Diagnostic(ErrorCode.ERR_IdentifierExpected, "int").WithLocation(1, 39), + // (1,39): error CS1003: Syntax error, ',' expected + // Func func1 = (int x!!, int y) => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "int").WithArguments(",").WithLocation(1, 39)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); { N(SyntaxKind.GenericName); - N(SyntaxKind.IdentifierToken, "Func"); - N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.LessThanToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); + N(SyntaxKind.IdentifierToken, "Func"); + N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.IntKeyword); + N(SyntaxKind.LessThanToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.GreaterThanToken); } - N(SyntaxKind.GreaterThanToken); } - } - N(SyntaxKind.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.VariableDeclarator); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.IdentifierToken, "func1"); + N(SyntaxKind.EqualsValueClause); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); - { - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.IdentifierToken, "x"); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.EqualsToken); + N(SyntaxKind.ParenthesizedExpression); { + N(SyntaxKind.OpenParenToken); N(SyntaxKind.PredefinedType); { N(SyntaxKind.IntKeyword); } - N(SyntaxKind.IdentifierToken, "y"); + M(SyntaxKind.CloseParenToken); } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); - { - N(SyntaxKind.IdentifierToken); } } - } - N(SyntaxKind.SemicolonToken); - } - } - - [Fact] - public void TestManyNullCheckedTypedParams() - { - UsingDeclaration("Func func1 = (int x!!, int y!!) => x;", options: TestOptions.RegularPreview); - N(SyntaxKind.FieldDeclaration); - { - N(SyntaxKind.VariableDeclaration); - { - N(SyntaxKind.GenericName); - N(SyntaxKind.IdentifierToken, "Func"); - N(SyntaxKind.TypeArgumentList); - { - N(SyntaxKind.LessThanToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.GreaterThanToken); + N(SyntaxKind.CommaToken); + M(SyntaxKind.VariableDeclarator); + { + M(SyntaxKind.IdentifierToken); } } - N(SyntaxKind.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); + N(SyntaxKind.SemicolonToken); + } + EOF(); + } + + [Fact] + public void TestManyNullCheckedTypedParams() + { + UsingDeclaration("Func func1 = (int x!!, int y!!) => x;", options: TestOptions.RegularPreview, + // (1,30): error CS1525: Invalid expression term 'int' + // Func func1 = (int x!!, int y!!) => x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "int").WithArguments("int").WithLocation(1, 30), + // (1,34): error CS1026: ) expected + // Func func1 = (int x!!, int y!!) => x; + Diagnostic(ErrorCode.ERR_CloseParenExpected, "x").WithLocation(1, 34), + // (1,34): error CS1003: Syntax error, ',' expected + // Func func1 = (int x!!, int y!!) => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "x").WithArguments(",").WithLocation(1, 34), + // (1,39): error CS1001: Identifier expected + // Func func1 = (int x!!, int y!!) => x; + Diagnostic(ErrorCode.ERR_IdentifierExpected, "int").WithLocation(1, 39), + // (1,39): error CS1003: Syntax error, ',' expected + // Func func1 = (int x!!, int y!!) => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "int").WithArguments(",").WithLocation(1, 39)); + + N(SyntaxKind.FieldDeclaration); + { + N(SyntaxKind.VariableDeclaration); { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.GenericName); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.IdentifierToken, "Func"); + N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.LessThanToken); + N(SyntaxKind.PredefinedType); { - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); } N(SyntaxKind.CommaToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.GreaterThanToken); + } + } + N(SyntaxKind.VariableDeclarator); + { + N(SyntaxKind.IdentifierToken, "func1"); + N(SyntaxKind.EqualsValueClause); + { + N(SyntaxKind.EqualsToken); + N(SyntaxKind.ParenthesizedExpression); { + N(SyntaxKind.OpenParenToken); N(SyntaxKind.PredefinedType); { N(SyntaxKind.IntKeyword); } - N(SyntaxKind.IdentifierToken, "y"); + M(SyntaxKind.CloseParenToken); } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); - { - N(SyntaxKind.IdentifierToken); } } + N(SyntaxKind.CommaToken); + M(SyntaxKind.VariableDeclarator); + { + M(SyntaxKind.IdentifierToken); + } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedNoParams() { - UsingDeclaration("Func func1 = (!!) => 42;", options: TestOptions.RegularPreview, expectedErrors: new DiagnosticDescription[] - { - // (1,20): error CS1001: Identifier expected + UsingDeclaration("Func func1 = (!!) => 42;", options: TestOptions.RegularPreview, + // (1,22): error CS1525: Invalid expression term ')' // Func func1 = (!!) => 42; - Diagnostic(ErrorCode.ERR_IdentifierExpected, "!").WithLocation(1, 20) - }); + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ")").WithArguments(")").WithLocation(1, 22), + // (1,24): error CS1003: Syntax error, ',' expected + // Func func1 = (!!) => 42; + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 24)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1238,84 +1277,100 @@ public void TestNullCheckedNoParams() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.ParenthesizedExpression); { - N(SyntaxKind.ParameterList); - { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.NumericLiteralExpression); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.LogicalNotExpression); { - N(SyntaxKind.NumericLiteralToken, "42"); + N(SyntaxKind.ExclamationToken); + N(SyntaxKind.LogicalNotExpression); + { + N(SyntaxKind.ExclamationToken); + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + } } + N(SyntaxKind.CloseParenToken); } } } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedDiscard() { - UsingDeclaration("Func func1 = (_!!) => 42;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func1 = (_!!) => 42;", options: TestOptions.RegularPreview, + // (1,30): error CS1003: Syntax error, ',' expected + // Func func1 = (_!!) => 42; + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 30)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); { N(SyntaxKind.GenericName); - N(SyntaxKind.IdentifierToken, "Func"); - N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.LessThanToken); - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.IntKeyword); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.PredefinedType); + N(SyntaxKind.IdentifierToken, "Func"); + N(SyntaxKind.TypeArgumentList); { - N(SyntaxKind.IntKeyword); + N(SyntaxKind.LessThanToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.GreaterThanToken); } - N(SyntaxKind.GreaterThanToken); } - } - N(SyntaxKind.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.VariableDeclarator); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.IdentifierToken, "func1"); + N(SyntaxKind.EqualsValueClause); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.EqualsToken); + N(SyntaxKind.ParenthesizedExpression); { - N(SyntaxKind.IdentifierToken, "_"); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "_"); + } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.CloseParenToken); } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.NumericLiteralExpression); - { - N(SyntaxKind.NumericLiteralToken); } } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedSyntaxCorrection0() { - UsingDeclaration("Func func0 = x!=> x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func0 = x!=> x;", options: TestOptions.RegularPreview, + // (1,33): error CS1525: Invalid expression term '>' + // Func func0 = x!=> x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 33)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1344,16 +1399,24 @@ public void TestNullCheckedSyntaxCorrection0() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.NotEqualsExpression); { - N(SyntaxKind.Parameter); + N(SyntaxKind.IdentifierName); { N(SyntaxKind.IdentifierToken, "x"); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.ExclamationEqualsToken); + N(SyntaxKind.GreaterThanExpression); { - N(SyntaxKind.IdentifierToken, "x"); + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.GreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } } } } @@ -1367,7 +1430,11 @@ public void TestNullCheckedSyntaxCorrection0() [Fact] public void TestNullCheckedSyntaxCorrection1() { - UsingDeclaration("Func func1 = x !=> x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func1 = x !=> x;", options: TestOptions.RegularPreview, + // (1,34): error CS1525: Invalid expression term '>' + // Func func1 = x !=> x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 34)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1396,16 +1463,24 @@ public void TestNullCheckedSyntaxCorrection1() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.NotEqualsExpression); { - N(SyntaxKind.Parameter); + N(SyntaxKind.IdentifierName); { N(SyntaxKind.IdentifierToken, "x"); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.ExclamationEqualsToken); + N(SyntaxKind.GreaterThanExpression); { - N(SyntaxKind.IdentifierToken, "x"); + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.GreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } } } } @@ -1419,7 +1494,11 @@ public void TestNullCheckedSyntaxCorrection1() [Fact] public void TestNullCheckedSyntaxCorrection2() { - UsingDeclaration("Func func2 = x != > x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func2 = x != > x;", options: TestOptions.RegularPreview, + // (1,35): error CS1525: Invalid expression term '>' + // Func func2 = x != > x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 35)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1448,16 +1527,24 @@ public void TestNullCheckedSyntaxCorrection2() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.NotEqualsExpression); { - N(SyntaxKind.Parameter); + N(SyntaxKind.IdentifierName); { N(SyntaxKind.IdentifierToken, "x"); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.ExclamationEqualsToken); + N(SyntaxKind.GreaterThanExpression); { - N(SyntaxKind.IdentifierToken, "x"); + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.GreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } } } } @@ -1571,7 +1658,11 @@ public void TestNullCheckedSyntaxCorrection4() [Fact] public void TestNullCheckedSyntaxCorrection5() { - UsingDeclaration("Func func5 = x !!=> x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func5 = x !!=> x;", options: TestOptions.RegularPreview, + // (1,35): error CS1525: Invalid expression term '>' + // Func func5 = x !!=> x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 35)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1600,16 +1691,28 @@ public void TestNullCheckedSyntaxCorrection5() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.NotEqualsExpression); { - N(SyntaxKind.Parameter); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.ExclamationEqualsToken); + N(SyntaxKind.GreaterThanExpression); { - N(SyntaxKind.IdentifierToken, "x"); + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.GreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } } } } @@ -1617,12 +1720,17 @@ public void TestNullCheckedSyntaxCorrection5() } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedSyntaxCorrection6() { - UsingDeclaration("Func func6 = x !!= > x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func6 = x !!= > x;", options: TestOptions.RegularPreview, + // (1,36): error CS1525: Invalid expression term '>' + // Func func6 = x !!= > x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 36)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1651,16 +1759,28 @@ public void TestNullCheckedSyntaxCorrection6() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.NotEqualsExpression); { - N(SyntaxKind.Parameter); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.ExclamationEqualsToken); + N(SyntaxKind.GreaterThanExpression); { - N(SyntaxKind.IdentifierToken, "x"); + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.GreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } } } } @@ -1674,7 +1794,11 @@ public void TestNullCheckedSyntaxCorrection6() [Fact] public void TestNullCheckedSyntaxCorrection7() { - UsingDeclaration("Func func7 = x!! => x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func7 = x!! => x;", options: TestOptions.RegularPreview, + // (1,34): error CS1003: Syntax error, ',' expected + // Func func7 = x!! => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 34)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1703,29 +1827,34 @@ public void TestNullCheckedSyntaxCorrection7() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.Parameter); - { - N(SyntaxKind.IdentifierToken, "x"); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); } + N(SyntaxKind.ExclamationToken); } } } } N(SyntaxKind.SemicolonToken); } + EOF(); } [Fact] public void TestNullCheckedSyntaxCorrection8() { - UsingDeclaration("Func func8 = x! !=> x;", options: TestOptions.RegularPreview); + UsingDeclaration("Func func8 = x! !=> x;", options: TestOptions.RegularPreview, + // (1,35): error CS1525: Invalid expression term '>' + // Func func8 = x! !=> x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 35)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1754,16 +1883,28 @@ public void TestNullCheckedSyntaxCorrection8() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.NotEqualsExpression); { - N(SyntaxKind.Parameter); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.ExclamationEqualsToken); + N(SyntaxKind.GreaterThanExpression); { - N(SyntaxKind.IdentifierToken, "x"); + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.GreaterThanToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } } } } @@ -1778,9 +1919,10 @@ public void TestNullCheckedSyntaxCorrection8() public void TestNullCheckedSyntaxCorrection9() { UsingDeclaration("Func func9 = x! ! => x;", options: TestOptions.RegularPreview, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,35): error CS1003: Syntax error, ',' expected // Func func9 = x! ! => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 35)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1809,17 +1951,17 @@ public void TestNullCheckedSyntaxCorrection9() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.Parameter); - { - N(SyntaxKind.IdentifierToken, "x"); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); } + N(SyntaxKind.ExclamationToken); } } } @@ -4250,9 +4392,9 @@ public void TestNullCheckedDefaultValueSimpleLambda() public void TestNullCheckedDefaultValueParenthesizedLambda1() { UsingDeclaration("Func func0 = (x!! = null) => x;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,43): error CS1003: Syntax error, ',' expected // Func func0 = (x!! = null) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32)); + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 43)); N(SyntaxKind.FieldDeclaration); { @@ -4282,30 +4424,30 @@ public void TestNullCheckedDefaultValueParenthesizedLambda1() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.ParenthesizedExpression); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.SimpleAssignmentExpression); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.IdentifierToken, "x"); - N(SyntaxKind.EqualsValueClause); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); + N(SyntaxKind.IdentifierName); { - N(SyntaxKind.NullKeyword); + N(SyntaxKind.IdentifierToken, "x"); } + N(SyntaxKind.ExclamationToken); } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.EqualsToken); + N(SyntaxKind.NullLiteralExpression); + { + N(SyntaxKind.NullKeyword); } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); - { - N(SyntaxKind.IdentifierToken, "x"); } + N(SyntaxKind.CloseParenToken); } } } @@ -4319,9 +4461,9 @@ public void TestNullCheckedDefaultValueParenthesizedLambda1() public void TestNullCheckedDefaultValueParenthesizedLambda2() { UsingDeclaration("Func func0 = (y, x!! = null) => x;", options: TestOptions.RegularPreview, - // (1,35): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,46): error CS1003: Syntax error, ',' expected // Func func0 = (y, x!! = null) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 35)); + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 46)); N(SyntaxKind.FieldDeclaration); { @@ -4351,35 +4493,41 @@ public void TestNullCheckedDefaultValueParenthesizedLambda2() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.TupleExpression); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Argument); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.IdentifierName); { N(SyntaxKind.IdentifierToken, "y"); } - N(SyntaxKind.CommaToken); - N(SyntaxKind.Parameter); + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.Argument); + { + N(SyntaxKind.SimpleAssignmentExpression); { - N(SyntaxKind.IdentifierToken, "x"); - N(SyntaxKind.EqualsValueClause); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.NullKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.EqualsToken); + N(SyntaxKind.NullLiteralExpression); + { + N(SyntaxKind.NullKeyword); } } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); - { - N(SyntaxKind.IdentifierToken, "x"); } + N(SyntaxKind.CloseParenToken); } } } @@ -4393,9 +4541,15 @@ public void TestNullCheckedDefaultValueParenthesizedLambda2() public void TestNullCheckedDefaultValueParenthesizedLambdaWithType1() { UsingDeclaration("Func func0 = (string x!! = null) => x;", options: TestOptions.RegularPreview, - // (1,39): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,31): error CS1525: Invalid expression term 'string' + // Func func0 = (string x!! = null) => x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "string").WithArguments("string").WithLocation(1, 31), + // (1,38): error CS1026: ) expected + // Func func0 = (string x!! = null) => x; + Diagnostic(ErrorCode.ERR_CloseParenExpected, "x").WithLocation(1, 38), + // (1,38): error CS1003: Syntax error, ',' expected // Func func0 = (string x!! = null) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 39)); + Diagnostic(ErrorCode.ERR_SyntaxError, "x").WithArguments(",").WithLocation(1, 38)); N(SyntaxKind.FieldDeclaration); { @@ -4425,34 +4579,14 @@ public void TestNullCheckedDefaultValueParenthesizedLambdaWithType1() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.ParenthesizedExpression); { - N(SyntaxKind.ParameterList); - { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); - { - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.StringKeyword); - } - N(SyntaxKind.IdentifierToken, "x"); - N(SyntaxKind.EqualsValueClause); - { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } - } - } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.PredefinedType); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.StringKeyword); } + M(SyntaxKind.CloseParenToken); } } } @@ -4466,9 +4600,15 @@ public void TestNullCheckedDefaultValueParenthesizedLambdaWithType1() public void TestNullCheckedDefaultValueParenthesizedLambdaWithType2() { UsingDeclaration("Func func0 = (string y, string x!! = null) => x;", options: TestOptions.RegularPreview, - // (1,49): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,41): error CS1525: Invalid expression term 'string' + // Func func0 = (string y, string x!! = null) => x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "string").WithArguments("string").WithLocation(1, 41), + // (1,48): error CS1026: ) expected + // Func func0 = (string y, string x!! = null) => x; + Diagnostic(ErrorCode.ERR_CloseParenExpected, "x").WithLocation(1, 48), + // (1,48): error CS1003: Syntax error, ',' expected // Func func0 = (string y, string x!! = null) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 49)); + Diagnostic(ErrorCode.ERR_SyntaxError, "x").WithArguments(",").WithLocation(1, 48)); N(SyntaxKind.FieldDeclaration); { @@ -4498,43 +4638,32 @@ public void TestNullCheckedDefaultValueParenthesizedLambdaWithType2() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.TupleExpression); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Argument); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); - { - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.StringKeyword); - } - N(SyntaxKind.IdentifierToken, "y"); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.DeclarationExpression); { N(SyntaxKind.PredefinedType); { N(SyntaxKind.StringKeyword); } - N(SyntaxKind.IdentifierToken, "x"); - N(SyntaxKind.EqualsValueClause); + N(SyntaxKind.SingleVariableDesignation); { - N(SyntaxKind.EqualsToken); - N(SyntaxKind.NullLiteralExpression); - { - N(SyntaxKind.NullKeyword); - } + N(SyntaxKind.IdentifierToken, "y"); } } - N(SyntaxKind.CloseParenToken); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.CommaToken); + N(SyntaxKind.Argument); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.StringKeyword); + } } + M(SyntaxKind.CloseParenToken); } } } @@ -4626,9 +4755,10 @@ public void TestArgListWithDefaultParameterValue() public void TestNullCheckedSpaceBetweenSimpleLambda() { UsingDeclaration("Func func0 = x! ! => x;", options: TestOptions.RegularPreview, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,35): error CS1003: Syntax error, ',' expected // Func func0 = x! ! => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 35)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -4657,17 +4787,17 @@ public void TestNullCheckedSpaceBetweenSimpleLambda() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.SimpleLambdaExpression); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.Parameter); - { - N(SyntaxKind.IdentifierToken, "x"); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); } + N(SyntaxKind.ExclamationToken); } } } @@ -4681,9 +4811,10 @@ public void TestNullCheckedSpaceBetweenSimpleLambda() public void TestNullCheckedSpaceBetweenParenthesizedLambda1() { UsingDeclaration("Func func0 = (x! !) => x;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,37): error CS1003: Syntax error, ',' expected // Func func0 = (x! !) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32)); + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 37)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -4712,22 +4843,22 @@ public void TestNullCheckedSpaceBetweenParenthesizedLambda1() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.ParenthesizedExpression); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.SuppressNullableWarningExpression); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); - { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.ExclamationToken); } + N(SyntaxKind.CloseParenToken); } } } @@ -4741,9 +4872,10 @@ public void TestNullCheckedSpaceBetweenParenthesizedLambda1() public void TestNullCheckedSpaceBetweenParenthesizedLambda2() { UsingDeclaration("Func func0 = (y, x! !) => x;", options: TestOptions.RegularPreview, - // (1,35): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,40): error CS1003: Syntax error, ',' expected // Func func0 = (y, x! !) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 35)); + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 40)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -4772,27 +4904,33 @@ public void TestNullCheckedSpaceBetweenParenthesizedLambda2() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.TupleExpression); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Argument); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.IdentifierName); { N(SyntaxKind.IdentifierToken, "y"); } - N(SyntaxKind.CommaToken); - N(SyntaxKind.Parameter); - { - N(SyntaxKind.IdentifierToken, "x"); - } - N(SyntaxKind.CloseParenToken); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.CommaToken); + N(SyntaxKind.Argument); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.SuppressNullableWarningExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.ExclamationToken); + } + N(SyntaxKind.ExclamationToken); + } } + N(SyntaxKind.CloseParenToken); } } } @@ -4806,9 +4944,16 @@ public void TestNullCheckedSpaceBetweenParenthesizedLambda2() public void TestNullCheckedSpaceBetweenLambdaWithType1() { UsingDeclaration("Func func0 = (string x! !) => x;", options: TestOptions.RegularPreview, - // (1,39): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,31): error CS1525: Invalid expression term 'string' // Func func0 = (string x! !) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 39)); + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "string").WithArguments("string").WithLocation(1, 31), + // (1,38): error CS1026: ) expected + // Func func0 = (string x! !) => x; + Diagnostic(ErrorCode.ERR_CloseParenExpected, "x").WithLocation(1, 38), + // (1,38): error CS1003: Syntax error, ',' expected + // Func func0 = (string x! !) => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "x").WithArguments(",").WithLocation(1, 38)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -4837,26 +4982,14 @@ public void TestNullCheckedSpaceBetweenLambdaWithType1() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.ParenthesizedExpression); { - N(SyntaxKind.ParameterList); - { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); - { - N(SyntaxKind.PredefinedType); - { - N(SyntaxKind.StringKeyword); - } - N(SyntaxKind.IdentifierToken, "x"); - } - N(SyntaxKind.CloseParenToken); - } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.PredefinedType); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.StringKeyword); } + M(SyntaxKind.CloseParenToken); } } } @@ -4870,9 +5003,16 @@ public void TestNullCheckedSpaceBetweenLambdaWithType1() public void TestNullCheckedSpaceBetweenLambdaWithType2() { UsingDeclaration("Func func0 = (string y, string x! !) => x;", options: TestOptions.RegularPreview, - // (1,49): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,41): error CS1525: Invalid expression term 'string' + // Func func0 = (string y, string x! !) => x; + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "string").WithArguments("string").WithLocation(1, 41), + // (1,48): error CS1026: ) expected // Func func0 = (string y, string x! !) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 49)); + Diagnostic(ErrorCode.ERR_CloseParenExpected, "x").WithLocation(1, 48), + // (1,48): error CS1003: Syntax error, ',' expected + // Func func0 = (string y, string x! !) => x; + Diagnostic(ErrorCode.ERR_SyntaxError, "x").WithArguments(",").WithLocation(1, 48)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -4901,35 +5041,32 @@ public void TestNullCheckedSpaceBetweenLambdaWithType2() N(SyntaxKind.EqualsValueClause); { N(SyntaxKind.EqualsToken); - N(SyntaxKind.ParenthesizedLambdaExpression); + N(SyntaxKind.TupleExpression); { - N(SyntaxKind.ParameterList); + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Argument); { - N(SyntaxKind.OpenParenToken); - N(SyntaxKind.Parameter); + N(SyntaxKind.DeclarationExpression); { N(SyntaxKind.PredefinedType); { N(SyntaxKind.StringKeyword); } - N(SyntaxKind.IdentifierToken, "y"); - } - N(SyntaxKind.CommaToken); - N(SyntaxKind.Parameter); - { - N(SyntaxKind.PredefinedType); + N(SyntaxKind.SingleVariableDesignation); { - N(SyntaxKind.StringKeyword); + N(SyntaxKind.IdentifierToken, "y"); } - N(SyntaxKind.IdentifierToken, "x"); } - N(SyntaxKind.CloseParenToken); } - N(SyntaxKind.EqualsGreaterThanToken); - N(SyntaxKind.IdentifierName); + N(SyntaxKind.CommaToken); + N(SyntaxKind.Argument); { - N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.StringKeyword); + } } + M(SyntaxKind.CloseParenToken); } } } From deee1fe89f9a4fef551948a9de20e0558302d565 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 7 Oct 2024 10:39:20 -0700 Subject: [PATCH 4/6] Remove loc string --- src/Compilers/CSharp/Portable/CSharpResources.resx | 3 --- src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf | 5 ----- src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf | 5 ----- .../CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf | 5 ----- .../CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf | 5 ----- 14 files changed, 68 deletions(-) diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 4210d8664c209..ef09ed5929e82 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -6358,9 +6358,6 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ Duplicate null suppression operator ('!') - - The 'parameter null-checking' feature is not supported. - Type '{0}' cannot be embedded because it has a re-abstraction of a member from base interface. Consider setting the 'Embed Interop Types' property to false. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index 8a3980dc0c336..3fb5f13e9c115 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -1622,11 +1622,6 @@ Metoda {0} určuje omezení struct pro parametr typu {1}, ale odpovídající parametr typu {2} přepsané nebo explicitně implementované metody {3} není typ, který nemůže mít hodnotu null. - - The 'parameter null-checking' feature is not supported. - Funkce parameter null-checking se nepodporuje. - - Constructor '{0}' leaves required member '{1}' uninitialized. Konstruktor {0} ponechá požadovaný člen {1} neinicializovaný. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index 844f25623b14f..fb930efd7fc4b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -1622,11 +1622,6 @@ Die Methode "{0}" gibt eine struct-Einschränkung für den Typparameter "{1}" an, aber der zugehörige Typparameter "{2}" der außer Kraft gesetzten oder explizit implementierten Methode "{3}" ist kein Non-Nullable-Werttyp. - - The 'parameter null-checking' feature is not supported. - Das "Parameter null-checking"-Feature wird nicht unterstützt. - - Constructor '{0}' leaves required member '{1}' uninitialized. Der Konstruktor "{0}" lässt den erforderlichen Member "{1}" deinitialisiert. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index b74515b7b9231..8b40569460016 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -1622,11 +1622,6 @@ El método "{0}" especifica una restricción "struct" para el parámetro de tipo "{1}", pero el parámetro de tipo correspondiente "{2}" de los métodos invalidados o implementados explícitamente "{3}" no es un tipo de valor que acepta valores NULL. - - The 'parameter null-checking' feature is not supported. - No se admite la característica "parameter null-checking". - - Constructor '{0}' leaves required member '{1}' uninitialized. El constructor "{0}" deja el miembro requerido "{1}" sin inicializar. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 711f3338ca166..6e80a79e1e7bd 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -1622,11 +1622,6 @@ La méthode '{0}' spécifie une contrainte 'struct' pour le paramètre de type '{1}', mais le paramètre de type '{2}' correspondant de la méthode substituée ou explicitement implémentée '{3}' n'est pas un type valeur non-nullable. - - The 'parameter null-checking' feature is not supported. - La fonctionnalité « paramètre null-checking » n’est pas prise en charge. - - Constructor '{0}' leaves required member '{1}' uninitialized. Le constructeur « {0} » laisse le membre « {1} » requis non initialisé. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index dfbab6eff83c5..9b704497fcd2e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -1622,11 +1622,6 @@ Il metodo '{0}' specifica un vincolo 'struct' per il parametro di tipo '{1}', ma il parametro di tipo corrispondente '{2}' del metodo '{3}' sottoposto a override o implementato in modo esplicito non è un tipo valore che non ammette valori Null. - - The 'parameter null-checking' feature is not supported. - La funzionalità 'parameter null-checking' non è supportata. - - Constructor '{0}' leaves required member '{1}' uninitialized. Il costruttore '{0}' lascia non inizializzato il membro richiesto '{1}'. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index 3082d6def6c8f..24072877d5c4c 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -1622,11 +1622,6 @@ メソッド '{0}' は、型パラメーター '{1}' に対して 'struct' 制約を指定していますが、オーバーライドされた、または明示的に実装されたメソッド '{3}' の対応する型パラメーター '{2}' は NULL 非許容の値型ではありません。 - - The 'parameter null-checking' feature is not supported. - 'parameter null-checking' 機能はサポートされていません。 - - Constructor '{0}' leaves required member '{1}' uninitialized. コンストラクター '{0}' は、必要なメンバー '{1}' を初期化しないままにします。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index 0d0629a24db2a..4fb4dc2b251ca 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -1622,11 +1622,6 @@ '{0}' 메서드는 형식 매개 변수 '{1}'의 'struct' 제약 조건을 지정하지만 재정의되었거나 명시적으로 구현된 '{3}' 메서드의 해당 형식 매개 변수 '{2}'이(가) null을 허용하지 않는 값 형식이 아닙니다. - - The 'parameter null-checking' feature is not supported. - 'parameter null-checking' 기능은 지원되지 않습니다. - - Constructor '{0}' leaves required member '{1}' uninitialized. 생성자 '{0}'은(는) 필수 멤버 '{1}'을(를) 초기화되지 않은 상태로 둡니다. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index 1a853f0945f1d..19bb4f822fb8c 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -1622,11 +1622,6 @@ Metoda „{0}” określa ograniczenie „struct” dla parametru typu „{1}”, lecz odpowiadający parametr typu „{2}” przesłoniętej lub jawnie zaimplementowanej metody „{3}” nie jest nienullowalnym typem wartości. - - The 'parameter null-checking' feature is not supported. - Funkcja „sprawdzanie wartości null parametru” nie jest obsługiwana. - - Constructor '{0}' leaves required member '{1}' uninitialized. Konstruktor „{0}” pozostawia wymaganą składową "{1}". diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index 54f448a982770..5cd5275ff8c9b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -1622,11 +1622,6 @@ O método '{0}' especifica uma restrição 'struct' para o parâmetro de tipo '{1}', mas o parâmetro de tipo correspondente '{2}' do método substituído ou implementado explicitamente '{3}' não é um tipo de valor não anulável. - - The 'parameter null-checking' feature is not supported. - O recurso de 'verificação nula de parâmetro' não tem suporte. - - Constructor '{0}' leaves required member '{1}' uninitialized. O construtor '{0}' deixa o membro obrigatório '{1}' não inicializado. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index ce535acf4444d..a51cfaae72950 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -1622,11 +1622,6 @@ Метод "{0}" задает ограничение struct для параметра типа "{1}", но соответствующий параметр типа "{2}" переопределенного или явно реализованного метода "{3}" не является типом значения, не допускающим значение NULL. - - The 'parameter null-checking' feature is not supported. - Функция "проверка значений NULL параметров" не поддерживается. - - Constructor '{0}' leaves required member '{1}' uninitialized. Конструктор "{0}" оставляет необходимый элемент "{1}" не инициализированным. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index ac2ce2281a961..356b41fcd8c66 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -1622,11 +1622,6 @@ '{0}' yöntemi, '{1}' tür parametresi için bir 'struct' kısıtlaması belirtiyor, ancak geçersiz kılınan veya açıkça uygulanan '{3}' yönteminin karşılık gelen '{2}' tür parametresi boş değer atanamaz bir tip değil. - - The 'parameter null-checking' feature is not supported. - 'Parametre null denetimi' özelliği desteklenmiyor. - - Constructor '{0}' leaves required member '{1}' uninitialized. Oluşturucu '{0}', gerekli '{1}' üyesinin başlatmasını geri alıyor. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index ab7b461fc4cfc..cab06fc70bb44 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -1622,11 +1622,6 @@ 方法 "{0}" 为类型参数 "{1}" 指定了 "struct" 约束,但重写的或显式实现的方法 "{3}" 的相应类型参数 "{2}" 不是不可为 null 的值类型。 - - The 'parameter null-checking' feature is not supported. - 不支持 'parameter null-checking' 功能。 - - Constructor '{0}' leaves required member '{1}' uninitialized. 构造函数“{0}”的必需成员“{1}”未初始化。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index 55f0936072bd4..a46b8496daad9 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -1622,11 +1622,6 @@ 方法 '{0}' 會為型別參數 '{1}' 指定 'struct' 條件約束,但覆寫或明確實作的方法 '{3}' 對應型別參數 '{2}' 是不可為 Null 實值型別。 - - The 'parameter null-checking' feature is not supported. - 不支援 'parameter null-checking' 功能。 - - Constructor '{0}' leaves required member '{1}' uninitialized. 建構函式 '{0}' 未初始化必要的成員 '{1}'。 From 458d8514c5c5bbc9607b77b4abf49db2d8bee3ab Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 7 Oct 2024 11:33:38 -0700 Subject: [PATCH 5/6] remove --- .../CSharp/Portable/Parser/LanguageParser.cs | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs b/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs index b6205c45c0847..f3db0e485c25d 100644 --- a/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs +++ b/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs @@ -4707,34 +4707,6 @@ private ParameterSyntax ParseParameter() equalsToken == null ? null : _syntaxFactory.EqualsValueClause(equalsToken, this.ParseExpressionCore())); } - /// - /// Merges two successive tokens into a single token with the given . If the two tokens - /// have no trivia between them, then the final token will be trivially generated, properly passing on the right - /// leading/trailing trivia. However, if there is trivia between the tokens, then appropriate errors will be - /// reported that the tokens cannot merge successfully. - /// - /// - /// IsFabricatedToken should be updated for tokens whose SyntaxKind is . - /// - private SyntaxToken? MergeAdjacent(SyntaxToken t1, SyntaxToken t2, SyntaxKind kind) - { - // Make sure we don't reuse the merged token for incremental parsing. - // "=>" wasn't proven to be a source of issues. See https://github.com/dotnet/roslyn/issues/60002 - Debug.Assert(Blender.Reader.IsFabricatedToken(kind) || kind == SyntaxKind.EqualsGreaterThanToken); - if (NoTriviaBetween(t1, t2)) - return SyntaxFactory.Token(t1.GetLeadingTrivia(), kind, t2.GetTrailingTrivia()); - - var sb = PooledStringBuilder.GetInstance(); - var writer = new StringWriter(sb.Builder, System.Globalization.CultureInfo.InvariantCulture); - t1.WriteTo(writer, leading: false, trailing: true); - t2.WriteTo(writer, leading: true, trailing: false); - var text = sb.ToStringAndFree(); - - return WithAdditionalDiagnostics( - SyntaxFactory.Token(t1.GetLeadingTrivia(), kind, text, text, t2.GetTrailingTrivia()), - GetExpectedTokenError(kind, t1.Kind)); - } - internal static bool NoTriviaBetween(SyntaxToken token1, SyntaxToken token2) => token1.GetTrailingTriviaWidth() == 0 && token2.GetLeadingTriviaWidth() == 0; From 48af074d12cd9675a5f57e323bc684835de3d90c Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 7 Oct 2024 11:41:35 -0700 Subject: [PATCH 6/6] Lint --- .../CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs index 87783228a995d..dc1a29a8411f1 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs @@ -7911,7 +7911,6 @@ public void TestNullCheckedArgWithSpaceAfterParam() // void M(string name !!=null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 20)); - N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -8060,7 +8059,6 @@ public void TestMethodDeclarationNullValidation_ExtraEquals() // void M(string name!!= = null) { } Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); - N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType);