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/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs index 3570d2efd6b18..431021aac3b5d 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/Portable/Parser/LanguageParser.cs b/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs index 1b2c4707840fb..f3db0e485c25d 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,80 +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 - /// 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; @@ -12150,13 +12073,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 +12117,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 +12172,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 +12430,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 +13246,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 +13342,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 +13383,6 @@ private bool ShouldParseLambdaParameterType() // (a) // (a => // (a { - // (a !! or (a !!= // (a = // // In all other cases, parse out a type. @@ -13521,7 +13391,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; 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}'。 diff --git a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs index 6673c199fa691..fa72f15c6145d 100644 --- a/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/IncrementalParsing/IncrementalParsingTests.cs @@ -70,13 +70,13 @@ 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. + // (4,30): error CS1003: Syntax error, ',' expected // public void M(string? x !!) { - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(4, 30)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(4, 30)); newTree.GetDiagnostics().Verify( - // (4,29): error CS8989: The 'parameter null-checking' feature is not supported. + // (4,29): error CS1003: Syntax error, ',' expected // public void M(string x !!) { - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(4, 29)); + 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 f727bfd113093..dc1a29a8411f1 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,10 @@ 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); @@ -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,15 +7390,17 @@ public void TestOptParamMethodDeclarationWithNullValidation() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [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. + // (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); @@ -7423,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); } @@ -7440,6 +7427,7 @@ public void TestOptParamMethodDeclarationWithNullValidationNoSpaces() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] @@ -7586,9 +7574,10 @@ 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); @@ -7623,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,9 +7722,10 @@ 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); @@ -7761,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); } @@ -7778,15 +7752,17 @@ public void TestNullCheckedArgWithLeadingSpace() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] 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); @@ -7804,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); } @@ -7821,15 +7789,17 @@ public void TestNullCheckedArgWithLeadingNewLine() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] 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); @@ -7847,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); } @@ -7864,15 +7826,17 @@ public void TestNullCheckedArgWithTrailingSpace() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] 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); @@ -7890,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); } @@ -7907,15 +7863,17 @@ public void TestNullCheckedArgWithTrailingNewLine() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [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. + // (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); @@ -7933,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); } @@ -7957,9 +7907,10 @@ 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); @@ -7977,14 +7928,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); } @@ -7994,15 +7937,17 @@ public void TestNullCheckedArgWithSpaceAfterParam() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] 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); @@ -8020,14 +7965,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); } @@ -8044,9 +7981,10 @@ 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); @@ -8064,14 +8002,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); } @@ -8088,9 +8018,10 @@ 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); @@ -8108,14 +8039,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); } @@ -8125,18 +8048,16 @@ public void TestNullCheckedArgWithSpaceAfterEquals() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact] 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. + // (1,19): error CS1003: Syntax error, ',' expected // void M(string name!!= = null) { } - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 19), - // (1,23): error CS1525: Invalid expression term '=' - // void M(string name!!= = null) { } - Diagnostic(ErrorCode.ERR_InvalidExprTerm, "=").WithArguments("=").WithLocation(1, 23)); + Diagnostic(ErrorCode.ERR_SyntaxError, "!").WithArguments(",").WithLocation(1, 19)); N(SyntaxKind.LocalFunctionStatement); { @@ -8155,22 +8076,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); } @@ -8191,9 +8096,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 +8147,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 +8197,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 +8267,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..6a715e65d95ac 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs @@ -775,470 +775,485 @@ 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. + UsingDeclaration("""Func func1 = x!! => x + "1";""", options: TestOptions.RegularPreview, + // (1,34): error CS1003: Syntax error, ',' expected // Func func1 = x!! => x + "1"; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + 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, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,39): error CS1003: Syntax error, ',' expected // Func func1 = (x!!, y) => x == y; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32)); + 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, - // (1,26): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,30): error CS1003: Syntax error, ',' expected // Func func1 = (x!!) => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 26)); + 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, - // (1,25): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,28): error CS1525: Invalid expression term '>' // Func func1 = x!!=>x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 25)); + 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, - // (1,30): error CS8989: The 'parameter null-checking' feature is not supported. + // (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_ParameterNullCheckingNotSupported, "!").WithLocation(1, 30)); + 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, - // (1,35): error CS8989: The 'parameter null-checking' feature is not supported. + // (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_ParameterNullCheckingNotSupported, "!").WithLocation(1, 35)); + 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.CommaToken); + M(SyntaxKind.VariableDeclarator); + { + M(SyntaxKind.IdentifierToken); + } } N(SyntaxKind.SemicolonToken); } + EOF(); } - - [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)); - 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.VariableDeclarator); - { - N(SyntaxKind.IdentifierToken, "func1"); - } - N(SyntaxKind.EqualsValueClause); + + [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); @@ -1262,90 +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, - // (1,26): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,30): error CS1003: Syntax error, ',' expected // Func func1 = (_!!) => 42; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 26)); + 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, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,33): error CS1525: Invalid expression term '>' // Func func0 = x!=> x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 33)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1374,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"); + } } } } @@ -1398,9 +1431,10 @@ public void TestNullCheckedSyntaxCorrection0() public void TestNullCheckedSyntaxCorrection1() { UsingDeclaration("Func func1 = x !=> x;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,34): error CS1525: Invalid expression term '>' // Func func1 = x !=> x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32)); + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 34)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1429,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"); + } } } } @@ -1453,12 +1495,10 @@ public void TestNullCheckedSyntaxCorrection1() 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 + // (1,35): error CS1525: Invalid expression term '>' // Func func2 = x != > x; - Diagnostic(ErrorCode.ERR_SyntaxError, "=").WithArguments("=>").WithLocation(1, 33)); + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 35)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1487,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"); + } } } } @@ -1611,9 +1659,10 @@ public void TestNullCheckedSyntaxCorrection4() public void TestNullCheckedSyntaxCorrection5() { UsingDeclaration("Func func5 = x !!=> x;", options: TestOptions.RegularPreview, - // (1,32): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,35): error CS1525: Invalid expression term '>' // Func func5 = x !!=> x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 32)); + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 35)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1642,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"); + } } } } @@ -1659,18 +1720,17 @@ public void TestNullCheckedSyntaxCorrection5() } N(SyntaxKind.SemicolonToken); } + EOF(); } [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 + // (1,36): error CS1525: Invalid expression term '>' // Func func6 = x !!= > x; - Diagnostic(ErrorCode.ERR_SyntaxError, "=").WithArguments("=>").WithLocation(1, 34)); + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 36)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1699,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"); + } } } } @@ -1723,9 +1795,10 @@ public void TestNullCheckedSyntaxCorrection6() public void TestNullCheckedSyntaxCorrection7() { UsingDeclaration("Func func7 = x!! => x;", options: TestOptions.RegularPreview, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,34): error CS1003: Syntax error, ',' expected // Func func7 = x!! => x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + Diagnostic(ErrorCode.ERR_SyntaxError, "=>").WithArguments(",").WithLocation(1, 34)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1754,32 +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, - // (1,31): error CS8989: The 'parameter null-checking' feature is not supported. + // (1,35): error CS1525: Invalid expression term '>' // Func func8 = x! !=> x; - Diagnostic(ErrorCode.ERR_ParameterNullCheckingNotSupported, "!").WithLocation(1, 31)); + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(1, 35)); + N(SyntaxKind.FieldDeclaration); { N(SyntaxKind.VariableDeclaration); @@ -1808,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"); + } } } } @@ -1832,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); @@ -1863,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); } } } @@ -4304,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); { @@ -4336,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); } } } @@ -4373,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); { @@ -4405,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); } } } @@ -4447,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); { @@ -4479,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); } } } @@ -4520,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); { @@ -4552,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); } } } @@ -4680,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); @@ -4711,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); } } } @@ -4735,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); @@ -4766,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); } } } @@ -4795,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); @@ -4826,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); } } } @@ -4860,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); @@ -4891,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); } } } @@ -4924,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); @@ -4955,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); } } }