diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000000..efdda18ee9aca --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Dotnet-format -w Roslyn.sln +abce41d282ac631be5217140f1bd46d0e250ad02 diff --git a/docs/Language Feature Status.md b/docs/Language Feature Status.md index 9ceeaa6f364df..777022a51399b 100644 --- a/docs/Language Feature Status.md +++ b/docs/Language Feature Status.md @@ -10,27 +10,32 @@ efforts behind them. | Feature | Branch | State | Developer | Reviewer | LDM Champ | | ------- | ------ | ----- | --------- | -------- | --------- | -| [Record structs](https://github.com/dotnet/csharplang/issues/4334) | [record-structs](https://github.com/dotnet/roslyn/tree/features/record-structs) | [Merged into 16.11](https://github.com/dotnet/roslyn/issues/51199) | [jcouv](https://github.com/jcouv) | [AlekseyTs](https://github.com/AlekseyTs), [RikkiGibson](https://github.com/RikkiGibson) | [jcouv](https://github.com/jcouv) | -| [Global Using Directive](https://github.com/dotnet/csharplang/issues/3428) | [GlobalUsingDirective](https://github.com/dotnet/roslyn/tree/features/GlobalUsingDirective) | [Merged into 16.11](https://github.com/dotnet/roslyn/issues/51307) | [AlekseyTs](https://github.com/AlekseyTs) | [333fred](https://github.com/333fred), [cston](https://github.com/cston) | [AlekseyTs](https://github.com/AlekseyTs) | | [Static Abstract Members In Interfaces](https://github.com/dotnet/csharplang/issues/4436) | [StaticAbstractMembersInInterfaces](https://github.com/dotnet/roslyn/tree/features/StaticAbstractMembersInInterfaces) | [In Progress](https://github.com/dotnet/roslyn/issues/52221) | [AlekseyTs](https://github.com/AlekseyTs) | [333fred](https://github.com/333fred), [RikkiGibson](https://github.com/RikkiGibson) | [MadsTorgersen](https://github.com/MadsTorgersen) | | [File-scoped namespace](https://github.com/dotnet/csharplang/issues/137) | [FileScopedNamespaces](https://github.com/dotnet/roslyn/tree/features/FileScopedNamespaces) | [In Progress](https://github.com/dotnet/roslyn/issues/49000) | [RikkiGibson](https://github.com/RikkiGibson) | [jcouv](https://github.com/jcouv), [chsienki](https://github.com/chsienki) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | | [Interpolated string improvements](https://github.com/dotnet/csharplang/issues/4487) | [interpolated-string](https://github.com/dotnet/roslyn/tree/features/interpolated-string) | [In Progress](https://github.com/dotnet/roslyn/issues/51499) | [333fred](https://github.com/333fred) | [AlekseyTs](https://github.com/AlekseyTs), [chsienki](https://github.com/chsienki) | [jaredpar](https://github.com/jaredpar) | | [Parameterless struct constructors](https://github.com/dotnet/csharplang/issues/99) | [struct-ctors](https://github.com/dotnet/roslyn/tree/features/struct-ctors) | [In Progress](https://github.com/dotnet/roslyn/issues/51698) | [cston](https://github.com/cston) | [jcouv](https://github.com/jcouv), [333fred](https://github.com/333fred) | [jcouv](https://github.com/jouv) | | [Lambda improvements](https://github.com/dotnet/csharplang/blob/main/proposals/lambda-improvements.md) | [lambdas](https://github.com/dotnet/roslyn/tree/features/lambdas) | [In Progress](https://github.com/dotnet/roslyn/issues/52192) | [cston](https://github.com/cston) | [333fred](https://github.com/333fred), [jcouv](https://github.com/jcouv) | [jaredpar](https://github.com/jaredpar) | | [nameof(parameter)](https://github.com/dotnet/csharplang/issues/373) | main | [In Progress](https://github.com/dotnet/roslyn/issues/40524) | [jcouv](https://github.com/jcouv) | TBD | [jcouv](https://github.com/jcouv) | -| [Improved Definite Assignment](https://github.com/dotnet/csharplang/issues/4465) | [improved-definite-assignment](https://github.com/dotnet/roslyn/tree/features/improved-definite-assignment) | [Merged into 17.0](https://github.com/dotnet/roslyn/issues/51463) | [RikkiGibson](https://github.com/RikkiGibson) | [jcouv](https://github.com/jcouv) | [jaredpar](https://github.com/jaredpar) | | [Relax ordering of `ref` and `partial` modifiers](https://github.com/dotnet/csharplang/issues/946) | [ref-partial](https://github.com/dotnet/roslyn/tree/features/ref-partial) | In Progress | [alrz](https://github.com/alrz) | [gafter](https://github.com/gafter) | [jcouv](https://github.com/jcouv) | | [Parameter null-checking](https://github.com/dotnet/csharplang/issues/2145) | [param-nullchecking](https://github.com/dotnet/roslyn/tree/features/param-nullchecking) | [In Progress](https://github.com/dotnet/roslyn/issues/36024) | [fayrose](https://github.com/fayrose) | [agocke](https://github.com/agocke) | [jaredpar](https://github.com/jaredpar) | | [Caller expression attribute](https://github.com/dotnet/csharplang/issues/287) | [caller-argument-expression](https://github.com/dotnet/roslyn/tree/features/caller-argument-expression) | [In Progress](https://github.com/dotnet/roslyn/issues/52745) | [Youssef1313](https://github.com/Youssef1313) | [333fred](https://github.com/333fred),[AlekseyTs](https://github.com/AlekseyTs) | [jcouv](https://github.com/jcouv) | | [Generic attributes](https://github.com/dotnet/csharplang/issues/124) | [generic-attributes](https://github.com/dotnet/roslyn/tree/features/generic-attributes) | [In Progress](https://github.com/dotnet/roslyn/issues/36285) | [AviAvni](https://github.com/AviAvni) | [agocke](https://github.com/agocke) | [mattwar](https://github.com/mattwar) | | [Default in deconstruction](https://github.com/dotnet/roslyn/pull/25562) | [decon-default](https://github.com/dotnet/roslyn/tree/features/decon-default) | [Implemented](https://github.com/dotnet/roslyn/issues/25559) | [jcouv](https://github.com/jcouv) | [gafter](https://github.com/gafter) | [jcouv](https://github.com/jcouv) | -| [Constant Interpolated Strings](https://github.com/dotnet/csharplang/issues/2951) | main | [Merged into 16.9p3](https://github.com/dotnet/roslyn/pull/49676) | [kevinsun-dev](https://github.com/kevinsun-dev) | [333fred](https://github.com/333fred) | [jaredar](https://github.com/jaredpar), [agocke](https://github.com/agocke) | -| [Mix declarations and variables in deconstruction](https://github.com/dotnet/csharplang/issues/125) | main | [Merged into 16.10](https://github.com/dotnet/roslyn/issues/47746) | [YairHalberstadt ](https://github.com/YairHalberstadt) | [jcouv](https://github.com/jcouv) | [MadsTorgersen](https://github.com/MadsTorgersen) | | [List patterns](https://github.com/dotnet/csharplang/issues/3435) | [list-patterns](https://github.com/dotnet/roslyn/tree/features/list-patterns) | [In Progress](https://github.com/dotnet/roslyn/issues/51289) | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv), [333fred](https://github.com/333fred) | [333fred](https://github.com/333fred) | + +# C# 10.0 + +| Feature | Branch | State | Developer | Reviewer | LDM Champ | +| ------- | ------ | ----- | --------- | -------- | --------- | +| [Record structs](https://github.com/dotnet/csharplang/issues/4334) | [record-structs](https://github.com/dotnet/roslyn/tree/features/record-structs) | [Merged into 16.11](https://github.com/dotnet/roslyn/issues/51199) | [jcouv](https://github.com/jcouv) | [AlekseyTs](https://github.com/AlekseyTs), [RikkiGibson](https://github.com/RikkiGibson) | [jcouv](https://github.com/jcouv) | +| [Global Using Directive](https://github.com/dotnet/csharplang/issues/3428) | [GlobalUsingDirective](https://github.com/dotnet/roslyn/tree/features/GlobalUsingDirective) | [Merged into 16.11](https://github.com/dotnet/roslyn/issues/51307) | [AlekseyTs](https://github.com/AlekseyTs) | [333fred](https://github.com/333fred), [cston](https://github.com/cston) | [AlekseyTs](https://github.com/AlekseyTs) | +| [Improved Definite Assignment](https://github.com/dotnet/csharplang/issues/4465) | [improved-definite-assignment](https://github.com/dotnet/roslyn/tree/features/improved-definite-assignment) | [Merged into 17.0](https://github.com/dotnet/roslyn/issues/51463) | [RikkiGibson](https://github.com/RikkiGibson) | [jcouv](https://github.com/jcouv) | [jaredpar](https://github.com/jaredpar) | +| [Constant Interpolated Strings](https://github.com/dotnet/csharplang/issues/2951) | main | [Merged into 16.9p3](https://github.com/dotnet/roslyn/pull/49676) | [kevinsun-dev](https://github.com/kevinsun-dev) | [333fred](https://github.com/333fred) | [jaredar](https://github.com/jaredpar), [agocke](https://github.com/agocke) | | [Extended property patterns](https://github.com/dotnet/csharplang/issues/4394) | [extended-property-patterns](https://github.com/dotnet/roslyn/tree/features/extended-property-patterns) | [Merged into 17.0](https://github.com/dotnet/roslyn/issues/52468) | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv), [333fred](https://github.com/333fred) | [333fred](https://github.com/333fred) | | [Sealed record ToString](https://github.com/dotnet/csharplang/issues/4174) | main | [Merged](https://github.com/dotnet/roslyn/issues/52031) | [thomaslevesque](https://github.com/thomaslevesque/) | [jcouv](https://github.com/jcouv) | [333fred](https://github.com/333fred) | -| [Source Generator V2 APIs](https://github.com/dotnet/roslyn/issues/51257) | [features/source-generators](https://github.com/dotnet/roslyn/tree/features/source-generators) | [In Progress](https://github.com/dotnet/roslyn/issues/51257) | [chsienki](https://github.com/chsienki/) | [rikkigibson](https://github.com/rikkigibson), [jaredpar](https://github.com/jaredpar), [cston](https://github.com/cston) | N/A | -| [Async method builder override](https://github.com/dotnet/csharplang/issues/1407) | main | [In Progress](https://github.com/dotnet/roslyn/issues/51999) | [jcouv](https://github.com/jcouv) | TBD | [stephentoub](https://github.com/stephentoub) | +| [Source Generator V2 APIs](https://github.com/dotnet/roslyn/issues/51257) | [features/source-generators](https://github.com/dotnet/roslyn/tree/features/source-generators) | [Merged into 17.0p2](https://github.com/dotnet/roslyn/issues/51257) | [chsienki](https://github.com/chsienki/) | [rikkigibson](https://github.com/rikkigibson), [jaredpar](https://github.com/jaredpar), [cston](https://github.com/cston) | N/A | +| [Mix declarations and variables in deconstruction](https://github.com/dotnet/csharplang/issues/125) | main | [Merged into 16.10](https://github.com/dotnet/roslyn/issues/47746) | [YairHalberstadt ](https://github.com/YairHalberstadt) | [jcouv](https://github.com/jcouv) | [MadsTorgersen](https://github.com/MadsTorgersen) | +| [Async method builder override](https://github.com/dotnet/csharplang/issues/1407) | main | [Merged into 17.0p2](https://github.com/dotnet/roslyn/issues/51999) | [jcouv](https://github.com/jcouv) | [cston](https://github.com/cston), [RikkiGibson](https://github.com/RikkiGibson) | [stephentoub](https://github.com/stephentoub) | # VB 16.9 diff --git a/dotnet-tools.json b/dotnet-tools.json index 10d642464725d..6ab0998319770 100644 --- a/dotnet-tools.json +++ b/dotnet-tools.json @@ -2,7 +2,7 @@ "isRoot": true, "tools": { "dotnet-format": { - "version": "5.0.141503", + "version": "6.0.231801", "commands": [ "dotnet-format" ] diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 1cb19c5392dbc..b42d8c8d6b619 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -6,9 +6,9 @@ 7e80445ee82adbf9a8e6ae601ac5e239d982afaa - + https://github.com/dotnet/source-build - 3fb25b8db3bec654e37e71a5b2b7fde14444bc2f + c35d744cbe24f85d2165a5edb1730355b8cb916f diff --git a/src/Compilers/CSharp/Portable/Binder/MethodArgumentInfo.cs b/src/Compilers/CSharp/Portable/Binder/MethodArgumentInfo.cs index 5e742d84d72a7..b8a2f76c02e53 100644 --- a/src/Compilers/CSharp/Portable/Binder/MethodArgumentInfo.cs +++ b/src/Compilers/CSharp/Portable/Binder/MethodArgumentInfo.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 101de6a04cc5a..777b59a102b24 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -6418,6 +6418,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ Feature '{0}' is not available in C# 9.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Unexpected argument list. @@ -6719,4 +6722,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ The AsyncMethodBuilder attribute is disallowed on anonymous methods without an explicit return type. + + At least one top-level statement must be non-empty. + diff --git a/src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs b/src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs index 85c6f95ffd137..a106610962e31 100644 --- a/src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs +++ b/src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs @@ -899,7 +899,7 @@ public override AwaitExpressionInfo GetAwaitExpressionInfo(AwaitExpressionSyntax throw new ArgumentException("node.Kind==" + node.Kind()); } - var bound = GetUpperBoundNode(node); + var bound = GetLowerBoundNode(node); BoundAwaitableInfo awaitableInfo = (((bound as BoundExpressionStatement)?.Expression ?? bound) as BoundAwaitExpression)?.AwaitableInfo; if (awaitableInfo == null) { diff --git a/src/Compilers/CSharp/Portable/Declarations/DeclarationTreeBuilder.cs b/src/Compilers/CSharp/Portable/Declarations/DeclarationTreeBuilder.cs index 92b021f45a175..4164baf567b67 100644 --- a/src/Compilers/CSharp/Portable/Declarations/DeclarationTreeBuilder.cs +++ b/src/Compilers/CSharp/Portable/Declarations/DeclarationTreeBuilder.cs @@ -59,6 +59,7 @@ private ImmutableArray VisitNamespaceChildren( bool isIterator = false; bool hasReturnWithExpression = false; GlobalStatementSyntax firstGlobalStatement = null; + bool hasNonEmptyGlobalSatement = false; var childrenBuilder = ArrayBuilder.GetInstance(); foreach (var member in members) @@ -74,6 +75,11 @@ private ImmutableArray VisitNamespaceChildren( firstGlobalStatement ??= global; var topLevelStatement = global.Statement; + if (!topLevelStatement.IsKind(SyntaxKind.EmptyStatement)) + { + hasNonEmptyGlobalSatement = true; + } + if (!hasAwaitExpressions) { hasAwaitExpressions = SyntaxFacts.HasAwaitOperations(topLevelStatement); @@ -98,7 +104,16 @@ private ImmutableArray VisitNamespaceChildren( // wrap all global statements in a compilation unit into a simple program type: if (firstGlobalStatement is object) { - childrenBuilder.Add(CreateSimpleProgram(firstGlobalStatement, hasAwaitExpressions, isIterator, hasReturnWithExpression)); + var diagnostics = ImmutableArray.Empty; + + if (!hasNonEmptyGlobalSatement) + { + var bag = DiagnosticBag.GetInstance(); + bag.Add(ErrorCode.ERR_SimpleProgramIsEmpty, ((EmptyStatementSyntax)firstGlobalStatement.Statement).SemicolonToken.GetLocation()); + diagnostics = bag.ToReadOnlyAndFree(); + } + + childrenBuilder.Add(CreateSimpleProgram(firstGlobalStatement, hasAwaitExpressions, isIterator, hasReturnWithExpression, diagnostics)); } // wrap all members that are defined in a namespace or compilation unit into an implicit type: @@ -130,7 +145,7 @@ private static SingleNamespaceOrTypeDeclaration CreateImplicitClass(ImmutableSeg diagnostics: ImmutableArray.Empty); } - private static SingleNamespaceOrTypeDeclaration CreateSimpleProgram(GlobalStatementSyntax firstGlobalStatement, bool hasAwaitExpressions, bool isIterator, bool hasReturnWithExpression) + private static SingleNamespaceOrTypeDeclaration CreateSimpleProgram(GlobalStatementSyntax firstGlobalStatement, bool hasAwaitExpressions, bool isIterator, bool hasReturnWithExpression, ImmutableArray diagnostics) { return new SingleTypeDeclaration( kind: DeclarationKind.SimpleProgram, @@ -144,7 +159,7 @@ private static SingleNamespaceOrTypeDeclaration CreateSimpleProgram(GlobalStatem nameLocation: new SourceLocation(firstGlobalStatement.GetFirstToken()), memberNames: ImmutableSegmentedDictionary.Empty, children: ImmutableArray.Empty, - diagnostics: ImmutableArray.Empty); + diagnostics: diagnostics); } /// diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs index 14dccabc41a11..16f5d833134d0 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs @@ -1958,6 +1958,8 @@ internal enum ErrorCode HDN_DuplicateWithGlobalUsing = 8933, ERR_CantConvAnonMethReturnType = 8934, ERR_BuilderAttributeDisallowed = 8935, + ERR_FeatureNotAvailableInVersion10 = 8936, + ERR_SimpleProgramIsEmpty = 8937, #endregion diff --git a/src/Compilers/CSharp/Portable/Errors/MessageID.cs b/src/Compilers/CSharp/Portable/Errors/MessageID.cs index f546e04f67af6..6523f5d3323aa 100644 --- a/src/Compilers/CSharp/Portable/Errors/MessageID.cs +++ b/src/Compilers/CSharp/Portable/Errors/MessageID.cs @@ -335,6 +335,10 @@ internal static LanguageVersion RequiredVersion(this MessageID feature) switch (feature) { // C# preview features. + case MessageID.IDS_FeatureStaticAbstractMembersInInterfaces: // semantic check + return LanguageVersion.Preview; + + // C# 10.0 features. case MessageID.IDS_FeatureMixedDeclarationsAndExpressionsInDeconstruction: // semantic check case MessageID.IDS_FeatureSealedToStringInRecord: // semantic check case MessageID.IDS_FeatureRecordStructs: @@ -345,10 +349,10 @@ internal static LanguageVersion RequiredVersion(this MessageID feature) case MessageID.IDS_FeatureInferredDelegateType: // semantic check case MessageID.IDS_FeatureLambdaAttributes: // semantic check case MessageID.IDS_FeatureExtendedPropertyPatterns: - case MessageID.IDS_FeatureStaticAbstractMembersInInterfaces: // semantic check case MessageID.IDS_FeatureLambdaReturnType: // semantic check case MessageID.IDS_AsyncMethodBuilderOverride: // semantic check - return LanguageVersion.Preview; + case MessageID.IDS_FeatureConstantInterpolatedStrings: // semantic check + return LanguageVersion.CSharp10; // C# 9.0 features. case MessageID.IDS_FeatureLambdaDiscardParameters: // semantic check @@ -375,12 +379,9 @@ internal static LanguageVersion RequiredVersion(this MessageID feature) case MessageID.IDS_FeatureStaticAnonymousFunction: // syntax check case MessageID.IDS_FeatureModuleInitializers: // semantic check on method attribute case MessageID.IDS_FeatureDefaultTypeParameterConstraint: + case MessageID.IDS_FeatureVarianceSafetyForStaticInterfaceMembers: // semantic check return LanguageVersion.CSharp9; - case MessageID.IDS_FeatureVarianceSafetyForStaticInterfaceMembers: //semantic check - case MessageID.IDS_FeatureConstantInterpolatedStrings: //semantic check - return LanguageVersion.Preview; - // C# 8.0 features. case MessageID.IDS_FeatureAltInterpolatedVerbatimStrings: case MessageID.IDS_FeatureCoalesceAssignmentExpression: diff --git a/src/Compilers/CSharp/Portable/LanguageVersion.cs b/src/Compilers/CSharp/Portable/LanguageVersion.cs index 4b7aff7955dad..cc0d508de5d28 100644 --- a/src/Compilers/CSharp/Portable/LanguageVersion.cs +++ b/src/Compilers/CSharp/Portable/LanguageVersion.cs @@ -187,6 +187,26 @@ public enum LanguageVersion /// CSharp9 = 900, + /// + /// C# language version 10.0 + /// + /// + /// Features: + /// + /// Record structs + /// Global using directives + /// Lambda improvements + /// Improved definite assignment + /// Constant interpolated strings + /// Mix declarations and variables in deconstruction + /// Extended property patterns + /// Sealed record ToString + /// Source Generator v2 APIs + /// Method-level AsyncMethodBuilder + /// + /// + CSharp10 = 1000, + /// /// The latest major supported version. /// @@ -226,6 +246,7 @@ internal static bool IsValid(this LanguageVersion value) case LanguageVersion.CSharp7_3: case LanguageVersion.CSharp8: case LanguageVersion.CSharp9: + case LanguageVersion.CSharp10: case LanguageVersion.Preview: return true; } @@ -261,6 +282,8 @@ internal static ErrorCode GetErrorCode(this LanguageVersion version) return ErrorCode.ERR_FeatureNotAvailableInVersion8; case LanguageVersion.CSharp9: return ErrorCode.ERR_FeatureNotAvailableInVersion9; + case LanguageVersion.CSharp10: + return ErrorCode.ERR_FeatureNotAvailableInVersion10; default: throw ExceptionUtilities.UnexpectedValue(version); } @@ -281,6 +304,12 @@ internal CSharpRequiredLanguageVersion(LanguageVersion version) public static class LanguageVersionFacts { + /// + /// Usages of TestOptions.RegularNext and LanguageVersionFacts.CSharpNext + /// will be replaced with TestOptions.RegularN and LanguageVersion.CSharpN when language version N is introduced. + /// + internal const LanguageVersion CSharpNext = LanguageVersion.Preview; + /// /// Displays the version number in the format expected on the command-line (/langver flag). /// For instance, "6", "7.0", "7.1", "latest". @@ -313,6 +342,8 @@ public static string ToDisplayString(this LanguageVersion version) return "8.0"; case LanguageVersion.CSharp9: return "9.0"; + case LanguageVersion.CSharp10: + return "10.0"; case LanguageVersion.Default: return "default"; case LanguageVersion.Latest: @@ -414,6 +445,11 @@ public static bool TryParse(string? version, out LanguageVersion result) result = LanguageVersion.CSharp9; return true; + case "10": + case "10.0": + result = LanguageVersion.CSharp10; + return true; + default: result = LanguageVersion.Default; return false; @@ -430,13 +466,13 @@ public static LanguageVersion MapSpecifiedToEffectiveVersion(this LanguageVersio case LanguageVersion.Latest: case LanguageVersion.Default: case LanguageVersion.LatestMajor: - return LanguageVersion.CSharp9; + return LanguageVersion.CSharp10; default: return version; } } - internal static LanguageVersion CurrentVersion => LanguageVersion.CSharp9; + internal static LanguageVersion CurrentVersion => LanguageVersion.CSharp10; /// Inference of tuple element names was added in C# 7.1 internal static bool DisallowInferredTupleElementNames(this LanguageVersion self) diff --git a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt index 12b95121ca21f..2f2973cf92b42 100644 --- a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt @@ -1,5 +1,6 @@ abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseExpressionColonSyntax.ColonToken.get -> Microsoft.CodeAnalysis.SyntaxToken abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseExpressionColonSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax +Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp10 = 1000 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion Microsoft.CodeAnalysis.CSharp.Syntax.BaseExpressionColonSyntax Microsoft.CodeAnalysis.CSharp.Syntax.BaseExpressionColonSyntax.WithColonToken(Microsoft.CodeAnalysis.SyntaxToken colonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseExpressionColonSyntax Microsoft.CodeAnalysis.CSharp.Syntax.BaseExpressionColonSyntax.WithExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseExpressionColonSyntax diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs index fc8221d9ad1f4..56979139e7487 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs @@ -5,6 +5,7 @@ #nullable disable using System.Collections.Immutable; +using System.Diagnostics; using Microsoft.CodeAnalysis.CSharp.Emit; using Microsoft.CodeAnalysis.PooledObjects; @@ -18,6 +19,10 @@ internal sealed class SynthesizedSubstitutedTypeParameterSymbol : SubstitutedTyp public SynthesizedSubstitutedTypeParameterSymbol(Symbol owner, TypeMap map, TypeParameterSymbol substitutedFrom, int ordinal) : base(owner, map, substitutedFrom, ordinal) { + Debug.Assert(this.TypeParameterKind == (ContainingSymbol is MethodSymbol ? TypeParameterKind.Method : + (ContainingSymbol is NamedTypeSymbol ? TypeParameterKind.Type : + TypeParameterKind.Cref)), + $"Container is {ContainingSymbol?.Kind}, TypeParameterKind is {this.TypeParameterKind}"); } public override bool IsImplicitlyDeclared @@ -25,6 +30,8 @@ public override bool IsImplicitlyDeclared get { return true; } } + public override TypeParameterKind TypeParameterKind => ContainingSymbol is MethodSymbol ? TypeParameterKind.Method : TypeParameterKind.Type; + internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder attributes) { base.AddSynthesizedAttributes(moduleBuilder, ref attributes); diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index 59d825d7da375..b464baee27688 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -467,6 +467,11 @@ Funkce {0} je zkušební, a proto není podporovaná. K aktivaci použijte /features:{1}. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. Funkce {0} není v C# 8.0 dostupná. Použijte prosím jazykovou verzi {1} nebo větší. @@ -957,6 +962,11 @@ Pokud existuje jednotka kompilace s příkazy nejvyšší úrovně, nedá se zadat /main. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. Místní proměnná nebo místní funkce {0} deklarovaná v příkazu nejvyšší úrovně v tomto kontextu se nedá použít. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index e9f447119329a..6f7c0a1c45e0f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -467,6 +467,11 @@ Das Feature "{0}" ist experimentell und wird nicht unterstützt. Verwenden Sie zur Aktivierung "/features:{1}". + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. Das Feature "{0}" ist in C# 8.0 nicht verfügbar. Verwenden Sie Sprachversion {1} oder höher. @@ -957,6 +962,11 @@ "/main" kann nicht angegeben werden, wenn eine Kompilierungseinheit mit Anweisungen der obersten Ebene vorhanden ist. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. Die lokale Variable oder die lokale Funktion "{0}", die in einer Anweisung der obersten Ebene in diesem Kontext deklariert wurde, kann nicht verwendet werden. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index bb633c2ce8821..44cc8b70093a8 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -467,6 +467,11 @@ La característica "{0}" es experimental y no se admite. Use "/features:{1}" para habilitarla. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. La característica "{0}" no está disponible en C# 8.0. Use la versión {1} del lenguaje o una posterior. @@ -957,6 +962,11 @@ No se puede especificar /main si hay una unidad de compilación con instrucciones de nivel superior. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. No se puede usar la variable local ni la función local "{0}" declarada en una instrucción de nivel superior en este contexto. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 3b853ad18cdda..c9cbc48f58e5b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -467,6 +467,11 @@ La fonctionnalité '{0}' est expérimentale et non prise en charge. Utilisez '/features:{1}' pour l'activer. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. La fonctionnalité '{0}' n'est pas disponible en C# 8.0. Utilisez la version de langage {1} ou une version ultérieure. @@ -957,6 +962,11 @@ Impossible de spécifier /main s'il existe une unité de compilation avec des instructions de niveau supérieur. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. Impossible d'utiliser une variable locale ou une fonction locale '{0}' déclarée dans une instruction de niveau supérieur dans ce contexte. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index 02d1eb287ffad..78c7df1ee1a3d 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -467,6 +467,11 @@ La funzionalità '{0}' è sperimentale e non è supportata. Per abilitare, usare '/features:{1}'. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. La funzionalità '{0}' non è disponibile in C# 8.0. Usare la versione {1} o versioni successive del linguaggio. @@ -957,6 +962,11 @@ Non è possibile specificare /main se è presente un'unità di compilazione con istruzioni di primo livello. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. In questo contesto non è possibile usare la variabile locale o la funzione locale '{0}' dichiarata in un'istruzione di primo livello. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index a74e38ed2cc86..14bbcae70195e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -467,6 +467,11 @@ 機能 '{0}' は試験段階であり、サポートされていません。有効にするには '/features:{1}' をご使用ください。 + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. 機能 '{0}' は C# 8.0 では使用できません。言語バージョン {1} 以上を使用してください。 @@ -957,6 +962,11 @@ トップレベルのステートメントを含むコンパイル ユニットがある場合、/main を指定することはできません。 + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. このコンテキストでは、トップレベルのステートメントで宣言されたローカル変数またはローカル関数 '{0}' を使用することはできません。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index 70922f4ba8a6f..7b54417afb4dc 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -467,6 +467,11 @@ 기능 '{0}'은(는) 실험적이며 지원되지 않습니다. 사용하도록 설정하려면 '/features:{1}'을(를) 사용하세요. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. '{0}' 기능은 C# 8.0에서 사용할 수 없습니다. 언어 버전 {1} 이상을 사용하세요. @@ -957,6 +962,11 @@ 최상위 문이 포함된 컴파일 단위가 있으면 /main을 지정할 수 없습니다. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. 이 컨텍스트에서는 최상위 문에 선언된 지역 변수 또는 로컬 함수 '{0}'을(를) 사용할 수 없습니다. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index dc03bb3294151..df05dbcd42da7 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -467,6 +467,11 @@ Funkcja „{0}” jest eksperymentalna i nieobsługiwana. Aby ją włączyć, użyj parametru „/features:{1}”. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. Funkcja „{0}” nie jest dostępna w języku C# 8.0. Użyj języka w wersji {1} lub nowszej. @@ -957,6 +962,11 @@ Nie można określić opcji /main, jeśli istnieje jednostka kompilacji z instrukcjami najwyższego poziomu. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. W tym kontekście nie można użyć zmiennej lokalnej ani funkcji lokalnej „{0}” zadeklarowanej w instrukcji najwyższego poziomu. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index 4d2226d58d979..a14ed0dd3608e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -467,6 +467,11 @@ O recurso '{0}' é experimental e sem suporte; use '/features:{1}' para habilitar. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. O recurso '{0}' não está disponível em C# 8.0. Use a versão de linguagem {1} ou superior. @@ -957,6 +962,11 @@ Não é possível especificar /main quando há uma unidade de compilação com instruções de nível superior. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. Não é possível usar a variável local ou a função local '{0}' declarada em uma instrução de nível superior neste contexto. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index 1135d72b83a5e..164006d058d72 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -467,6 +467,11 @@ Функция "{0}" является экспериментальной и не поддерживается; используйте "/features:{1}" для включения. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. Функция "{0}" недоступна в C# 8.0. Используйте версию языка {1} или более позднюю. @@ -957,6 +962,11 @@ Невозможно указать параметр /main, если существует единица компиляции с инструкциями верхнего уровня. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. Невозможно использовать локальную переменную или локальную функцию "{0}", объявленную в инструкции верхнего уровня в этом контексте. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index 4b5b79e20b7dd..4d4c6d42436d2 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -467,6 +467,11 @@ '{0}' özelliği deneyseldir ve desteklenmez; etkinleştirmek için '/features:{1}' kullanın. + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. '{0}' özelliği C# 8.0'da kullanılamaz. Lütfen {1} veya daha yüksek bir dil sürümü kullanın. @@ -957,6 +962,11 @@ Üst düzey deyimleri olan bir derleme birimi varsa /main belirtilemez. + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. Bu bağlamda, üst düzey bir ifadede bildirilen '{0}' yerel değişkeni veya yerel işlevi kullanılamaz. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index bb6ccf4ed5f12..892181b0fce7a 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -467,6 +467,11 @@ 功能“{0}”是实验性的且不受支持;请使用“/features:{1}”来启用。 + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. 功能“{0}”在 C# 8.0 中不可用。请使用语言版本 {1} 或更高版本。 @@ -957,6 +962,11 @@ 如果存在包含顶级语句的编译单元,则不能指定 /main。 + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. 在此上下文中,无法使用在顶级语句中声明的局部变量或本地函数“{0}”。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index d53c890a82f76..c40f055ab4f13 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -467,6 +467,11 @@ 功能 '{0}' 仍在實驗階段且不具支援;請使用 '/features:{1}' 來啟用。 + + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + Feature '{0}' is not available in C# 10.0. Please use language version {1} or greater. + + Feature '{0}' is not available in C# 8.0. Please use language version {1} or greater. C# 8.0 中無法使用功能 '{0}'。請使用 {1} 或更新的語言版本。 @@ -957,6 +962,11 @@ 如果有編譯單位包含最上層陳述式,就無法指定 /main。 + + At least one top-level statement must be non-empty. + At least one top-level statement must be non-empty. + + Cannot use local variable or local function '{0}' declared in a top-level statement in this context. 在此內容中,無法使用最上層陳述式中宣告的區域變數或區域函式 '{0}'。 diff --git a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs index 2c59e7cc97d26..bc35ca5830830 100644 --- a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs +++ b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs @@ -1609,7 +1609,8 @@ public void LangVersion_NoValueSpecified() [InlineData("iso-3")] [InlineData("iso1")] [InlineData("8.1")] - [InlineData("10")] + [InlineData("10.1")] + [InlineData("11")] [InlineData("1000")] public void LangVersion_BadVersion(string value) { @@ -1663,7 +1664,9 @@ public void LanguageVersionAdded_Canary() // When a new version is added, this test will break. This list must be checked: // - update the "UpgradeProject" codefixer // - update all the tests that call this canary - AssertEx.SetEqual(new[] { "default", "1", "2", "3", "4", "5", "6", "7.0", "7.1", "7.2", "7.3", "8.0", "9.0", "latest", "latestmajor", "preview" }, + // - update MaxSupportedLangVersion (a relevant test should break when new version is introduced) + // - email release management to add to the release notes (see old example: https://github.com/dotnet/core/pull/1454) + AssertEx.SetEqual(new[] { "default", "1", "2", "3", "4", "5", "6", "7.0", "7.1", "7.2", "7.3", "8.0", "9.0", "10.0", "latest", "latestmajor", "preview" }, Enum.GetValues(typeof(LanguageVersion)).Cast().Select(v => v.ToDisplayString())); // For minor versions and new major versions, the format should be "x.y", such as "7.1" } @@ -1695,6 +1698,7 @@ public void LanguageVersion_GetErrorCode() ErrorCode.ERR_FeatureNotAvailableInVersion7_3, ErrorCode.ERR_FeatureNotAvailableInVersion8, ErrorCode.ERR_FeatureNotAvailableInVersion9, + ErrorCode.ERR_FeatureNotAvailableInVersion10, }; AssertEx.SetEqual(versions, errorCodes); @@ -1716,9 +1720,10 @@ public void LanguageVersion_GetErrorCode() InlineData(LanguageVersion.CSharp7_3, LanguageVersion.CSharp7_3), InlineData(LanguageVersion.CSharp8, LanguageVersion.CSharp8), InlineData(LanguageVersion.CSharp9, LanguageVersion.CSharp9), - InlineData(LanguageVersion.CSharp9, LanguageVersion.LatestMajor), - InlineData(LanguageVersion.CSharp9, LanguageVersion.Latest), - InlineData(LanguageVersion.CSharp9, LanguageVersion.Default), + InlineData(LanguageVersion.CSharp10, LanguageVersion.CSharp10), + InlineData(LanguageVersion.CSharp10, LanguageVersion.LatestMajor), + InlineData(LanguageVersion.CSharp10, LanguageVersion.Latest), + InlineData(LanguageVersion.CSharp10, LanguageVersion.Default), InlineData(LanguageVersion.Preview, LanguageVersion.Preview), ] public void LanguageVersion_MapSpecifiedToEffectiveVersion(LanguageVersion expectedMappedVersion, LanguageVersion input) @@ -1757,6 +1762,8 @@ public void LanguageVersion_MapSpecifiedToEffectiveVersion(LanguageVersion expec InlineData("8.0", true, LanguageVersion.CSharp8), InlineData("9", true, LanguageVersion.CSharp9), InlineData("9.0", true, LanguageVersion.CSharp9), + InlineData("10", true, LanguageVersion.CSharp10), + InlineData("10.0", true, LanguageVersion.CSharp10), InlineData("08", false, LanguageVersion.Default), InlineData("07.1", false, LanguageVersion.Default), InlineData("default", true, LanguageVersion.Default), diff --git a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Locations.cs b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Locations.cs index 18fc9ecd2f117..5ce3b07416ccc 100644 --- a/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Locations.cs +++ b/src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_Locations.cs @@ -195,7 +195,7 @@ record struct S { } "; - CreateCompilation(source, parseOptions: TestOptions.RegularPreview).VerifyDiagnostics( + CreateCompilation(source, parseOptions: TestOptions.Regular10).VerifyDiagnostics( // (8,2): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored. Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "type"), // (9,2): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored. @@ -243,7 +243,7 @@ record class S { } "; - CreateCompilation(source, parseOptions: TestOptions.RegularPreview).VerifyDiagnostics( + CreateCompilation(source, parseOptions: TestOptions.Regular10).VerifyDiagnostics( // (8,2): warning CS0657: 'assembly' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored. Diagnostic(ErrorCode.WRN_AttributeLocationOnBadDeclaration, "assembly").WithArguments("assembly", "type"), // (9,2): warning CS0657: 'module' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are 'type'. All attributes in this block will be ignored. diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMethodBuilderOverrideTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMethodBuilderOverrideTests.cs index 05c335b270a69..a220a78b9be9a 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMethodBuilderOverrideTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncMethodBuilderOverrideTests.cs @@ -115,18 +115,18 @@ class C "; var compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( - // (11,25): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (11,25): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // static async MyTask F() { System.Console.Write("F "); await Task.Delay(0); } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "F").WithArguments("async method builder override").WithLocation(11, 25), - // (14,28): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "F").WithArguments("async method builder override", "10.0").WithLocation(11, 25), + // (14,28): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // static async MyTask G(T t) { System.Console.Write("G "); await Task.Delay(0); return t; } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "G").WithArguments("async method builder override").WithLocation(14, 28), - // (17,37): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "G").WithArguments("async method builder override", "10.0").WithLocation(14, 28), + // (17,37): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // public static async MyTask M() { System.Console.Write("M "); await F(); return await G(3); } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "M").WithArguments("async method builder override").WithLocation(17, 37) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "M").WithArguments("async method builder override", "10.0").WithLocation(17, 37) ); - compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.RegularPreview); + compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular10); var verifier = CompileAndVerify(compilation, expectedOutput: "M F G 3"); verifier.VerifyDiagnostics(); var testData = verifier.TestData; @@ -223,7 +223,7 @@ public static async MyTask M() {AsyncMethodBuilderAttribute} "; - var compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.RegularPreview); + var compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular10); compilation.VerifyDiagnostics( // (14,16): warning CS8603: Possible null reference return. // return default(T); // 1 @@ -521,18 +521,18 @@ public void BuilderOnMethod_DummyBuilderOnType_OnLocalFunction(string dummyBuild "; var compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( - // (9,21): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (9,21): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // static async MyTask F() { System.Console.Write("F "); await Task.Delay(0); } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "F").WithArguments("async method builder override").WithLocation(9, 21), - // (12,24): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "F").WithArguments("async method builder override", "10.0").WithLocation(9, 21), + // (12,24): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // static async MyTask G(T t) { System.Console.Write("G "); await Task.Delay(0); return t; } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "G").WithArguments("async method builder override").WithLocation(12, 24), - // (15,26): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "G").WithArguments("async method builder override", "10.0").WithLocation(12, 24), + // (15,26): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // static async MyTask M() { System.Console.Write("M "); await F(); return await G(3); } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "M").WithArguments("async method builder override").WithLocation(15, 26) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "M").WithArguments("async method builder override", "10.0").WithLocation(15, 26) ); - compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.RegularPreview); + compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular10); var verifier = CompileAndVerify(compilation, expectedOutput: "M F G 3"); verifier.VerifyDiagnostics(); } @@ -765,26 +765,26 @@ public void BuilderOnMethod_OnLambda() "; var compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular9); compilation.VerifyEmitDiagnostics( - // (6,18): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,18): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // Func f = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder))] static async () => { System.Console.Write("F "); await Task.Delay(0); }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[AsyncMethodBuilder(typeof(MyTaskMethodBuilder))]").WithArguments("lambda attributes").WithLocation(6, 18), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[AsyncMethodBuilder(typeof(MyTaskMethodBuilder))]").WithArguments("lambda attributes", "10.0").WithLocation(6, 18), // (6,84): error CS8935: The AsyncMethodBuilder attribute is disallowed on anonymous methods without an explicit return type. // Func f = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder))] static async () => { System.Console.Write("F "); await Task.Delay(0); }; Diagnostic(ErrorCode.ERR_BuilderAttributeDisallowed, "=>").WithLocation(6, 84), - // (6,84): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,84): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // Func f = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder))] static async () => { System.Console.Write("F "); await Task.Delay(0); }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "=>").WithArguments("async method builder override").WithLocation(6, 84), - // (8,23): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "=>").WithArguments("async method builder override", "10.0").WithLocation(6, 84), + // (8,23): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // Func> m = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))] async () => { System.Console.Write("M "); await f(); return 3; }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))]").WithArguments("lambda attributes").WithLocation(8, 23), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))]").WithArguments("lambda attributes", "10.0").WithLocation(8, 23), // (8,84): error CS8935: The AsyncMethodBuilder attribute is disallowed on anonymous methods without an explicit return type. // Func> m = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))] async () => { System.Console.Write("M "); await f(); return 3; }; Diagnostic(ErrorCode.ERR_BuilderAttributeDisallowed, "=>").WithLocation(8, 84), - // (8,84): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (8,84): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // Func> m = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))] async () => { System.Console.Write("M "); await f(); return 3; }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "=>").WithArguments("async method builder override").WithLocation(8, 84) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "=>").WithArguments("async method builder override", "10.0").WithLocation(8, 84) ); - compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.RegularPreview); + compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular10); compilation.VerifyEmitDiagnostics( // (6,84): error CS8933: The AsyncMethodBuilder attribute is disallowed on anonymous methods without an explicit return type. // Func f = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder))] static async () => { System.Console.Write("F "); await Task.Delay(0); }; @@ -819,27 +819,27 @@ public void BuilderOnMethod_OnLambda_WithExplicitType() "; var compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular9); compilation.VerifyEmitDiagnostics( - // (6,18): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,18): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // Func f = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder))] static async MyTask () => { System.Console.Write("F "); await Task.Delay(0); }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[AsyncMethodBuilder(typeof(MyTaskMethodBuilder))]").WithArguments("lambda attributes").WithLocation(6, 18), - // (6,81): error CS8652: The feature 'lambda return type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[AsyncMethodBuilder(typeof(MyTaskMethodBuilder))]").WithArguments("lambda attributes", "10.0").WithLocation(6, 18), + // (6,81): error CS8773: Feature 'lambda return type' is not available in C# 9.0. Please use language version 10.0 or greater. // Func f = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder))] static async MyTask () => { System.Console.Write("F "); await Task.Delay(0); }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "MyTask").WithArguments("lambda return type").WithLocation(6, 81), - // (6,91): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "MyTask").WithArguments("lambda return type", "10.0").WithLocation(6, 81), + // (6,91): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // Func f = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder))] static async MyTask () => { System.Console.Write("F "); await Task.Delay(0); }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "=>").WithArguments("async method builder override").WithLocation(6, 91), - // (8,23): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "=>").WithArguments("async method builder override", "10.0").WithLocation(6, 91), + // (8,23): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // Func> m = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))] async MyTask () => { System.Console.Write("M "); await f(); return 3; }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))]").WithArguments("lambda attributes").WithLocation(8, 23), - // (8,81): error CS8652: The feature 'lambda return type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))]").WithArguments("lambda attributes", "10.0").WithLocation(8, 23), + // (8,81): error CS8773: Feature 'lambda return type' is not available in C# 9.0. Please use language version 10.0 or greater. // Func> m = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))] async MyTask () => { System.Console.Write("M "); await f(); return 3; }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "MyTask").WithArguments("lambda return type").WithLocation(8, 81), - // (8,96): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "MyTask").WithArguments("lambda return type", "10.0").WithLocation(8, 81), + // (8,96): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. // Func> m = [AsyncMethodBuilder(typeof(MyTaskMethodBuilder<>))] async MyTask () => { System.Console.Write("M "); await f(); return 3; }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "=>").WithArguments("async method builder override").WithLocation(8, 96) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "=>").WithArguments("async method builder override", "10.0").WithLocation(8, 96) ); - compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.RegularPreview); + compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular10); var verifier = CompileAndVerify(compilation, expectedOutput: "M F 3"); verifier.VerifyDiagnostics(); } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs index d47cd7fb86dc5..144ab5ebf7656 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenDeconstructTests.cs @@ -6168,12 +6168,12 @@ static void Main() var comp = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (6,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. // (@_, var x) = (1, 2); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(@_, var x) = (1, 2)", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(6, 9), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(@_, var x) = (1, 2)").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(6, 9), // (6,10): error CS0103: The name '_' does not exist in the current context // (@_, var x) = (1, 2); - Diagnostic(ErrorCode.ERR_NameNotInContext, "@_", isSuppressed: false).WithArguments("_").WithLocation(6, 10) + Diagnostic(ErrorCode.ERR_NameNotInContext, "@_").WithArguments("_").WithLocation(6, 10) ); var tree = comp.SyntaxTrees.First(); @@ -6716,21 +6716,21 @@ static void Main() "; var compCSharp9 = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular9); compCSharp9.VerifyDiagnostics( - // (6,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. // (var x, x) = (1, 2); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(var x, x) = (1, 2)", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(6, 9), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(var x, x) = (1, 2)").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(6, 9), // (6,17): error CS0841: Cannot use local variable 'x' before it is declared // (var x, x) = (1, 2); - Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x", isSuppressed: false).WithArguments("x").WithLocation(6, 17), - // (7,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "x").WithArguments("x").WithLocation(6, 17), + // (7,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. // (y, var y) = (1, 2); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(y, var y) = (1, 2)", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(7, 9), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(y, var y) = (1, 2)").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(7, 9), // (7,10): error CS0841: Cannot use local variable 'y' before it is declared // (y, var y) = (1, 2); - Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "y", isSuppressed: false).WithArguments("y").WithLocation(7, 10) + Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "y").WithArguments("y").WithLocation(7, 10) ); - var comp = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.RegularPreview); + var comp = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics( // (6,17): error CS0841: Cannot use local variable 'x' before it is declared // (var x, x) = (1, 2); @@ -7231,9 +7231,9 @@ static void Main(string[] args) }"; var compilation = CreateCompilation(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( - // (8,14): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (8,14): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. // for ((int x1, z) = t; ; ) - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(int x1, z) = t", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(8, 14)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(int x1, z) = t").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(8, 14)); var tree = compilation.SyntaxTrees.First(); var model = compilation.GetSemanticModel(tree); @@ -9933,18 +9933,18 @@ public void Deconstruct(out int a, out (string b, bool c) tuple) } "; CreateCompilation(source, parseOptions: TestOptions.Regular9).VerifyDiagnostics( - // (7,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (7,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. // (x1, string y1) = new A(); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(x1, string y1) = new A()", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(7, 9), - // (9,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(x1, string y1) = new A()").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(7, 9), + // (9,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. // (int x2, y2) = new A(); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(int x2, y2) = new A()", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(9, 9), - // (11,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(int x2, y2) = new A()").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(9, 9), + // (11,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. // (int x3, (string y3, z3)) = new B(); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(int x3, (string y3, z3)) = new B()", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(11, 9), - // (13,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(int x3, (string y3, z3)) = new B()").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(11, 9), + // (13,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. // (x4, var (y4, z4)) = new B(); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(x4, var (y4, z4)) = new B()", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(13, 9)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(x4, var (y4, z4)) = new B()").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(13, 9)); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs index 5c099ac55b72b..89ee7957084a1 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleEqualityTests.cs @@ -1353,17 +1353,27 @@ static void Main() System.Console.Write((null, () => 2) == default); } }"; - var comp = CreateCompilation(source); + var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( // (6,30): error CS0034: Operator '==' is ambiguous on operands of type '' and 'default' // System.Console.Write((null, () => 1) == (default, default)); Diagnostic(ErrorCode.ERR_AmbigBinaryOps, "(null, () => 1) == (default, default)").WithArguments("==", "", "default").WithLocation(6, 30), - // (6,37): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,37): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Console.Write((null, () => 1) == (default, default)); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => 1").WithArguments("inferred delegate type").WithLocation(6, 37), - // (6,37): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => 1").WithArguments("inferred delegate type", "10.0").WithLocation(6, 37), + // (6,37): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Console.Write((null, () => 1) == (default, default)); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => 1").WithArguments("inferred delegate type").WithLocation(6, 37), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => 1").WithArguments("inferred delegate type", "10.0").WithLocation(6, 37), + // (7,30): error CS0034: Operator '==' is ambiguous on operands of type '(, lambda expression)' and 'default' + // System.Console.Write((null, () => 2) == default); + Diagnostic(ErrorCode.ERR_AmbigBinaryOps, "(null, () => 2) == default").WithArguments("==", "(, lambda expression)", "default").WithLocation(7, 30) + ); + + comp = CreateCompilation(source); + comp.VerifyDiagnostics( + // (6,30): error CS0034: Operator '==' is ambiguous on operands of type '' and 'default' + // System.Console.Write((null, () => 1) == (default, default)); + Diagnostic(ErrorCode.ERR_AmbigBinaryOps, "(null, () => 1) == (default, default)").WithArguments("==", "", "default").WithLocation(6, 30), // (7,30): error CS0034: Operator '==' is ambiguous on operands of type '(, lambda expression)' and 'default' // System.Console.Write((null, () => 2) == default); Diagnostic(ErrorCode.ERR_AmbigBinaryOps, "(null, () => 2) == default").WithArguments("==", "(, lambda expression)", "default").WithLocation(7, 30) @@ -1662,30 +1672,30 @@ static void Main() }"; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (6,65): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,65): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "x => x").WithArguments("inferred delegate type").WithLocation(6, 65), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "x => x").WithArguments("inferred delegate type", "10.0").WithLocation(6, 65), // (6,65): error CS8917: The delegate type could not be inferred. // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })); Diagnostic(ErrorCode.ERR_CannotInferDelegateType, "x => x").WithLocation(6, 65), - // (6,65): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,65): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "x => x").WithArguments("inferred delegate type").WithLocation(6, 65), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "x => x").WithArguments("inferred delegate type", "10.0").WithLocation(6, 65), // (6,65): error CS8917: The delegate type could not be inferred. // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })); Diagnostic(ErrorCode.ERR_CannotInferDelegateType, "x => x").WithLocation(6, 65), - // (6,73): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,73): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "Main").WithArguments("inferred delegate type").WithLocation(6, 73), - // (6,73): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "Main").WithArguments("inferred delegate type", "10.0").WithLocation(6, 73), + // (6,73): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "Main").WithArguments("inferred delegate type").WithLocation(6, 73), - // (6,79): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "Main").WithArguments("inferred delegate type", "10.0").WithLocation(6, 73), + // (6,79): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(int i) => { int j = 0; return i + j; }").WithArguments("inferred delegate type").WithLocation(6, 79), - // (6,79): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(int i) => { int j = 0; return i + j; }").WithArguments("inferred delegate type", "10.0").WithLocation(6, 79), + // (6,79): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Console.Write((null, null, null, null) == (null, x => x, Main, (int i) => { int j = 0; return i + j; })); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(int i) => { int j = 0; return i + j; }").WithArguments("inferred delegate type").WithLocation(6, 79)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(int i) => { int j = 0; return i + j; }").WithArguments("inferred delegate type", "10.0").WithLocation(6, 79)); verify(comp); comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); @@ -2017,9 +2027,6 @@ public void M() // (6,13): error CS0815: Cannot assign (, ) to an implicitly-typed variable // var t = (null, null); Diagnostic(ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, "t = (null, null)").WithArguments("(, )").WithLocation(6, 13), - // (7,22): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // if (null == (() => {}) ) {} - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => {}").WithArguments("inferred delegate type").WithLocation(7, 22), // (8,13): error CS0019: Operator '==' cannot be applied to operands of type 'string' and 'int' // if ("" == 1) {} Diagnostic(ErrorCode.ERR_BadBinaryOps, @""""" == 1").WithArguments("==", "string", "int").WithLocation(8, 13) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs index ff547024e3d84..dd27e4aff990f 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs @@ -20,6 +20,85 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests /// public class AwaitExpressionTests : CompilingTestBase { + [Fact] + public void TestAwaitInfoExtensionMethod() + { + var text = +@"using System; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +static class App{ + public static async Task Main(){ + var x = new MyAwaitable(); + x.SetValue(42); + + Console.WriteLine(await x + ""!""); + } +} + +struct MyAwaitable +{ + private ValueTask task; + private TaskCompletionSource source; + + private TaskCompletionSource Source + { + get + { + if (source == null) + { + source = new TaskCompletionSource(); + task = new ValueTask(source.Task); + } + return source; + } + } + internal ValueTask Task + { + get + { + _ = Source; + return task; + } + } + + public void SetValue(int i) + { + Source.SetResult(i); + } +} + +static class MyAwaitableExtension +{ + public static System.Runtime.CompilerServices.ValueTaskAwaiter GetAwaiter(this MyAwaitable a) + { + return a.Task.GetAwaiter(); + } +}"; + + var csCompilation = CreateCompilation(text, targetFramework: TargetFramework.NetCoreAppAndCSharp); + var tree = csCompilation.SyntaxTrees.Single(); + + var model = csCompilation.GetSemanticModel(tree); + var awaitExpression = tree.GetRoot().DescendantNodes().OfType().First(); + Assert.Equal("await x", awaitExpression.ToString()); + + var info = model.GetAwaitExpressionInfo(awaitExpression); + Assert.Equal( + "System.Runtime.CompilerServices.ValueTaskAwaiter MyAwaitableExtension.GetAwaiter(this MyAwaitable a)", + info.GetAwaiterMethod.ToTestDisplayString() + ); + Assert.Equal( + "System.Int32 System.Runtime.CompilerServices.ValueTaskAwaiter.GetResult()", + info.GetResultMethod.ToTestDisplayString() + ); + Assert.Equal( + "System.Boolean System.Runtime.CompilerServices.ValueTaskAwaiter.IsCompleted { get; }", + info.IsCompletedProperty.ToTestDisplayString() + ); + } + [Fact] [WorkItem(711413, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/711413")] public void TestAwaitInfo() diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs index 8249170b71bb9..1574892347516 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs @@ -246,9 +246,6 @@ static void M(A a) // (11,9): error CS1656: Cannot assign to 'E' because it is a 'method group' // a.E += a.E; Diagnostic(ErrorCode.ERR_AssgReadonlyLocalCause, "a.E").WithArguments("E", "method group").WithLocation(11, 9), - // (12,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // if (a.E != null) - Diagnostic(ErrorCode.ERR_FeatureInPreview, "a.E").WithArguments("inferred delegate type").WithLocation(12, 13), // (14,15): error CS1503: Argument 1: cannot convert from 'method group' to 'A' // M(a.E); Diagnostic(ErrorCode.ERR_BadArgType, "a.E").WithArguments("1", "method group", "A").WithLocation(14, 15), diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/ConstantTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/ConstantTests.cs index e33614276b71e..a963782c19e28 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/ConstantTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/ConstantTests.cs @@ -3727,65 +3727,65 @@ void M2(string S1 = $""Testing"", object O = null, Namae N = null) } } }"; - var comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + var comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics( // (32,27): error CS0133: The expression being assigned to 'S6' must be constant // const string S6 = $"Failed to {VS}"; Diagnostic(ErrorCode.ERR_NotConstantExpression, @"$""Failed to {VS}""").WithArguments("S6").WithLocation(34, 27)); - comp = CreateCompilation(source, parseOptions: TestOptions.Regular8); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (12,4): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (12,4): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // [A($"ITEM")] - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""ITEM""").WithArguments("constant interpolated strings").WithLocation(12, 4), - // (15,23): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""ITEM""").WithArguments("constant interpolated strings", "10.0").WithLocation(12, 4), + // (15,23): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string S0 = $"Post"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Post""").WithArguments("constant interpolated strings").WithLocation(15, 23), - // (25,27): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Post""").WithArguments("constant interpolated strings", "10.0").WithLocation(15, 23), + // (25,27): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string S1 = $"Testing"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Testing""").WithArguments("constant interpolated strings").WithLocation(25, 27), - // (26,27): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Testing""").WithArguments("constant interpolated strings", "10.0").WithLocation(25, 27), + // (26,27): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string S2 = $"{"Level 5"} {"Number 3"}"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""{""Level 5""} {""Number 3""}""").WithArguments("constant interpolated strings").WithLocation(26, 27), - // (27,27): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""{""Level 5""} {""Number 3""}""").WithArguments("constant interpolated strings", "10.0").WithLocation(26, 27), + // (27,27): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string S3 = $"{$"{"Spinning Top"}"}"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""{$""{""Spinning Top""}""}""").WithArguments("constant interpolated strings").WithLocation(27, 27), - // (28,27): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""{$""{""Spinning Top""}""}""").WithArguments("constant interpolated strings", "10.0").WithLocation(27, 27), + // (28,27): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string S4 = $"Hybrid" + "Testing" + "123"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Hybrid""").WithArguments("constant interpolated strings").WithLocation(28, 27), - // (29,50): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Hybrid""").WithArguments("constant interpolated strings", "10.0").WithLocation(28, 27), + // (29,50): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string S5 = "Hybrid" + "Testing" + $"321"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""321""").WithArguments("constant interpolated strings").WithLocation(29, 50), - // (30,27): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""321""").WithArguments("constant interpolated strings", "10.0").WithLocation(29, 50), + // (30,27): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string F1 = $"{S1}"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""{S1}""").WithArguments("constant interpolated strings").WithLocation(30, 27), - // (31,32): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""{S1}""").WithArguments("constant interpolated strings", "10.0").WithLocation(30, 27), + // (31,32): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string F2 = F1 + $" the {S2}"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$"" the {S2}""").WithArguments("constant interpolated strings").WithLocation(31, 32), - // (34,27): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$"" the {S2}""").WithArguments("constant interpolated strings", "10.0").WithLocation(31, 32), + // (34,27): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // const string S6 = $"Failed to {VS}"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Failed to {VS}""").WithArguments("constant interpolated strings").WithLocation(34, 27), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Failed to {VS}""").WithArguments("constant interpolated strings", "10.0").WithLocation(34, 27), // (34,27): error CS0133: The expression being assigned to 'S6' must be constant // const string S6 = $"Failed to {VS}"; Diagnostic(ErrorCode.ERR_NotConstantExpression, @"$""Failed to {VS}""").WithArguments("S6").WithLocation(34, 27), - // (37,25): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (37,25): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // void M2(string S1 = $"Testing", object O = null, Namae N = null) - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Testing""").WithArguments("constant interpolated strings").WithLocation(37, 25), - // (40,18): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Testing""").WithArguments("constant interpolated strings", "10.0").WithLocation(37, 25), + // (40,18): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // case $"Level 5": - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Level 5""").WithArguments("constant interpolated strings").WithLocation(40, 18), - // (44,30): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Level 5""").WithArguments("constant interpolated strings", "10.0").WithLocation(40, 18), + // (44,30): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // if (N is Namae { X : $"ConstantInterpolatedString"}){ - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""ConstantInterpolatedString""").WithArguments("constant interpolated strings").WithLocation(44, 30), - // (46,22): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""ConstantInterpolatedString""").WithArguments("constant interpolated strings", "10.0").WithLocation(44, 30), + // (46,22): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // case $"Number 3": - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Number 3""").WithArguments("constant interpolated strings").WithLocation(46, 22), - // (48,22): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Number 3""").WithArguments("constant interpolated strings", "10.0").WithLocation(46, 22), + // (48,22): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // case $"Radio Noise": - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Radio Noise""").WithArguments("constant interpolated strings").WithLocation(48, 22), - // (49,31): error CS8652: The feature 'constant interpolated strings' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Radio Noise""").WithArguments("constant interpolated strings", "10.0").WithLocation(48, 22), + // (49,31): error CS8773: Feature 'constant interpolated strings' is not available in C# 9.0. Please use language version 10.0 or greater. // goto case $"Number 3"; - Diagnostic(ErrorCode.ERR_FeatureInPreview, @"$""Number 3""").WithArguments("constant interpolated strings").WithLocation(49, 31)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, @"$""Number 3""").WithArguments("constant interpolated strings", "10.0").WithLocation(49, 31)); } [Fact] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs index 02010ef5ab222..f911fc9fe74fe 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs @@ -73,20 +73,20 @@ static void Main() var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (6,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // d = Main; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "Main").WithArguments("inferred delegate type").WithLocation(6, 13), - // (7,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "Main").WithArguments("inferred delegate type", "10.0").WithLocation(6, 13), + // (7,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // d = () => { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => { }").WithArguments("inferred delegate type").WithLocation(7, 13), - // (8,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => { }").WithArguments("inferred delegate type", "10.0").WithLocation(7, 13), + // (8,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // d = delegate () { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "delegate () { }").WithArguments("inferred delegate type").WithLocation(8, 13), - // (9,48): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "delegate () { }").WithArguments("inferred delegate type", "10.0").WithLocation(8, 13), + // (9,48): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // System.Linq.Expressions.Expression e = () => 1; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => 1").WithArguments("inferred delegate type").WithLocation(9, 48)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => 1").WithArguments("inferred delegate type", "10.0").WithLocation(9, 48)); - comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics(); } @@ -1818,15 +1818,15 @@ static class E var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (7,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // c.M(Main); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "Main").WithArguments("inferred delegate type").WithLocation(7, 13), - // (8,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // c.M(() => { }); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => { }").WithArguments("inferred delegate type").WithLocation(8, 13)); + // (7,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. + // c.M(Main); // C#9: E.M(object x, Action y) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "Main").WithArguments("inferred delegate type", "10.0").WithLocation(7, 13), + // (8,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. + // c.M(() => { }); // C#9: E.M(object x, Action y) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => { }").WithArguments("inferred delegate type", "10.0").WithLocation(8, 13)); // Breaking change from C#9 which binds to E.M. - CompileAndVerify(source, parseOptions: TestOptions.RegularPreview, expectedOutput: + CompileAndVerify(source, parseOptions: TestOptions.Regular10, expectedOutput: @"C.M C.M "); @@ -1858,12 +1858,12 @@ static class E var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (8,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (8,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // c.M(() => 1); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => 1").WithArguments("inferred delegate type").WithLocation(8, 13)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => 1").WithArguments("inferred delegate type", "10.0").WithLocation(8, 13)); // Breaking change from C#9 which binds to E.M. - CompileAndVerify(source, parseOptions: TestOptions.RegularPreview, expectedOutput: @"C.M"); + CompileAndVerify(source, parseOptions: TestOptions.Regular10, expectedOutput: @"C.M"); } [Fact] @@ -1899,26 +1899,26 @@ static void Main() var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (14,12): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (14,12): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // FA(F2); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "F2").WithArguments("inferred delegate type").WithLocation(14, 12), - // (15,12): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "F2").WithArguments("inferred delegate type", "10.0").WithLocation(14, 12), + // (15,12): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // FB(F1); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "F1").WithArguments("inferred delegate type").WithLocation(15, 12), - // (18,12): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "F1").WithArguments("inferred delegate type", "10.0").WithLocation(15, 12), + // (18,12): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // FA(() => 0); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => 0").WithArguments("inferred delegate type").WithLocation(18, 12), - // (19,12): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => 0").WithArguments("inferred delegate type", "10.0").WithLocation(18, 12), + // (19,12): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // FB(() => { }); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => { }").WithArguments("inferred delegate type").WithLocation(19, 12), - // (22,12): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => { }").WithArguments("inferred delegate type", "10.0").WithLocation(19, 12), + // (22,12): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // FA(delegate () { return 0; }); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "delegate () { return 0; }").WithArguments("inferred delegate type").WithLocation(22, 12), - // (23,12): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "delegate () { return 0; }").WithArguments("inferred delegate type", "10.0").WithLocation(22, 12), + // (23,12): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // FB(delegate () { }); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "delegate () { }").WithArguments("inferred delegate type").WithLocation(23, 12)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "delegate () { }").WithArguments("inferred delegate type", "10.0").WithLocation(23, 12)); - CompileAndVerify(source, parseOptions: TestOptions.RegularPreview, expectedOutput: + CompileAndVerify(source, parseOptions: TestOptions.Regular10, expectedOutput: @"FA(Action) FA(Delegate) FB(Delegate) @@ -1954,11 +1954,11 @@ static void Main() var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (11,11): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (11,11): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // F(() => string.Empty); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "() => string.Empty").WithArguments("inferred delegate type").WithLocation(11, 11)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "() => string.Empty").WithArguments("inferred delegate type", "10.0").WithLocation(11, 11)); - CompileAndVerify(source, parseOptions: TestOptions.RegularPreview, expectedOutput: + CompileAndVerify(source, parseOptions: TestOptions.Regular10, expectedOutput: @"F(Expression>): () => 0 F(Expression): () => String.Empty "); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/FunctionPointerTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/FunctionPointerTests.cs index 2e597b7498082..c4cfb87ed8580 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/FunctionPointerTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/FunctionPointerTests.cs @@ -44,7 +44,12 @@ public void UsingAliasTest() Diagnostic(ErrorCode.ERR_IdentifierExpectedKW, "delegate").WithArguments("", "delegate").WithLocation(2, 11), // (2,25): error CS0116: A namespace cannot directly contain members such as fields or methods // using s = delegate*; - Diagnostic(ErrorCode.ERR_NamespaceUnexpected, ">").WithLocation(2, 25) + Diagnostic(ErrorCode.ERR_NamespaceUnexpected, ">").WithLocation(2, 25), + + // See same-named test in TopLevelStatementsParsingTests, there is a single top-level statement in the tree and it is an empty statement. + // (2,26): error CS8937: At least one top-level statement must be non-empty. + // using s = delegate*; + Diagnostic(ErrorCode.ERR_SimpleProgramIsEmpty, ";").WithLocation(2, 26) ); } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/GlobalUsingDirectiveTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/GlobalUsingDirectiveTests.cs index b798bd8003748..35eb4bc5d2573 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/GlobalUsingDirectiveTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/GlobalUsingDirectiveTests.cs @@ -33,7 +33,19 @@ namespace ns2 {} namespace ns3 {} namespace ns4 {} "; - CreateCompilation(source, parseOptions: TestOptions.RegularPreview).VerifyDiagnostics( + CreateCompilation(source, parseOptions: TestOptions.Regular9).VerifyDiagnostics( + // (4,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. + // global using ns1; + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "global using ns1;").WithArguments("global using directive", "10.0").WithLocation(4, 1), + // (6,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. + // global using ns3; + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "global using ns3;").WithArguments("global using directive", "10.0").WithLocation(6, 1), + // (6,1): error CS8915: A global using directive must precede all non-global using directives. + // global using ns3; + Diagnostic(ErrorCode.ERR_GlobalUsingOutOfOrder, "global").WithLocation(6, 1) + ); + + CreateCompilation(source, parseOptions: TestOptions.Regular10).VerifyDiagnostics( // (6,1): error CS9002: A global using directive must precede all non-global using directives. // global using ns3; Diagnostic(ErrorCode.ERR_GlobalUsingOutOfOrder, "global").WithLocation(6, 1) @@ -52,7 +64,7 @@ public void MixingUsings_02() namespace ns1 {} namespace ns3 {} "; - CreateCompilation(source, parseOptions: TestOptions.RegularPreview).VerifyDiagnostics(); + CreateCompilation(source, parseOptions: TestOptions.Regular10).VerifyDiagnostics(); } [Fact] @@ -177,7 +189,7 @@ static void Main() } } "; - var comp2 = CreateCompilation(source2, parseOptions: TestOptions.RegularPreview, options: TestOptions.DebugExe, references: new[] { comp1Ref }); + var comp2 = CreateCompilation(source2, parseOptions: TestOptions.Regular10, options: TestOptions.DebugExe, references: new[] { comp1Ref }); CompileAndVerify(comp2, expectedOutput: @" C1 @@ -220,7 +232,7 @@ static void Main() } } "; - var comp3 = CreateCompilation(source3, parseOptions: TestOptions.RegularPreview, options: TestOptions.DebugExe, references: new[] { comp1Ref }); + var comp3 = CreateCompilation(source3, parseOptions: TestOptions.Regular10, options: TestOptions.DebugExe, references: new[] { comp1Ref }); CompileAndVerify(comp3, expectedOutput: @" C1 @@ -290,7 +302,7 @@ public static void Test() } } "; - var comp2 = CreateCompilation(source2, parseOptions: TestOptions.RegularPreview, options: TestOptions.DebugExe, references: new[] { comp1Ref }); + var comp2 = CreateCompilation(source2, parseOptions: TestOptions.Regular10, options: TestOptions.DebugExe, references: new[] { comp1Ref }); CompileAndVerify(comp2, expectedOutput: @" C1 diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs index 475be24bb3db1..a303513dcc29e 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/InheritanceBindingTests.cs @@ -68,7 +68,7 @@ static void IGoo.Method12() { } private protected void IGoo.Method14() { } }"; - CreateCompilation(text).VerifyDiagnostics( + CreateCompilation(text, parseOptions: TestOptions.Regular9).VerifyDiagnostics( // (22,24): error CS0106: The modifier 'abstract' is not valid for this item // abstract void IGoo.Method1() { } Diagnostic(ErrorCode.ERR_BadMemberFlag, "Method1").WithArguments("abstract").WithLocation(22, 24), @@ -160,7 +160,7 @@ private int IGoo.Property10 { set { } } static int IGoo.Property12 { set { } } }"; - CreateCompilation(text).VerifyDiagnostics( + CreateCompilation(text, parseOptions: TestOptions.Regular9).VerifyDiagnostics( // (20,23): error CS0106: The modifier 'abstract' is not valid for this item Diagnostic(ErrorCode.ERR_BadMemberFlag, "Property1").WithArguments("abstract"), // (21,22): error CS0106: The modifier 'virtual' is not valid for this item @@ -305,7 +305,7 @@ static event System.Action IGoo.Event12 { add { } remove { } } // If the other errors are fixed ERR_ExternHasBody is reported. // We report all errors at once since they are unrelated, not cascading. - CreateCompilation(text).VerifyDiagnostics( + CreateCompilation(text, parseOptions: TestOptions.Regular9).VerifyDiagnostics( // (20,39): error CS0106: The modifier 'abstract' is not valid for this item // abstract event System.Action IGoo.Event1 { add { } remove { } } Diagnostic(ErrorCode.ERR_BadMemberFlag, "Event1").WithArguments("abstract"), diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaDiscardParametersTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaDiscardParametersTests.cs index 76a4850e08ab8..5fc1d4f4ef61c 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaDiscardParametersTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaDiscardParametersTests.cs @@ -368,15 +368,15 @@ static void Main() var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (8,14): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (8,14): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // a = ([A] _, y) => { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[A]").WithArguments("lambda attributes").WithLocation(8, 14), - // (9,24): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[A]").WithArguments("lambda attributes", "10.0").WithLocation(8, 14), + // (9,24): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // a = (object x, [A] object _) => { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[A]").WithArguments("lambda attributes").WithLocation(9, 24)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[A]").WithArguments("lambda attributes", "10.0").WithLocation(9, 24)); verifyAttributes(comp); - comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics(); verifyAttributes(comp); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs index 08fd8d7217ae5..19801f4bafc0b 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs @@ -3537,7 +3537,7 @@ static void Main() } }"; - var comp = CreateCompilation(new[] { sourceA, sourceB }, parseOptions: TestOptions.RegularPreview, options: TestOptions.ReleaseExe); + var comp = CreateCompilation(new[] { sourceA, sourceB }, parseOptions: TestOptions.Regular10, options: TestOptions.ReleaseExe); var tree = comp.SyntaxTrees[0]; var model = comp.GetSemanticModel(tree); var exprs = tree.GetRoot().DescendantNodes().OfType(); @@ -3607,23 +3607,23 @@ static void Main() var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (9,13): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (9,13): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // a = [A, B] (x, y) => { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[A, B]").WithArguments("lambda attributes").WithLocation(9, 13), - // (10,14): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[A, B]").WithArguments("lambda attributes", "10.0").WithLocation(9, 13), + // (10,14): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // a = ([A] x, [B] y) => { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[A]").WithArguments("lambda attributes").WithLocation(10, 14), - // (10,21): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[A]").WithArguments("lambda attributes", "10.0").WithLocation(10, 14), + // (10,21): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // a = ([A] x, [B] y) => { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[B]").WithArguments("lambda attributes").WithLocation(10, 21), - // (11,24): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[B]").WithArguments("lambda attributes", "10.0").WithLocation(10, 21), + // (11,24): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // a = (object x, [A][B] object y) => { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[A]").WithArguments("lambda attributes").WithLocation(11, 24), - // (11,27): error CS8652: The feature 'lambda attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[A]").WithArguments("lambda attributes", "10.0").WithLocation(11, 24), + // (11,27): error CS8773: Feature 'lambda attributes' is not available in C# 9.0. Please use language version 10.0 or greater. // a = (object x, [A][B] object y) => { }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "[B]").WithArguments("lambda attributes").WithLocation(11, 27)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "[B]").WithArguments("lambda attributes", "10.0").WithLocation(11, 27)); - comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics(); } @@ -3662,7 +3662,7 @@ static void Main() var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics(expectedDiagnostics); - comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics(expectedDiagnostics); } @@ -4346,17 +4346,17 @@ static void F() var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (6,22): error CS8652: The feature 'lambda return type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,22): error CS8773: Feature 'lambda return type' is not available in C# 9.0. Please use language version 10.0 or greater. // Func f1 = T () => default; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "T").WithArguments("lambda return type").WithLocation(6, 22), - // (7,25): error CS8652: The feature 'lambda return type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "T").WithArguments("lambda return type", "10.0").WithLocation(6, 22), + // (7,25): error CS8773: Feature 'lambda return type' is not available in C# 9.0. Please use language version 10.0 or greater. // Func f2 = T (x) => { return x; }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "T").WithArguments("lambda return type").WithLocation(7, 25), - // (8,25): error CS8652: The feature 'lambda return type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "T").WithArguments("lambda return type", "10.0").WithLocation(7, 25), + // (8,25): error CS8773: Feature 'lambda return type' is not available in C# 9.0. Please use language version 10.0 or greater. // Func f3 = T (T x) => x; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "T").WithArguments("lambda return type").WithLocation(8, 25)); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "T").WithArguments("lambda return type", "10.0").WithLocation(8, 25)); - comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics(); } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs index 7524584f6fda9..fa06937b150cd 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NullableReferenceTypesTests.cs @@ -1945,13 +1945,13 @@ static void M(A a) } } }"; - CreateCompilation(source).VerifyDiagnostics( + CreateCompilation(source, parseOptions: TestOptions.Regular9).VerifyDiagnostics( // (8,9): error CS1656: Cannot assign to 'E' because it is a 'method group' // a.E! += a.E!; // 1 Diagnostic(ErrorCode.ERR_AssgReadonlyLocalCause, "a.E").WithArguments("E", "method group").WithLocation(8, 9), - // (9,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (9,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // if (a.E! != null) // 2 - Diagnostic(ErrorCode.ERR_FeatureInPreview, "a.E").WithArguments("inferred delegate type").WithLocation(9, 13), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "a.E").WithArguments("inferred delegate type", "10.0").WithLocation(9, 13), // (11,15): error CS1503: Argument 1: cannot convert from 'method group' to 'A' // M(a.E!); // 3 Diagnostic(ErrorCode.ERR_BadArgType, "a.E").WithArguments("1", "method group", "A").WithLocation(11, 15), @@ -1970,9 +1970,9 @@ static void M(A a) // (17,9): error CS1656: Cannot assign to 'F' because it is a 'method group' // a.F! += a.F!; // 8 Diagnostic(ErrorCode.ERR_AssgReadonlyLocalCause, "a.F").WithArguments("F", "method group").WithLocation(17, 9), - // (18,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (18,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // if (a.F! != null) // 9 - Diagnostic(ErrorCode.ERR_FeatureInPreview, "a.F").WithArguments("inferred delegate type").WithLocation(18, 13), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "a.F").WithArguments("inferred delegate type", "10.0").WithLocation(18, 13), // (20,15): error CS1503: Argument 1: cannot convert from 'method group' to 'A' // M(a.F!); // 10 Diagnostic(ErrorCode.ERR_BadArgType, "a.F").WithArguments("1", "method group", "A").WithLocation(20, 15), diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests5.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests5.cs index f336211da27bb..2fb1dd4436933 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests5.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests5.cs @@ -522,7 +522,7 @@ class C { public object Prop3 => null; } Statements (0) "; - VerifyFlowGraphAndDiagnosticsForTest(src, expectedFlowGraph, DiagnosticDescription.None, parseOptions: TestOptions.RegularPreview); + VerifyFlowGraphAndDiagnosticsForTest(src, expectedFlowGraph, DiagnosticDescription.None, parseOptions: TestOptions.Regular10); } [Fact] @@ -684,7 +684,7 @@ struct C { public object Field3; } Statements (0) "; - VerifyFlowGraphAndDiagnosticsForTest(src, expectedFlowGraph, expectedDiagnostics, parseOptions: TestOptions.RegularPreview); + VerifyFlowGraphAndDiagnosticsForTest(src, expectedFlowGraph, expectedDiagnostics, parseOptions: TestOptions.Regular10); } [Fact] @@ -1503,9 +1503,9 @@ public void Deconstruct(out C c1, out C c2) "; var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular9); compilation.VerifyEmitDiagnostics( - // (8,22): error CS8652: The feature 'extended property patterns' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (8,22): error CS8773: Feature 'extended property patterns' is not available in C# 9.0. Please use language version 10.0 or greater. // _ = this is (Property.Property: null, Property: null); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "Property.Property").WithArguments("extended property patterns").WithLocation(8, 22), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "Property.Property").WithArguments("extended property patterns", "10.0").WithLocation(8, 22), // (8,22): error CS1001: Identifier expected // _ = this is (Property.Property: null, Property: null); Diagnostic(ErrorCode.ERR_IdentifierExpected, "Property.Property").WithLocation(8, 22), diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordStructTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordStructTests.cs index 226260166b8ab..75948efc9befc 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordStructTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordStructTests.cs @@ -281,19 +281,19 @@ record struct Point(int x, int y); comp = CreateCompilation(new[] { src2, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular9, options: TestOptions.ReleaseDll); comp.VerifyDiagnostics( - // (2,8): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (2,8): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // record struct Point { } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(2, 8) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(2, 8) ); comp = CreateCompilation(new[] { src3, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular9, options: TestOptions.ReleaseDll); comp.VerifyDiagnostics( - // (2,8): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // record struct Point(int x, int y); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(2, 8) + // (2,8): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. + // record struct Point { } + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(2, 8) ); - comp = CreateCompilation(new[] { src1, IsExternalInitTypeDefinition }, parseOptions: TestOptions.RegularPreview, options: TestOptions.ReleaseDll); + comp = CreateCompilation(new[] { src1, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular10, options: TestOptions.ReleaseDll); comp.VerifyDiagnostics( // (2,13): error CS1514: { expected // struct Point(int x, int y); @@ -324,10 +324,10 @@ record struct Point(int x, int y); Diagnostic(ErrorCode.ERR_UseDefViolation, "int y").WithArguments("y").WithLocation(2, 21) ); - comp = CreateCompilation(new[] { src2, IsExternalInitTypeDefinition }, parseOptions: TestOptions.RegularPreview, options: TestOptions.ReleaseDll); + comp = CreateCompilation(new[] { src2, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular10, options: TestOptions.ReleaseDll); comp.VerifyDiagnostics(); - comp = CreateCompilation(new[] { src3, IsExternalInitTypeDefinition }, parseOptions: TestOptions.RegularPreview, options: TestOptions.ReleaseDll); + comp = CreateCompilation(new[] { src3, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular10, options: TestOptions.ReleaseDll); comp.VerifyDiagnostics(); } @@ -376,23 +376,23 @@ record struct Point { } comp = CreateCompilation(new[] { src2, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (4,12): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (4,12): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // record struct Point { } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(4, 12) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(4, 12) ); comp = CreateCompilation(new[] { src3, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (4,12): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (4,12): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // record struct Point(int x, int y); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(4, 12) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(4, 12) ); comp = CreateCompilation(src4, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (4,12): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (4,12): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // record struct Point { } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(4, 12) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(4, 12) ); comp = CreateCompilation(src1); @@ -2959,7 +2959,7 @@ public static class IsExternalInit } "; - var comp = CreateCompilation(src, parseOptions: TestOptions.RegularWithDocumentationComments.WithLanguageVersion(LanguageVersion.Preview)); + var comp = CreateCompilation(src, parseOptions: TestOptions.RegularWithDocumentationComments); comp.VerifyDiagnostics(); var cMember = comp.GetMember("C"); @@ -3005,7 +3005,7 @@ public static class IsExternalInit } "; - var comp = CreateCompilation(src, parseOptions: TestOptions.RegularWithDocumentationComments.WithLanguageVersion(LanguageVersion.Preview)); + var comp = CreateCompilation(src, parseOptions: TestOptions.RegularWithDocumentationComments); comp.VerifyDiagnostics( // (7,52): warning CS1574: XML comment has cref attribute 'x' that could not be resolved // /// Description for @@ -6449,9 +6449,9 @@ public B M() }"; var comp = CreateCompilation(src, parseOptions: TestOptions.Regular9); comp.VerifyEmitDiagnostics( - // (13,16): error CS8652: The feature 'with on structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (13,16): error CS8773: Feature 'with on structs' is not available in C# 9.0. Please use language version 10.0 or greater. // return this with { X = 42 }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "this with { X = 42 }").WithArguments("with on structs").WithLocation(13, 16) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "this with { X = 42 }").WithArguments("with on structs", "10.0").WithLocation(13, 16) ); comp = CreateCompilation(src); @@ -7775,12 +7775,12 @@ static T Identity(T t) }"; var comp = CreateCompilation(src, parseOptions: TestOptions.Regular9); comp.VerifyEmitDiagnostics( - // (9,17): error CS8652: The feature 'with on anonymous types' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (9,17): error CS8773: Feature 'with on anonymous types' is not available in C# 9.0. Please use language version 10.0 or greater. // var b = Identity(a) with { A = Identity(30), B = Identity(40) }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "Identity(a) with { A = Identity(30), B = Identity(40) }").WithArguments("with on anonymous types").WithLocation(9, 17) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "Identity(a) with { A = Identity(30), B = Identity(40) }").WithArguments("with on anonymous types", "10.0").WithLocation(9, 17) ); - comp = CreateCompilation(src, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(src, parseOptions: TestOptions.Regular10); comp.VerifyEmitDiagnostics(); var verifier = CompileAndVerify(comp, expectedOutput: "Identity({ A = 10, B = 20 }) Identity(30) Identity(40) { A = 30, B = 40 }"); verifier.VerifyIL("C.M", @" @@ -10098,15 +10098,15 @@ record struct A(int X) "; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyEmitDiagnostics( - // (8,8): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (8,8): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // record struct A(int X) - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(8, 8), - // (8,17): error CS8652: The feature 'positional fields in records' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(8, 8), + // (8,17): error CS8773: Feature 'positional fields in records' is not available in C# 9.0. Please use language version 10.0 or greater. // record struct A(int X) - Diagnostic(ErrorCode.ERR_FeatureInPreview, "int X").WithArguments("positional fields in records").WithLocation(8, 17) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "int X").WithArguments("positional fields in records", "10.0").WithLocation(8, 17) ); - comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, expectedOutput: "42 - 42"); verifier.VerifyIL("A.Deconstruct", @" diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs index f63456641bf32..b8cb91b2b0b9a 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RecordTests.cs @@ -282,12 +282,12 @@ record class Point(int x, int y); comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular9, options: TestOptions.ReleaseDll); comp.VerifyDiagnostics( - // (2,8): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (2,8): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // record class Point(int x, int y); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "class").WithArguments("record structs").WithLocation(2, 8) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "class").WithArguments("record structs", "10.0").WithLocation(2, 8) ); - comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, parseOptions: TestOptions.RegularPreview, options: TestOptions.ReleaseDll); + comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular10, options: TestOptions.ReleaseDll); comp.VerifyDiagnostics(); } @@ -852,7 +852,7 @@ public partial record class C public int P2 { get; set; } = X; } "; - var comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, options: TestOptions.DebugExe, parseOptions: TestOptions.RegularPreview); + var comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular10); CompileAndVerify(comp, expectedOutput: "(2, 2)", verify: Verification.Skipped /* init-only */).VerifyDiagnostics(); } @@ -1106,7 +1106,7 @@ public void RecordProperties_05_RecordClass() record class C(int X, int X) { }"; - var comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, parseOptions: TestOptions.RegularPreview); + var comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics( // (2,27): error CS0100: The parameter name 'X' is a duplicate // record class C(int X, int X) @@ -1247,9 +1247,9 @@ class P1 { } // (1,17): error CS0102: The type 'C' already contains a definition for 'P1' // record C(object P1, object P2, object P3, object P4) Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "P1").WithArguments("C", "P1").WithLocation(1, 17), - // (1,21): error CS8652: The feature 'positional fields in records' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,21): error CS8773: Feature 'positional fields in records' is not available in C# 9.0. Please use language version 10.0 or greater. // record C(object P1, object P2, object P3, object P4) - Diagnostic(ErrorCode.ERR_FeatureInPreview, "object P2").WithArguments("positional fields in records").WithLocation(1, 21), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "object P2").WithArguments("positional fields in records", "10.0").WithLocation(1, 21), // (1,28): warning CS8907: Parameter 'P2' is unread. Did you forget to use it to initialize the property with that name? // record C(object P1, object P2, object P3, object P4) Diagnostic(ErrorCode.WRN_UnreadRecordParameter, "P2").WithArguments("P2").WithLocation(1, 28), @@ -1261,7 +1261,7 @@ class P1 { } Diagnostic(ErrorCode.ERR_DuplicateNameInClass, "P4").WithArguments("C", "P4").WithLocation(6, 9) ); - comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(new[] { src, IsExternalInitTypeDefinition }, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics( // (1,17): error CS0102: The type 'C' already contains a definition for 'P1' // record C(object P1, object P2, object P3, object P4) @@ -1667,7 +1667,7 @@ static void Main() } "; - var verifier = CompileAndVerify(src, expectedOutput: "True", parseOptions: TestOptions.RegularPreview); + var verifier = CompileAndVerify(src, expectedOutput: "True", parseOptions: TestOptions.Regular10); verifier.VerifyDiagnostics(); verifier.VerifyIL("C..ctor()", @" @@ -2765,9 +2765,9 @@ public override void M(U t) }"; var comp = CreateCompilationWithIL(new[] { src, IsExternalInitTypeDefinition }, ilSource: ilSource, parseOptions: TestOptions.Regular9); comp.VerifyDiagnostics( - // (11,13): error CS8652: The feature 'with on structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (11,13): error CS8773: Feature 'with on structs' is not available in C# 9.0. Please use language version 10.0 or greater. // _ = t with { X = 2, Property = 3 }; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "t with { X = 2, Property = 3 }").WithArguments("with on structs").WithLocation(11, 13), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "t with { X = 2, Property = 3 }").WithArguments("with on structs", "10.0").WithLocation(11, 13), // (11,22): error CS0117: 'U' does not contain a definition for 'X' // _ = t with { X = 2, Property = 3 }; Diagnostic(ErrorCode.ERR_NoSuchMember, "X").WithArguments("U", "X").WithLocation(11, 22), @@ -2776,7 +2776,7 @@ public override void M(U t) Diagnostic(ErrorCode.ERR_NoSuchMember, "Property").WithArguments("U", "Property").WithLocation(11, 29) ); - comp = CreateCompilationWithIL(new[] { src, IsExternalInitTypeDefinition }, ilSource: ilSource, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilationWithIL(new[] { src, IsExternalInitTypeDefinition }, ilSource: ilSource, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics( // (11,22): error CS0117: 'U' does not contain a definition for 'X' // _ = t with { X = 2, Property = 3 }; @@ -5988,7 +5988,7 @@ record C1 record C2 : C1; "; - var comp = CreateCompilation(src, parseOptions: usePreview ? TestOptions.RegularPreview : TestOptions.Regular9, options: TestOptions.DebugExe); + var comp = CreateCompilation(src, parseOptions: usePreview ? TestOptions.Regular10 : TestOptions.Regular9, options: TestOptions.DebugExe); if (usePreview) { comp.VerifyEmitDiagnostics(); @@ -5997,9 +5997,9 @@ record C2 : C1; else { comp.VerifyEmitDiagnostics( - // (4,35): error CS8652: The feature 'sealed ToString in record' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // public sealed override string ToString() => throw null; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "ToString").WithArguments("sealed ToString in record").WithLocation(7, 35) + // (7,35): error CS8773: Feature 'sealed ToString in record' is not available in C# 9.0. Please use language version 10.0 or greater. + // public sealed override string ToString() => "C1"; + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "ToString").WithArguments("sealed ToString in record", "10.0").WithLocation(7, 35) ); } } @@ -7376,7 +7376,7 @@ public record B : A { var comp = CreateCompilationWithIL( new[] { source, IsExternalInitTypeDefinition }, ilSource: ilSource, - parseOptions: usePreview ? TestOptions.RegularPreview : TestOptions.Regular9); + parseOptions: usePreview ? TestOptions.Regular10 : TestOptions.Regular9); if (usePreview) { comp.VerifyEmitDiagnostics(); @@ -7385,9 +7385,9 @@ public record B : A { else { comp.VerifyEmitDiagnostics( - // (2,1): error CS8912: Inheriting from a record with a sealed 'Object.ToString' is not supported in C# 9.0. Please use language version 'preview' or greater. - // record B : A - Diagnostic(ErrorCode.ERR_InheritingFromRecordWithSealedToString, "B").WithArguments("9.0", "preview").WithLocation(5, 15) + // (5,15): error CS8912: Inheriting from a record with a sealed 'Object.ToString' is not supported in C# 9.0. Please use language version '10.0' or greater. + // public record B : A { + Diagnostic(ErrorCode.ERR_InheritingFromRecordWithSealedToString, "B").WithArguments("9.0", "10.0").WithLocation(5, 15) ); } } @@ -7425,7 +7425,7 @@ record C1 } "; - var comp = CreateCompilation(src, parseOptions: usePreview ? TestOptions.RegularPreview : TestOptions.Regular9); + var comp = CreateCompilation(src, parseOptions: usePreview ? TestOptions.Regular10 : TestOptions.Regular9); if (usePreview) { comp.VerifyEmitDiagnostics(); @@ -7433,9 +7433,9 @@ record C1 else { comp.VerifyEmitDiagnostics( - // (4,35): error CS8652: The feature 'sealed ToString in record' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (4,35): error CS8773: Feature 'sealed ToString in record' is not available in C# 9.0. Please use language version 10.0 or greater. // public sealed override string ToString() => throw null; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "ToString").WithArguments("sealed ToString in record").WithLocation(4, 35) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "ToString").WithArguments("sealed ToString in record", "10.0").WithLocation(4, 35) ); } } @@ -10044,9 +10044,9 @@ static void Main() // (7,21): warning CS8907: Parameter 'Y' is unread. Did you forget to use it to initialize the property with that name? // record B(int X, int Y, int Z) : A Diagnostic(ErrorCode.WRN_UnreadRecordParameter, "Y").WithArguments("Y").WithLocation(7, 21), - // (7,24): error CS8652: The feature 'positional fields in records' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (7,24): error CS8773: Feature 'positional fields in records' is not available in C# 9.0. Please use language version 10.0 or greater. // record B(int X, int Y, int Z) : A - Diagnostic(ErrorCode.ERR_FeatureInPreview, "int Z").WithArguments("positional fields in records").WithLocation(7, 24), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "int Z").WithArguments("positional fields in records", "10.0").WithLocation(7, 24), // (7,28): warning CS8907: Parameter 'Z' is unread. Did you forget to use it to initialize the property with that name? // record B(int X, int Y, int Z) : A Diagnostic(ErrorCode.WRN_UnreadRecordParameter, "Z").WithArguments("Z").WithLocation(7, 28)); @@ -10905,9 +10905,9 @@ public class P1 { } // (1,17): warning CS8907: Parameter 'P1' is unread. Did you forget to use it to initialize the property with that name? // record B(object P1, object P2, object P3, object P4) : A Diagnostic(ErrorCode.WRN_UnreadRecordParameter, "P1").WithArguments("P1").WithLocation(1, 17), - // (1,21): error CS8652: The feature 'positional fields in records' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,21): error CS8773: Feature 'positional fields in records' is not available in C# 9.0. Please use language version 10.0 or greater. // record B(object P1, object P2, object P3, object P4) : A - Diagnostic(ErrorCode.ERR_FeatureInPreview, "object P2").WithArguments("positional fields in records").WithLocation(1, 21), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "object P2").WithArguments("positional fields in records", "10.0").WithLocation(1, 21), // (1,28): warning CS8907: Parameter 'P2' is unread. Did you forget to use it to initialize the property with that name? // record B(object P1, object P2, object P3, object P4) : A Diagnostic(ErrorCode.WRN_UnreadRecordParameter, "P2").WithArguments("P2").WithLocation(1, 28), @@ -14556,9 +14556,9 @@ static void Main() "; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyEmitDiagnostics( - // (4,10): error CS8652: The feature 'positional fields in records' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (4,10): error CS8773: Feature 'positional fields in records' is not available in C# 9.0. Please use language version 10.0 or greater. // record C(int X) - Diagnostic(ErrorCode.ERR_FeatureInPreview, "int X").WithArguments("positional fields in records").WithLocation(4, 10), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "int X").WithArguments("positional fields in records", "10.0").WithLocation(4, 10), // (4,14): warning CS8907: Parameter 'X' is unread. Did you forget to use it to initialize the property with that name? // record C(int X) Diagnostic(ErrorCode.WRN_UnreadRecordParameter, "X").WithArguments("X").WithLocation(4, 14), @@ -14567,7 +14567,7 @@ static void Main() Diagnostic(ErrorCode.WRN_UnreferencedField, "X").WithArguments("C.X").WithLocation(6, 9) ); - comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics( // (4,14): warning CS8907: Parameter 'X' is unread. Did you forget to use it to initialize the property with that name? // record C(int X) @@ -15827,7 +15827,7 @@ public void Overrides_01(bool usePreview) record B(int X, int Y) : A { }"; - var comp = CreateCompilation(new[] { source, IsExternalInitTypeDefinition }, parseOptions: usePreview ? TestOptions.RegularPreview : TestOptions.Regular9); + var comp = CreateCompilation(new[] { source, IsExternalInitTypeDefinition }, parseOptions: usePreview ? TestOptions.Regular10 : TestOptions.Regular9); if (usePreview) { comp.VerifyDiagnostics( @@ -15845,15 +15845,15 @@ record B(int X, int Y) : A else { comp.VerifyDiagnostics( - // (3,33): error CS0111: Type 'A' already defines a member called 'Equals' with the same parameter types - // public sealed override bool Equals(object other) => false; - Diagnostic(ErrorCode.ERR_MemberAlreadyExists, "Equals").WithArguments("Equals", "A").WithLocation(3, 33), - // (5,35): error CS8652: The feature 'sealed ToString in record' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // public sealed override string ToString() => null; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "ToString").WithArguments("sealed ToString in record").WithLocation(5, 35), // (4,32): error CS8870: 'A.GetHashCode()' cannot be sealed because containing record is not sealed. // public sealed override int GetHashCode() => 0; Diagnostic(ErrorCode.ERR_SealedAPIInRecord, "GetHashCode").WithArguments("A.GetHashCode()").WithLocation(4, 32), + // (5,35): error CS8773: Feature 'sealed ToString in record' is not available in C# 9.0. Please use language version 10.0 or greater. + // public sealed override string ToString() => null; + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "ToString").WithArguments("sealed ToString in record", "10.0").WithLocation(5, 35), + // (3,33): error CS0111: Type 'A' already defines a member called 'Equals' with the same parameter types + // public sealed override bool Equals(object other) => false; + Diagnostic(ErrorCode.ERR_MemberAlreadyExists, "Equals").WithArguments("Equals", "A").WithLocation(3, 33), // (7,8): error CS0239: 'B.GetHashCode()': cannot override inherited member 'A.GetHashCode()' because it is sealed // record B(int X, int Y) : A Diagnostic(ErrorCode.ERR_CantOverrideSealed, "B").WithArguments("B.GetHashCode()", "A.GetHashCode()").WithLocation(7, 8) @@ -28054,7 +28054,7 @@ public static class IsExternalInit } "; - var comp = CreateCompilation(src, parseOptions: TestOptions.RegularWithDocumentationComments.WithLanguageVersion(LanguageVersion.Preview)); + var comp = CreateCompilation(src, parseOptions: TestOptions.RegularWithDocumentationComments); comp.VerifyDiagnostics(); var cMember = comp.GetMember("C"); @@ -28972,12 +28972,12 @@ record A(int X) "; var comp = CreateCompilation(source, parseOptions: TestOptions.Regular9); comp.VerifyEmitDiagnostics( - // (8,10): error CS8652: The feature 'positional fields in records' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // record A(int X) - Diagnostic(ErrorCode.ERR_FeatureInPreview, "int X").WithArguments("positional fields in records").WithLocation(8, 10) + // (8,10): error CS8773: Feature 'positional fields in records' is not available in C# 9.0. Please use language version 10.0 or greater. + // record A(int X) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "int X").WithArguments("positional fields in records", "10.0").WithLocation(8, 10) ); - comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); + comp = CreateCompilation(source, parseOptions: TestOptions.Regular10); comp.VerifyDiagnostics(); var verifier = CompileAndVerify(comp, expectedOutput: "42 - 42"); verifier.VerifyIL("A.Deconstruct", @" diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/TopLevelStatementsTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/TopLevelStatementsTests.cs index 1885bc63119c3..3f36753d91e4d 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/TopLevelStatementsTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/TopLevelStatementsTests.cs @@ -8819,5 +8819,98 @@ void M() Statements (0) "); } + + [Fact] + public void EmptyStatements_01() + { + var text = @";"; + + var comp = CreateCompilation(text, options: TestOptions.DebugExe, parseOptions: DefaultParseOptions); + comp.VerifyDiagnostics( + // (1,1): error CS8937: At least one top-level statement must be non-empty. + // ; + Diagnostic(ErrorCode.ERR_SimpleProgramIsEmpty, ";").WithLocation(1, 1) + ); + } + + [Fact] + public void EmptyStatements_02() + { + var text = @";; + + +;; +;"; + + var comp = CreateCompilation(text, options: TestOptions.DebugExe, parseOptions: DefaultParseOptions); + comp.VerifyDiagnostics( + // (1,1): error CS8937: At least one top-level statement must be non-empty. + // ;; + Diagnostic(ErrorCode.ERR_SimpleProgramIsEmpty, ";").WithLocation(1, 1) + ); + } + + [Fact] + public void EmptyStatements_03() + { + var text = @" +System.Console.WriteLine(""Hi!""); +;; +; +"; + + var comp = CreateCompilation(text, options: TestOptions.DebugExe, parseOptions: DefaultParseOptions); + CompileAndVerify(comp, expectedOutput: "Hi!"); + } + + [Fact] + public void EmptyStatements_04() + { + var text = @" +;; +; +System.Console.WriteLine(""Hi!"");"; + + var comp = CreateCompilation(text, options: TestOptions.DebugExe, parseOptions: DefaultParseOptions); + CompileAndVerify(comp, expectedOutput: "Hi!"); + } + + [Fact] + public void EmptyStatements_05() + { + var text = @" +; +System.Console.WriteLine(""Hi!""); +; +"; + + var comp = CreateCompilation(text, options: TestOptions.DebugExe, parseOptions: DefaultParseOptions); + CompileAndVerify(comp, expectedOutput: "Hi!"); + } + + [Fact] + public void EmptyStatements_06() + { + var text = +@" +using System; +; + +class Program +{ + static void Main(String[] args) {} +} +"; + + var comp = CreateCompilation(text, options: TestOptions.DebugExe, parseOptions: DefaultParseOptions); + comp.VerifyDiagnostics( + // (3,1): error CS8937: At least one top-level statement must be non-empty. + // ; + Diagnostic(ErrorCode.ERR_SimpleProgramIsEmpty, ";").WithLocation(3, 1), + // (7,17): warning CS7022: The entry point of the program is global code; ignoring 'Program.Main(string[])' entry point. + // static void Main(String[] args) {} + Diagnostic(ErrorCode.WRN_MainIgnored, "Main").WithArguments("Program.Main(string[])").WithLocation(7, 17) + ); + } } } diff --git a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs index bfb72a21c30bb..80d65639594e1 100644 --- a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs @@ -1244,6 +1244,7 @@ void verifyDiagnosticsWithSource(string source, (Diagnostic, TextSpan)[] reportD [Theory] [InlineData(LanguageVersion.CSharp9)] + [InlineData(LanguageVersion.CSharp10)] [InlineData(LanguageVersion.Preview)] public void GeneratorDriver_Prefers_Incremental_Generators(LanguageVersion langVer) { @@ -1284,6 +1285,7 @@ class C { } [Theory] [InlineData(LanguageVersion.CSharp9)] + [InlineData(LanguageVersion.CSharp10)] [InlineData(LanguageVersion.Preview)] public void GeneratorDriver_Initializes_Incremental_Generators(LanguageVersion langVer) { @@ -1337,7 +1339,7 @@ public void Incremental_Generators_Exception_During_Execution() var source = @" class C { } "; - var parseOptions = TestOptions.Regular.WithLanguageVersion(LanguageVersion.Preview); + var parseOptions = TestOptions.RegularPreview; Compilation compilation = CreateCompilation(source, options: TestOptions.DebugDll, parseOptions: parseOptions); compilation.VerifyDiagnostics(); @@ -1362,7 +1364,7 @@ public void Incremental_Generators_Exception_During_Execution_Doesnt_Produce_Any var source = @" class C { } "; - var parseOptions = TestOptions.Regular.WithLanguageVersion(LanguageVersion.Preview); + var parseOptions = TestOptions.RegularPreview; Compilation compilation = CreateCompilation(source, options: TestOptions.DebugDll, parseOptions: parseOptions); compilation.VerifyDiagnostics(); diff --git a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/StateTableTests.cs b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/StateTableTests.cs index 31ac16e6a4ebc..d5a8c60275cae 100644 --- a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/StateTableTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/StateTableTests.cs @@ -257,7 +257,7 @@ private void AssertTableEntries(NodeStateTable table, IList<(T item, Entry private DriverStateTable.Builder GetBuilder(DriverStateTable previous) { - var options = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Preview); + var options = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp10); var c = CSharpCompilation.Create("empty"); var state = new GeneratorDriverState(options, CompilerAnalyzerConfigOptionsProvider.Empty, diff --git a/src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs b/src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs index 188a65c7fe99f..00d944065650d 100644 --- a/src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs @@ -2060,14 +2060,14 @@ public void ReferenceManagerReuse_WithReferences() [Fact] public void ReferenceManagerReuse_WithSyntaxTrees() { - var ta = Parse("class C { }"); + var ta = Parse("class C { }", options: TestOptions.Regular10); var tb = Parse(@" class C { }", options: TestOptions.Script); var tc = Parse(@" #r ""bar"" // error: #r in regular code -class D { }"); +class D { }", options: TestOptions.Regular10); var tr = Parse(@" #r ""goo"" diff --git a/src/Compilers/CSharp/Test/Symbol/Compilation/UsedAssembliesTests.cs b/src/Compilers/CSharp/Test/Symbol/Compilation/UsedAssembliesTests.cs index 3e291c27d2dac..896a66f247db4 100644 --- a/src/Compilers/CSharp/Test/Symbol/Compilation/UsedAssembliesTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Compilation/UsedAssembliesTests.cs @@ -186,7 +186,7 @@ void assertUsedAssemblyReferences(Compilation comp, MetadataReference[] expected "); builder.Append(afterUsings); - var parseOptions = ((CSharpParseOptions)tree.Options).WithLanguageVersion(LanguageVersion.Preview); + var parseOptions = ((CSharpParseOptions)tree.Options).WithLanguageVersion(LanguageVersion.CSharp10); yield return (comp.ReplaceSyntaxTree(tree, CSharpTestBase.Parse(builder.ToString(), tree.FilePath, parseOptions)), before, after); // With global usings in a separate unit diff --git a/src/Compilers/CSharp/Test/Symbol/DocumentationComments/CrefTests.cs b/src/Compilers/CSharp/Test/Symbol/DocumentationComments/CrefTests.cs index 19bf6cfcede32..8b4c6f0b30c14 100644 --- a/src/Compilers/CSharp/Test/Symbol/DocumentationComments/CrefTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/DocumentationComments/CrefTests.cs @@ -6769,7 +6769,7 @@ public void OnRecordStruct(string terminator) /// record struct CacheContext(string RelativePathBase)" + terminator; - var comp = CreateCompilation(source, parseOptions: TestOptions.RegularWithDocumentationComments.WithLanguageVersion(LanguageVersion.Preview), targetFramework: TargetFramework.NetCoreApp); + var comp = CreateCompilation(source, parseOptions: TestOptions.RegularWithDocumentationComments.WithLanguageVersion(LanguageVersion.CSharp10), targetFramework: TargetFramework.NetCoreApp); comp.VerifyDiagnostics( // (6,25): warning CS1574: XML comment has cref attribute 'InvalidCref' that could not be resolved // /// See also . @@ -6814,7 +6814,7 @@ public void OnRecordStruct_WithoutPrimaryCtor(string terminator) /// record struct CacheContext" + terminator; - var comp = CreateCompilation(source, parseOptions: TestOptions.RegularWithDocumentationComments.WithLanguageVersion(LanguageVersion.Preview), targetFramework: TargetFramework.NetCoreApp); + var comp = CreateCompilation(source, parseOptions: TestOptions.RegularWithDocumentationComments.WithLanguageVersion(LanguageVersion.CSharp10), targetFramework: TargetFramework.NetCoreApp); comp.VerifyDiagnostics( // (5,25): warning CS1574: XML comment has cref attribute 'InvalidCref' that could not be resolved // /// See also . diff --git a/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs b/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs index 2fb52eb889c1c..7f142995debb0 100644 --- a/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs @@ -7688,7 +7688,7 @@ record struct Person(string First, string Last); text, findSymbol, format, - TestOptions.Regular.WithLanguageVersion(LanguageVersion.Preview), + TestOptions.Regular10, "record struct Person", SymbolDisplayPartKind.Keyword, SymbolDisplayPartKind.Space, @@ -7711,7 +7711,7 @@ public void ReadOnlyRecordStructDeclaration() text, findSymbol, format, - TestOptions.Regular.WithLanguageVersion(LanguageVersion.Preview), + TestOptions.Regular10, "readonly record struct Person", SymbolDisplayPartKind.Keyword, SymbolDisplayPartKind.Space, diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs index de8c324c6e1b2..9323bd7bc7aaf 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs @@ -7002,7 +7002,7 @@ class Test2 : I1 {} "; var compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.Regular, + parseOptions: TestOptions.Regular9, targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( @@ -8588,7 +8588,7 @@ void I1.M5() {} } "; var compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.Regular, + parseOptions: TestOptions.Regular9, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); compilation1.VerifyDiagnostics( @@ -12066,7 +12066,7 @@ class Test2 : I1 {} "; var compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.Regular, + parseOptions: TestOptions.Regular9, targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( @@ -14775,7 +14775,7 @@ class Test2 : I1, I2, I3, I4, I5 private void ValidatePropertyModifiers_18(string source1, params DiagnosticDescription[] expected) { var compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.Regular, + parseOptions: TestOptions.Regular9, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); compilation1.VerifyDiagnostics(expected); @@ -24906,7 +24906,7 @@ class Test2 : I1 {} "; var compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.Regular, + parseOptions: TestOptions.Regular9, targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( @@ -27439,7 +27439,7 @@ class Test2 : I1, I2, I3, I4, I5 private void ValidateEventModifiers_18(string source1, params DiagnosticDescription[] expected) { var compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.Regular, + parseOptions: TestOptions.Regular9, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); compilation1.VerifyDiagnostics(expected); @@ -59581,18 +59581,17 @@ interface I2 parseOptions: TestOptions.Regular8, targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( - // (15,12): error CS8904: Invalid variance: The type parameter 'T1' must be invariantly valid on 'I2.P1' unless language version 'preview' or greater is used. 'T1' is covariant. + // (15,12): error CS8904: Invalid variance: The type parameter 'T1' must be invariantly valid on 'I2.P1' unless language version '9.0' or greater is used. 'T1' is covariant. // static T1 P1 { get; set; } - Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "T1").WithArguments("I2.P1", "T1", "covariant", "invariantly", "preview").WithLocation(15, 12), - // (16,12): error CS8904: Invalid variance: The type parameter 'T2' must be invariantly valid on 'I2.P2' unless language version 'preview' or greater is used. 'T2' is contravariant. + Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "T1").WithArguments("I2.P1", "T1", "covariant", "invariantly", "9.0").WithLocation(15, 12), + // (16,12): error CS8904: Invalid variance: The type parameter 'T2' must be invariantly valid on 'I2.P2' unless language version '9.0' or greater is used. 'T2' is contravariant. // static T2 P2 { get; set; } - Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "T2").WithArguments("I2.P2", "T2", "contravariant", "invariantly", "preview").WithLocation(16, 12) + Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "T2").WithArguments("I2.P2", "T2", "contravariant", "invariantly", "9.0").WithLocation(16, 12) ); compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, - targetFramework: TargetFramework.NetCoreApp); - + parseOptions: TestOptions.Regular9, + targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, verify: VerifyOnMonoOrCoreClr, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @"a b").VerifyDiagnostics(); @@ -59623,17 +59622,17 @@ interface I2 parseOptions: TestOptions.Regular8, targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( - // (13,18): error CS8904: Invalid variance: The type parameter 'T1' must be contravariantly valid on 'I2.M1(T1)' unless language version 'preview' or greater is used. 'T1' is covariant. + // (13,18): error CS8904: Invalid variance: The type parameter 'T1' must be contravariantly valid on 'I2.M1(T1)' unless language version '9.0' or greater is used. 'T1' is covariant. // static T1 M1(T1 x) => x; - Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "T1").WithArguments("I2.M1(T1)", "T1", "covariant", "contravariantly", "preview").WithLocation(13, 18), - // (14,12): error CS8904: Invalid variance: The type parameter 'T2' must be covariantly valid on 'I2.M2(T2)' unless language version 'preview' or greater is used. 'T2' is contravariant. + Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "T1").WithArguments("I2.M1(T1)", "T1", "covariant", "contravariantly", "9.0").WithLocation(13, 18), + // (14,12): error CS8904: Invalid variance: The type parameter 'T2' must be covariantly valid on 'I2.M2(T2)' unless language version '9.0' or greater is used. 'T2' is contravariant. // static T2 M2(T2 x) => x; - Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "T2").WithArguments("I2.M2(T2)", "T2", "contravariant", "covariantly", "preview").WithLocation(14, 12) + Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "T2").WithArguments("I2.M2(T2)", "T2", "contravariant", "covariantly", "9.0").WithLocation(14, 12) ); compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, - targetFramework: TargetFramework.NetCoreApp); + parseOptions: TestOptions.Regular9, + targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, verify: VerifyOnMonoOrCoreClr, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @"a @@ -59687,17 +59686,17 @@ static T3 Print(T3 x) parseOptions: TestOptions.Regular8, targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( - // (24,53): error CS8904: Invalid variance: The type parameter 'T1' must be contravariantly valid on 'I2.E1' unless language version 'preview' or greater is used. 'T1' is covariant. + // (24,53): error CS8904: Invalid variance: The type parameter 'T1' must be contravariantly valid on 'I2.E1' unless language version '9.0' or greater is used. 'T1' is covariant. // static event System.Action> E1; - Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "E1").WithArguments("I2.E1", "T1", "covariant", "contravariantly", "preview").WithLocation(24, 53), - // (25,53): error CS8904: Invalid variance: The type parameter 'T2' must be covariantly valid on 'I2.E2' unless language version 'preview' or greater is used. 'T2' is contravariant. + Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "E1").WithArguments("I2.E1", "T1", "covariant", "contravariantly", "9.0").WithLocation(24, 53), + // (25,53): error CS8904: Invalid variance: The type parameter 'T2' must be covariantly valid on 'I2.E2' unless language version '9.0' or greater is used. 'T2' is contravariant. // static event System.Action> E2; - Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "E2").WithArguments("I2.E2", "T2", "contravariant", "covariantly", "preview").WithLocation(25, 53) + Diagnostic(ErrorCode.ERR_UnexpectedVarianceStaticMember, "E2").WithArguments("I2.E2", "T2", "contravariant", "covariantly", "9.0").WithLocation(25, 53) ); compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, - targetFramework: TargetFramework.NetCoreApp); + parseOptions: TestOptions.Regular9, + targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, verify: VerifyOnMonoOrCoreClr, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @"a diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/ExtensionMethodTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/ExtensionMethodTests.cs index d6377beb3b457..14146f5916534 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/ExtensionMethodTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/ExtensionMethodTests.cs @@ -1135,14 +1135,14 @@ static class S internal static object E(this object o) { return null; } private static object F(this object o) { return null; } }"; - var compilation = CreateCompilation(source); + var compilation = CreateCompilation(source, parseOptions: TestOptions.Regular9); compilation.VerifyDiagnostics( // (5,9): error CS1656: Cannot assign to 'E' because it is a 'method group' // o.E += o.E; Diagnostic(ErrorCode.ERR_AssgReadonlyLocalCause, "o.E").WithArguments("E", "method group").WithLocation(5, 9), - // (6,13): error CS8652: The feature 'inferred delegate type' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (6,13): error CS8773: Feature 'inferred delegate type' is not available in C# 9.0. Please use language version 10.0 or greater. // if (o.E != null) - Diagnostic(ErrorCode.ERR_FeatureInPreview, "o.E").WithArguments("inferred delegate type").WithLocation(6, 13), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "o.E").WithArguments("inferred delegate type", "10.0").WithLocation(6, 13), // (8,15): error CS1503: Argument 1: cannot convert from 'method group' to 'object' // M(o.E); Diagnostic(ErrorCode.ERR_BadArgType, "o.E").WithArguments("1", "method group", "object").WithLocation(8, 15), diff --git a/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/PreprocessorTests.cs b/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/PreprocessorTests.cs index d49b5b3e3c398..559aef0d9e5d7 100644 --- a/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/PreprocessorTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/PreprocessorTests.cs @@ -3037,9 +3037,9 @@ private void CheckDiagnosticStringFileName(string compilationFileName, string li [Theory] [InlineData(LanguageVersion.CSharp4, "4")] [InlineData(LanguageVersion.CSharp9, "9.0")] - [InlineData(LanguageVersion.Latest, "latest (9.0)")] - [InlineData(LanguageVersion.LatestMajor, "latestmajor (9.0)")] - [InlineData(LanguageVersion.Default, "default (9.0)")] + [InlineData(LanguageVersion.Latest, "latest (10.0)")] + [InlineData(LanguageVersion.LatestMajor, "latestmajor (10.0)")] + [InlineData(LanguageVersion.Default, "default (10.0)")] [InlineData(LanguageVersion.Preview, "preview")] public void TestErrorWithVersion(LanguageVersion version, string expectedLanguageVersion) { diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/DeconstructionTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/DeconstructionTests.cs index 5abc85ef9d624..c167d2bc46bc0 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/DeconstructionTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/DeconstructionTests.cs @@ -2128,12 +2128,12 @@ struct ValueTuple } }"; CreateCompilation(source, parseOptions: TestOptions.Regular9).VerifyDiagnostics( - // (7,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // (int x1, x2) = (1, 2); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(int x1, x2) = (1, 2)", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(7, 9), - // (8,9): error CS8652: The feature 'Mixed declarations and expressions in deconstruction' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // (x3, int x4) = (1, 2); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "(x3, int x4) = (1, 2)", isSuppressed: false).WithArguments("Mixed declarations and expressions in deconstruction").WithLocation(8, 9)); + // (7,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. + // (int x1, x2) = (1, 2); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(int x1, x2) = (1, 2)").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(7, 9), + // (8,9): error CS8773: Feature 'Mixed declarations and expressions in deconstruction' is not available in C# 9.0. Please use language version 10.0 or greater. + // (x3, int x4) = (1, 2); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "(x3, int x4) = (1, 2)").WithArguments("Mixed declarations and expressions in deconstruction", "10.0").WithLocation(8, 9)); } [Fact, WorkItem(12803, "https://github.com/dotnet/roslyn/issues/12803")] diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/PatternParsingTests2.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/PatternParsingTests2.cs index c5ad3311d7edb..646d55b54b899 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/PatternParsingTests2.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/PatternParsingTests2.cs @@ -24,13 +24,13 @@ public PatternParsingTests2(ITestOutputHelper output) : base(output) [Fact] public void ExtendedPropertySubpattern_01() { - UsingExpression(@"e is { a.b.c: p }"); + UsingExpression(@"e is { a.b.c: p }", TestOptions.Regular10); verify(); UsingExpression(@"e is { a.b.c: p }", TestOptions.Regular9, - // (1,8): error CS8652: The feature 'extended property patterns' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // e is { a.b.c: p } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "a.b.c").WithArguments("extended property patterns").WithLocation(1, 8)); + // (1,8): error CS8773: Feature 'extended property patterns' is not available in C# 9.0. Please use language version 10.0 or greater. + // e is { a.b.c: p } + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "a.b.c").WithArguments("extended property patterns", "10.0").WithLocation(1, 8)); verify(); void verify() diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/RecordParsing.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/RecordParsing.cs index 8a41b481ea4bf..112b273c84e92 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/RecordParsing.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/RecordParsing.cs @@ -2600,16 +2600,16 @@ public void RecordStructParsing_RecordNamedStruct() { var text = "record struct(int X, int Y);"; UsingTree(text, options: TestOptions.Regular9, - // (1,8): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,8): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // record struct(int X, int Y); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(1, 8), + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(1, 8), // (1,14): error CS1001: Identifier expected // record struct(int X, int Y); Diagnostic(ErrorCode.ERR_IdentifierExpected, "(").WithLocation(1, 14) ); verify(); - UsingTree(text, options: TestOptions.RegularPreview, + UsingTree(text, options: TestOptions.Regular10, // (1,14): error CS1001: Identifier expected // record struct(int X, int Y); Diagnostic(ErrorCode.ERR_IdentifierExpected, "(").WithLocation(1, 14) @@ -2659,14 +2659,14 @@ void verify() public void RecordStructParsing() { var text = "record struct C(int X, int Y);"; - UsingTree(text, options: TestOptions.RegularPreview); + UsingTree(text, options: TestOptions.Regular10); verifyParsedAsRecord(); UsingTree(text, options: TestOptions.Regular9, - // (1,8): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. - // record struct C(int X, int Y); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(1, 8) + // (1,8): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. + // record struct C(int X, int Y); + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(1, 8) ); verifyParsedAsRecord(); @@ -2793,7 +2793,7 @@ void verifyParsedAsRecord() public void RecordStructParsing_WithBody() { var text = "record struct C(int X, int Y) { }"; - UsingTree(text, options: TestOptions.RegularPreview); + UsingTree(text, options: TestOptions.Regular10); N(SyntaxKind.CompilationUnit); { @@ -2836,14 +2836,14 @@ public void RecordStructParsing_WithBody() public void RecordClassParsing() { var text = "record class C(int X, int Y);"; - UsingTree(text, options: TestOptions.RegularPreview); + UsingTree(text, options: TestOptions.Regular10); verifyParsedAsRecord(); UsingTree(text, options: TestOptions.Regular9, - // (1,8): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,8): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // record class C(int X, int Y); - Diagnostic(ErrorCode.ERR_FeatureInPreview, "class").WithArguments("record structs").WithLocation(1, 8) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "class").WithArguments("record structs", "10.0").WithLocation(1, 8) ); verifyParsedAsRecord(); @@ -3727,9 +3727,9 @@ public void RecordStructParsing_Ref() EOF(); UsingTree(text, options: TestOptions.Regular9, - // (1,12): error CS8652: The feature 'record structs' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,12): error CS8773: Feature 'record structs' is not available in C# 9.0. Please use language version 10.0 or greater. // ref record struct S; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "struct").WithArguments("record structs").WithLocation(1, 12) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "struct").WithArguments("record structs", "10.0").WithLocation(1, 12) ); verifyParsedAsRecord(); diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/TopLevelStatementsParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/TopLevelStatementsParsingTests.cs index 5967e1d75453b..a829a2b420bb7 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/TopLevelStatementsParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/TopLevelStatementsParsingTests.cs @@ -2582,5 +2582,70 @@ public void ConstructorLike_03() } EOF(); } + + [Fact] + public void UsingAliasTest() + { + var test = @"using s = delegate*;"; + + UsingTree(test, + // (1,11): error CS1041: Identifier expected; 'delegate' is a keyword + // using s = delegate*; + Diagnostic(ErrorCode.ERR_IdentifierExpectedKW, "delegate").WithArguments("", "delegate").WithLocation(1, 11), + // (1,25): error CS0116: A namespace cannot directly contain members such as fields or methods + // using s = delegate*; + Diagnostic(ErrorCode.ERR_NamespaceUnexpected, ">").WithLocation(1, 25) + ); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "s"); + } + N(SyntaxKind.EqualsToken); + } + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + M(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.IncompleteMember); + { + N(SyntaxKind.FunctionPointerType); + { + N(SyntaxKind.DelegateKeyword); + N(SyntaxKind.AsteriskToken); + N(SyntaxKind.FunctionPointerParameterList); + { + N(SyntaxKind.LessThanToken); + N(SyntaxKind.FunctionPointerParameter); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.VoidKeyword); + } + } + N(SyntaxKind.GreaterThanToken); + } + } + } + N(SyntaxKind.GlobalStatement); + { + N(SyntaxKind.EmptyStatement); + { + N(SyntaxKind.SemicolonToken); + } + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } } } diff --git a/src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxTreeTests.cs b/src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxTreeTests.cs index 806ada148b529..0b84004d50a4e 100644 --- a/src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxTreeTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxTreeTests.cs @@ -248,7 +248,7 @@ public void GlobalUsingDirective_01() { var test = "global using ns1;"; - UsingTree(test, TestOptions.RegularPreview); + UsingTree(test, TestOptions.Regular10); N(SyntaxKind.CompilationUnit); { @@ -273,9 +273,9 @@ public void GlobalUsingDirective_02() var test = "global using ns1;"; UsingTree(test, TestOptions.Regular9, - // (1,1): error CS8652: The feature 'global using directive' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. // global using ns1; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "global using ns1;").WithArguments("global using directive").WithLocation(1, 1) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "global using ns1;").WithArguments("global using directive", "10.0").WithLocation(1, 1) ); N(SyntaxKind.CompilationUnit); @@ -300,7 +300,7 @@ public void GlobalUsingDirective_03() { var test = "namespace ns { global using ns1; }"; - UsingTree(test, TestOptions.RegularPreview); + UsingTree(test, TestOptions.Regular10); N(SyntaxKind.CompilationUnit); { @@ -335,9 +335,9 @@ public void GlobalUsingDirective_04() var test = "namespace ns { global using ns1; }"; UsingTree(test, TestOptions.Regular9, - // (1,16): error CS8652: The feature 'global using directive' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,16): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. // namespace ns { global using ns1; } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "global using ns1;").WithArguments("global using directive").WithLocation(1, 16) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "global using ns1;").WithArguments("global using directive", "10.0").WithLocation(1, 16) ); N(SyntaxKind.CompilationUnit); @@ -372,7 +372,7 @@ public void GlobalUsingDirective_05() { var test = "global using static ns1;"; - UsingTree(test, TestOptions.RegularPreview); + UsingTree(test, TestOptions.Regular10); N(SyntaxKind.CompilationUnit); { @@ -398,9 +398,9 @@ public void GlobalUsingDirective_06() var test = "global using static ns1;"; UsingTree(test, TestOptions.Regular9, - // (1,1): error CS8652: The feature 'global using directive' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. // global using static ns1; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "global using static ns1;").WithArguments("global using directive").WithLocation(1, 1) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "global using static ns1;").WithArguments("global using directive", "10.0").WithLocation(1, 1) ); N(SyntaxKind.CompilationUnit); @@ -426,7 +426,7 @@ public void GlobalUsingDirective_07() { var test = "namespace ns { global using static ns1; }"; - UsingTree(test, TestOptions.RegularPreview); + UsingTree(test, TestOptions.Regular10); N(SyntaxKind.CompilationUnit); { @@ -462,9 +462,9 @@ public void GlobalUsingDirective_08() var test = "namespace ns { global using static ns1; }"; UsingTree(test, TestOptions.Regular9, - // (1,16): error CS8652: The feature 'global using directive' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,16): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. // namespace ns { global using static ns1; } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "global using static ns1;").WithArguments("global using directive").WithLocation(1, 16) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "global using static ns1;").WithArguments("global using directive", "10.0").WithLocation(1, 16) ); N(SyntaxKind.CompilationUnit); @@ -533,9 +533,9 @@ public void GlobalUsingDirective_10() var test = "global using alias = ns1;"; UsingTree(test, TestOptions.Regular9, - // (1,1): error CS8652: The feature 'global using directive' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,1): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. // global using alias = ns1; - Diagnostic(ErrorCode.ERR_FeatureInPreview, "global using alias = ns1;").WithArguments("global using directive").WithLocation(1, 1) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "global using alias = ns1;").WithArguments("global using directive", "10.0").WithLocation(1, 1) ); N(SyntaxKind.CompilationUnit); @@ -611,9 +611,9 @@ public void GlobalUsingDirective_12() var test = "namespace ns { global using alias = ns1; }"; UsingTree(test, TestOptions.Regular9, - // (1,16): error CS8652: The feature 'global using directive' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + // (1,16): error CS8773: Feature 'global using directive' is not available in C# 9.0. Please use language version 10.0 or greater. // namespace ns { global using alias = ns1; } - Diagnostic(ErrorCode.ERR_FeatureInPreview, "global using alias = ns1;").WithArguments("global using directive").WithLocation(1, 16) + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion9, "global using alias = ns1;").WithArguments("global using directive", "10.0").WithLocation(1, 16) ); N(SyntaxKind.CompilationUnit); diff --git a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets index 395b63a7c7d41..674e383d829b2 100644 --- a/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets +++ b/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets @@ -17,6 +17,10 @@ <_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' == '5.0' AND '$(_MaxSupportedLangVersion)' == ''">9.0 + + <_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' == '6.0' AND + '$(_MaxSupportedLangVersion)' == ''">10.0 + $(_MaxSupportedLangVersion) $(_MaxSupportedLangVersion) diff --git a/src/Compilers/Core/MSBuildTaskTests/TargetTests.cs b/src/Compilers/Core/MSBuildTaskTests/TargetTests.cs index 228d0b3c3c3b6..8cabe33d65fc8 100644 --- a/src/Compilers/Core/MSBuildTaskTests/TargetTests.cs +++ b/src/Compilers/Core/MSBuildTaskTests/TargetTests.cs @@ -399,7 +399,8 @@ public void GenerateEditorConfigCoreHandlesMalformedCompilerVisibleItemMetadata( [InlineData(".NETCoreApp", "3.0", "8.0")] [InlineData(".NETCoreApp", "3.1", "8.0")] [InlineData(".NETCoreApp", "5.0", "9.0")] - [InlineData(".NETCoreApp", "6.0", "")] + [InlineData(".NETCoreApp", "6.0", "10.0")] + [InlineData(".NETCoreApp", "7.0", "")] [InlineData(".NETStandard", "1.0", "7.3")] [InlineData(".NETStandard", "1.5", "7.3")] @@ -408,6 +409,7 @@ public void GenerateEditorConfigCoreHandlesMalformedCompilerVisibleItemMetadata( [InlineData("UnknownTFM", "0.0", "7.3")] [InlineData("UnknownTFM", "5.0", "7.3")] + [InlineData("UnknownTFM", "6.0", "7.3")] public void LanguageVersionGivenTargetFramework(string tfi, string tfv, string expectedVersion) { XmlReader xmlReader = XmlReader.Create(new StringReader($@" @@ -432,7 +434,7 @@ public void LanguageVersionGivenTargetFramework(string tfi, string tfv, string e // This will fail whenever the current language version is updated. // Ensure you update the target files to select the correct CSharp version for the newest target framework // and add to the theory data above to cover it, before changing this version to make the test pass again. - Assert.Equal(CSharp.LanguageVersion.CSharp9, CSharp.LanguageVersionFacts.CurrentVersion); + Assert.Equal(CSharp.LanguageVersion.CSharp10, CSharp.LanguageVersionFacts.CurrentVersion); } [Fact] diff --git a/src/Compilers/Core/Portable/InternalUtilities/IsExternalInit.cs b/src/Compilers/Core/Portable/InternalUtilities/IsExternalInit.cs index 19138060ce89d..7d1e003609644 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/IsExternalInit.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/IsExternalInit.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Compilers/Core/Portable/InternalUtilities/SpanUtilities.cs b/src/Compilers/Core/Portable/InternalUtilities/SpanUtilities.cs index 98b512186e329..78b7a1d66c43d 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/SpanUtilities.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/SpanUtilities.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.ConditionalAccessOperationTracker.cs b/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.ConditionalAccessOperationTracker.cs index d51ad4e5303cf..f3f77c8bfdb6c 100644 --- a/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.ConditionalAccessOperationTracker.cs +++ b/src/Compilers/Core/Portable/Operations/ControlFlowGraphBuilder.ConditionalAccessOperationTracker.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Compilers/Core/Portable/Operations/Operation.Enumerable.cs b/src/Compilers/Core/Portable/Operations/Operation.Enumerable.cs index 84e466976926e..a0e1ef8b253dd 100644 --- a/src/Compilers/Core/Portable/Operations/Operation.Enumerable.cs +++ b/src/Compilers/Core/Portable/Operations/Operation.Enumerable.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Compilers/Core/Portable/Operations/OperationMapBuilder.cs b/src/Compilers/Core/Portable/Operations/OperationMapBuilder.cs index e3beda6e9cfb3..7a31dcb0fcc12 100644 --- a/src/Compilers/Core/Portable/Operations/OperationMapBuilder.cs +++ b/src/Compilers/Core/Portable/Operations/OperationMapBuilder.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs b/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs index 1c115f3ff7428..00de9e50f7780 100644 --- a/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs +++ b/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs @@ -876,7 +876,7 @@ public static SyntaxTree Parse(string text, string filename = "", CSharpParseOpt { if ((object)options == null) { - options = TestOptions.Regular; + options = TestOptions.RegularPreview; } var stringText = StringText.From(text, encoding ?? Encoding.UTF8); @@ -1121,7 +1121,7 @@ private static CSharpCompilation CreateCompilationCore( if (experimentalFeature.HasValue) { - parseOptions = (parseOptions ?? TestOptions.Regular).WithExperimental(experimentalFeature.Value); + parseOptions = (parseOptions ?? TestOptions.RegularPreview).WithExperimental(experimentalFeature.Value); } Func createCompilationLambda = () => CSharpCompilation.Create( diff --git a/src/Compilers/Test/Utilities/CSharp/TestOptions.cs b/src/Compilers/Test/Utilities/CSharp/TestOptions.cs index e5bba5b842d74..9dcee21970d7c 100644 --- a/src/Compilers/Test/Utilities/CSharp/TestOptions.cs +++ b/src/Compilers/Test/Utilities/CSharp/TestOptions.cs @@ -23,9 +23,17 @@ public static class TestOptions public static readonly CSharpParseOptions Regular7_2 = Regular.WithLanguageVersion(LanguageVersion.CSharp7_2); public static readonly CSharpParseOptions Regular7_3 = Regular.WithLanguageVersion(LanguageVersion.CSharp7_3); public static readonly CSharpParseOptions RegularDefault = Regular.WithLanguageVersion(LanguageVersion.Default); + + /// + /// Usages of and + /// will be replaced with TestOptions.RegularN and LanguageVersion.CSharpN when language version N is introduced. + /// + public static readonly CSharpParseOptions RegularNext = Regular.WithLanguageVersion(LanguageVersion.Preview); + public static readonly CSharpParseOptions RegularPreview = Regular.WithLanguageVersion(LanguageVersion.Preview); public static readonly CSharpParseOptions Regular8 = Regular.WithLanguageVersion(LanguageVersion.CSharp8); public static readonly CSharpParseOptions Regular9 = Regular.WithLanguageVersion(LanguageVersion.CSharp9); + public static readonly CSharpParseOptions Regular10 = Regular.WithLanguageVersion(LanguageVersion.CSharp10); public static readonly CSharpParseOptions RegularWithDocumentationComments = Regular.WithDocumentationMode(DocumentationMode.Diagnose); public static readonly CSharpParseOptions RegularWithLegacyStrongName = Regular.WithFeature("UseLegacyStrongNameProvider"); public static readonly CSharpParseOptions WithoutImprovedOverloadCandidates = Regular.WithLanguageVersion(MessageID.IDS_FeatureImprovedOverloadCandidates.RequiredVersion() - 1); diff --git a/src/Compilers/VisualBasic/Portable/Symbols/SynthesizedSymbols/SynthesizedClonedTypeParameterSymbol.vb b/src/Compilers/VisualBasic/Portable/Symbols/SynthesizedSymbols/SynthesizedClonedTypeParameterSymbol.vb index 85122d83b1244..d7a9a545059da 100644 --- a/src/Compilers/VisualBasic/Portable/Symbols/SynthesizedSymbols/SynthesizedClonedTypeParameterSymbol.vb +++ b/src/Compilers/VisualBasic/Portable/Symbols/SynthesizedSymbols/SynthesizedClonedTypeParameterSymbol.vb @@ -45,6 +45,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols _correspondingMethodTypeParameter = correspondingMethodTypeParameter _name = name _typeMapFactory = typeMapFactory + + Debug.Assert(Me.TypeParameterKind = If(TypeOf Me.ContainingSymbol Is MethodSymbol, TypeParameterKind.Method, + If(TypeOf Me.ContainingSymbol Is NamedTypeSymbol, TypeParameterKind.Type, + TypeParameterKind.Cref)), + $"Container is {Me.ContainingSymbol?.Kind}, TypeParameterKind is {Me.TypeParameterKind}") End Sub Public Overrides ReadOnly Property TypeParameterKind As TypeParameterKind diff --git a/src/Compilers/VisualBasic/Portable/Symbols/Wrapped/WrappedTypeParameterSymbol.vb b/src/Compilers/VisualBasic/Portable/Symbols/Wrapped/WrappedTypeParameterSymbol.vb index c9cc775bfcd3d..a98e82937f542 100644 --- a/src/Compilers/VisualBasic/Portable/Symbols/Wrapped/WrappedTypeParameterSymbol.vb +++ b/src/Compilers/VisualBasic/Portable/Symbols/Wrapped/WrappedTypeParameterSymbol.vb @@ -88,6 +88,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols Public Sub New(underlyingTypeParameter As TypeParameterSymbol) Debug.Assert(underlyingTypeParameter IsNot Nothing) Me._underlyingTypeParameter = underlyingTypeParameter + + Debug.Assert(Me.TypeParameterKind = If(TypeOf Me.ContainingSymbol Is MethodSymbol, TypeParameterKind.Method, + If(TypeOf Me.ContainingSymbol Is NamedTypeSymbol, TypeParameterKind.Type, + TypeParameterKind.Cref)), + $"Container is {Me.ContainingSymbol?.Kind}, TypeParameterKind is {Me.TypeParameterKind}") End Sub Public Overrides Function GetDocumentationCommentXml(Optional preferredCulture As CultureInfo = Nothing, Optional expandIncludes As Boolean = False, Optional cancellationToken As CancellationToken = Nothing) As String diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs index 53caa05b1a1f1..5064e21e7967d 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs @@ -1001,7 +1001,7 @@ interface I2 static T1 M1([|T1|] x) => x; } ", - expected: LanguageVersion.Preview, + expected: LanguageVersion.CSharp9, new CSharpParseOptions(LanguageVersion.CSharp8)); } @@ -1011,13 +1011,13 @@ public async Task UpgradeProjectForSealedToStringInRecords_CS8912() await TestLanguageVersionUpgradedAsync( @" - + Assembly2 record [|Derived|] : Base; - + public record Base { @@ -1027,7 +1027,29 @@ public record Base ", - expected: LanguageVersion.Preview, + expected: LanguageVersion.CSharp10, + new CSharpParseOptions(LanguageVersion.CSharp9)); + } + + [Fact] + public async Task UpgradeProjectForTargetTypedNew() + { + await TestLanguageVersionUpgradedAsync(@" +class Test +{ + Test t = [|new()|]; +}", + LanguageVersion.CSharp9, + new CSharpParseOptions(LanguageVersion.CSharp8)); + } + + [Fact] + public async Task UpgradeProjectForGlobalUsing() + { + await TestLanguageVersionUpgradedAsync(@" +[|global using System;|] +", + LanguageVersion.CSharp10, new CSharpParseOptions(LanguageVersion.CSharp9)); } } diff --git a/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs b/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs index d98d0765b424d..ea89267c08658 100644 --- a/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs +++ b/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs @@ -7335,6 +7335,50 @@ void M2() MainDescription($"({FeaturesResources.local_variable}) string? x")); } + [WorkItem(53135, "https://github.com/dotnet/roslyn/issues/53135")] + [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)] + public async Task TestDocumentationCData() + { + var markup = +@"using I$$ = IGoo; +/// +/// summary for interface IGoo +/// y = null; +/// ]]> +/// +interface IGoo { }"; + + await TestAsync(markup, + MainDescription("interface IGoo"), + Documentation(@"summary for interface IGoo + +List y = null;")); + } + + [WorkItem(37503, "https://github.com/dotnet/roslyn/issues/37503")] + [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)] + public async Task DoNotNormalizeWhitespaceForCode() + { + var markup = +@"using I$$ = IGoo; +/// +/// Normalize this, and Also this +/// +/// line 1 +/// line 2 +/// +/// +interface IGoo { }"; + + await TestAsync(markup, + MainDescription("interface IGoo"), + Documentation(@"Normalize this, and Also this + +line 1 +line 2")); + } + [Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)] public async Task TestStaticAbstract_ImplicitImplementation() { diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/IVSTypeScriptFormattingInteractionService.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/IVSTypeScriptFormattingInteractionService.cs index bdcff8b3229bc..8b6f154e38c29 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/IVSTypeScriptFormattingInteractionService.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/IVSTypeScriptFormattingInteractionService.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFormattingInteractionService.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFormattingInteractionService.cs index d4b2ab1481110..6a6bb7990ca23 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFormattingInteractionService.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFormattingInteractionService.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs b/src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs index 9a23741881b7d..3d8d8e9e73134 100644 --- a/src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs +++ b/src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs @@ -50,7 +50,7 @@ public void ExampleAndCodeTags() results in p's having the value (2,8). "; - var expected = "This method changes the point's location by the given x- and y-offsets. For example:\r\n\r\nPoint p = new Point(3,5); p.Translate(-1,3);\r\n\r\nresults in p's having the value (2,8)."; + var expected = "This method changes the point's location by the given x- and y-offsets. For example:\r\n\r\n Point p = new Point(3,5);\r\n p.Translate(-1,3);\r\n \r\n\r\nresults in p's having the value (2,8)."; TestFormat(comment, expected); } diff --git a/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs b/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs index cb59f140b4de9..fc2368f442f1f 100644 --- a/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs +++ b/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs @@ -3087,5 +3087,33 @@ public class TestType var metadataAsSourceFile = await context.GenerateSourceAsync(navigationSymbol); TestContext.VerifyResult(metadataAsSourceFile, expected); } + + [WorkItem(22431, "https://github.com/dotnet/roslyn/issues/22431")] + [Fact, Trait(Traits.Feature, Traits.Features.MetadataAsSource)] + public async Task TestCDATAComment() + { + var source = @" +public enum BinaryOperatorKind +{ + /// + /// Represents the operator. + /// + LeftShift = 0x8, +} +"; + var symbolName = "BinaryOperatorKind.LeftShift"; + var expectedCS = $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null +// {CodeAnalysisResources.InMemoryAssembly} +#endregion + +public enum BinaryOperatorKind +{{ + // + // {FeaturesResources.Summary_colon} + // Represents the '<<' operator. + [|LeftShift|] = 8 +}}"; + await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.CSharp, expectedCS, includeXmlDocComments: true); + } } } diff --git a/src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests_Code.vb b/src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests_Code.vb new file mode 100644 index 0000000000000..25d531e754130 --- /dev/null +++ b/src/EditorFeatures/Test2/IntelliSense/IntellisenseQuickInfoBuilderTests_Code.vb @@ -0,0 +1,113 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports Microsoft.CodeAnalysis.Classification +Imports Microsoft.CodeAnalysis.Test.Utilities.QuickInfo +Imports Microsoft.VisualStudio.Core.Imaging +Imports Microsoft.VisualStudio.Imaging +Imports Microsoft.VisualStudio.Text.Adornments + +Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense + Public Class IntellisenseQuickInfoBuilderTests_Code + Inherits AbstractIntellisenseQuickInfoBuilderTests + + Public Async Function QuickInfoForXmlCodeElementWithCDATA() As Task + Dim workspace = + + + + class MyClass { + /// <summary> + /// summary for MyClass + /// <code><![CDATA[ + /// List<string> y = null; + /// ]]></code> + /// </summary> + void MyMethod() { + MyM$$ethod(); + } + } + + + + + Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp) + + Dim expected = New ContainerElement( + ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding, + New ContainerElement( + ContainerElementStyle.Stacked, + New ContainerElement( + ContainerElementStyle.Wrapped, + New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.MethodPrivate)), + New ClassifiedTextElement( + New ClassifiedTextRun(ClassificationTypeNames.Keyword, "void"), + New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "), + New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"), + New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "."), + New ClassifiedTextRun(ClassificationTypeNames.MethodName, "MyMethod", navigationAction:=Sub() Return, "void MyClass.MyMethod()"), + New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "("), + New ClassifiedTextRun(ClassificationTypeNames.Punctuation, ")"))), + New ClassifiedTextElement( + New ClassifiedTextRun(ClassificationTypeNames.Text, "summary for MyClass"))), + New ClassifiedTextElement( + New ClassifiedTextRun(ClassificationTypeNames.Text, "List y = null;", ClassifiedTextRunStyle.UseClassificationFont))) + + ToolTipAssert.EqualContent(expected, intellisenseQuickInfo.Item) + End Function + + + Public Async Function QuickInfoForXmlCodeElement() As Task + Dim workspace = + + + + class MyClass { + /// <summary> + /// Normalize this, <c>and also + /// this</c> + /// <code> + /// line 1 + /// line 2 + /// </code> + /// Extra text after code. + /// </summary> + void MyMethod() { + MyM$$ethod(); + } + } + + + + + Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp) + + Dim expected = New ContainerElement( + ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding, + New ContainerElement( + ContainerElementStyle.Stacked, + New ContainerElement( + ContainerElementStyle.Wrapped, + New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.MethodPrivate)), + New ClassifiedTextElement( + New ClassifiedTextRun(ClassificationTypeNames.Keyword, "void"), + New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "), + New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"), + New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "."), + New ClassifiedTextRun(ClassificationTypeNames.MethodName, "MyMethod", navigationAction:=Sub() Return, "void MyClass.MyMethod()"), + New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "("), + New ClassifiedTextRun(ClassificationTypeNames.Punctuation, ")"))), + New ClassifiedTextElement( + New ClassifiedTextRun(ClassificationTypeNames.Text, "Normalize this,"), + New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "), + New ClassifiedTextRun(ClassificationTypeNames.Text, "and also this", ClassifiedTextRunStyle.UseClassificationFont))), + New ClassifiedTextElement( + New ClassifiedTextRun(ClassificationTypeNames.Text, $"line 1{vbCrLf}line 2", ClassifiedTextRunStyle.UseClassificationFont)), + New ClassifiedTextElement( + New ClassifiedTextRun(ClassificationTypeNames.Text, "Extra text after code."))) + + ToolTipAssert.EqualContent(expected, intellisenseQuickInfo.Item) + End Function + End Class +End Namespace diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs index de45ef9551757..604bfbce2c7b8 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.cs @@ -8,6 +8,7 @@ using Roslyn.Utilities; using System; using System.Collections.Immutable; +using System.Diagnostics; namespace Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator { @@ -25,6 +26,11 @@ public SimpleTypeParameterSymbol(Symbol container, int ordinal, string name) _container = container; _ordinal = ordinal; _name = name; + + Debug.Assert(this.TypeParameterKind == (ContainingSymbol is MethodSymbol ? TypeParameterKind.Method : + (ContainingSymbol is NamedTypeSymbol ? TypeParameterKind.Type : + TypeParameterKind.Cref)), + $"Container is {ContainingSymbol?.Kind}, TypeParameterKind is {this.TypeParameterKind}"); } public override string Name @@ -39,7 +45,7 @@ public override int Ordinal public override TypeParameterKind TypeParameterKind { - get { return TypeParameterKind.Type; } + get { return ContainingSymbol is MethodSymbol ? TypeParameterKind.Method : TypeParameterKind.Type; } } public override bool HasConstructorConstraint diff --git a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb index 6ac0b20075f3a..19b822a4c7a74 100644 --- a/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb +++ b/src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Symbols/SimpleTypeParameterSymbol.vb @@ -21,6 +21,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator _container = container _ordinal = ordinal _name = name + + Debug.Assert(Me.TypeParameterKind = If(TypeOf Me.ContainingSymbol Is MethodSymbol, TypeParameterKind.Method, + If(TypeOf Me.ContainingSymbol Is NamedTypeSymbol, TypeParameterKind.Type, + TypeParameterKind.Cref)), + $"Container is {Me.ContainingSymbol?.Kind}, TypeParameterKind is {Me.TypeParameterKind}") End Sub Public Overrides ReadOnly Property Name As String @@ -37,7 +42,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator Public Overrides ReadOnly Property TypeParameterKind As TypeParameterKind Get - Return TypeParameterKind.Type + Return If(TypeOf Me.ContainingSymbol Is MethodSymbol, TypeParameterKind.Method, TypeParameterKind.Type) End Get End Property diff --git a/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs b/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs index b79e74ef15c73..beea4f23e74d8 100644 --- a/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs @@ -43,6 +43,7 @@ public CSharpUpgradeProjectCodeFixProvider() "CS8511", // error CS8511: An expression of type 'T' cannot be handled by a pattern of type ''. Please use language version 'preview' or greater to match an open type with a constant pattern. "CS8627", // error CS8627: A nullable type parameter must be known to be a value type or non-nullable reference type unless language version '{0}' or greater is used. Consider changing the language version or adding a 'class', 'struct', or type constraint. "CS8652", // error CS8652: The feature '' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. + "CS8773", // error CS8773: Feature is not available in C# 9.0. Please use language version X or greater. "CS8703", // error CS8703: The modifier '{0}' is not valid for this item in C# {1}. Please use language version '{2}' or greater. "CS8706", // error CS8706: '{0}' cannot implement interface member '{1}' in type '{2}' because feature '{3}' is not available in C# {4}. Please use language version '{5}' or greater. "CS8904", // error CS8904: Invalid variance: The type parameter 'T1' must be contravariantly valid on 'I2.M1(T1)' unless language version 'preview' or greater is used. 'T1' is covariant. diff --git a/src/Features/Core/Portable/CodeCleanup/DiagnosticSet.cs b/src/Features/Core/Portable/CodeCleanup/DiagnosticSet.cs index 79843492db80d..29fd7b4dbd97e 100644 --- a/src/Features/Core/Portable/CodeCleanup/DiagnosticSet.cs +++ b/src/Features/Core/Portable/CodeCleanup/DiagnosticSet.cs @@ -21,4 +21,4 @@ public DiagnosticSet(string description, params string[] diagnosticIds) DiagnosticIds = ImmutableArray.Create(diagnosticIds); } } -} \ No newline at end of file +} diff --git a/src/Features/Core/Portable/Common/TaggedTextStyle.cs b/src/Features/Core/Portable/Common/TaggedTextStyle.cs index cf7a756e86aad..4440b13bb3434 100644 --- a/src/Features/Core/Portable/Common/TaggedTextStyle.cs +++ b/src/Features/Core/Portable/Common/TaggedTextStyle.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable disable - using System; namespace Microsoft.CodeAnalysis @@ -13,12 +11,14 @@ internal enum TaggedTextStyle { None = 0, - Strong = 0x1, + Strong = 1 << 0, + + Emphasis = 1 << 1, - Emphasis = 0x2, + Underline = 1 << 2, - Underline = 0x4, + Code = 1 << 3, - Code = 0x8, + PreserveWhitespace = 1 << 4, } } diff --git a/src/Features/Core/Portable/DocumentationComments/AbstractDocumentationCommentFormattingService.cs b/src/Features/Core/Portable/DocumentationComments/AbstractDocumentationCommentFormattingService.cs index 3714fea91d5ef..03c637fc424b9 100644 --- a/src/Features/Core/Portable/DocumentationComments/AbstractDocumentationCommentFormattingService.cs +++ b/src/Features/Core/Portable/DocumentationComments/AbstractDocumentationCommentFormattingService.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using System.Xml; using System.Xml.Linq; @@ -102,10 +103,14 @@ public void AppendSingleSpace() public void AppendString(string s) { EmitPendingChars(); - - Builder.Add(new TaggedText(TextTags.Text, s, Style, NavigationTarget.target, NavigationTarget.hint)); + Builder.Add(new TaggedText(TextTags.Text, NormalizeLineEndings(s), Style, NavigationTarget.target, NavigationTarget.hint)); _anyNonWhitespaceSinceLastPara = true; + + // XText.Value returns a string with `\n` as the line endings, causing + // the end result to have mixed line-endings. So normalize everything to `\r\n`. + // https://www.w3.org/TR/xml/#sec-line-ends + static string NormalizeLineEndings(string input) => input.Replace("\n", "\r\n"); } public void AppendParts(IEnumerable parts) @@ -305,8 +310,9 @@ public ImmutableArray Format(string rawXmlText, ISymbol symbol, Sema private static void AppendTextFromNode(FormatterState state, XNode node, Compilation compilation) { - if (node.NodeType == XmlNodeType.Text) + if (node.NodeType is XmlNodeType.Text or XmlNodeType.CDATA) { + // cast is safe since XCData inherits XText AppendTextFromTextNode(state, (XText)node); } @@ -354,13 +360,16 @@ DocumentationCommentXmlNames.SeeAlsoElementName or return; } - else if (name is DocumentationCommentXmlNames.CElementName - or DocumentationCommentXmlNames.CodeElementName - or "tt") + else if (name is DocumentationCommentXmlNames.CElementName or "tt") { needPopStyle = true; state.PushStyle(TaggedTextStyle.Code); } + else if (name is DocumentationCommentXmlNames.CodeElementName) + { + needPopStyle = true; + state.PushStyle(TaggedTextStyle.Code | TaggedTextStyle.PreserveWhitespace); + } else if (name is "em" or "i") { needPopStyle = true; @@ -550,6 +559,13 @@ private static string TrimCrefPrefix(string value) private static void AppendTextFromTextNode(FormatterState state, XText element) { var rawText = element.Value; + if ((state.Style & TaggedTextStyle.PreserveWhitespace) == TaggedTextStyle.PreserveWhitespace) + { + // Don't normalize code from middle. Only trim leading/trailing new lines. + state.AppendString(rawText.Trim('\n')); + return; + } + var builder = new StringBuilder(rawText.Length); // Normalize the whitespace. diff --git a/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs b/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs index c06f04b943495..fe8226cce6929 100644 --- a/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs +++ b/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs @@ -169,11 +169,11 @@ private void AddDocumentationContent(ISymbol symbol) _documentationMap.Add( SymbolDescriptionGroups.Documentation, - symbol.GetDocumentationParts(_semanticModel, _position, formatter, CancellationToken).ToImmutableArray()); + symbol.GetDocumentationParts(_semanticModel, _position, formatter, CancellationToken)); _documentationMap.Add( SymbolDescriptionGroups.RemarksDocumentation, - symbol.GetRemarksDocumentationParts(_semanticModel, _position, formatter, CancellationToken).ToImmutableArray()); + symbol.GetRemarksDocumentationParts(_semanticModel, _position, formatter, CancellationToken)); AddReturnsDocumentationParts(symbol, formatter); AddValueDocumentationParts(symbol, formatter); diff --git a/src/Features/Core/Portable/MetadataAsSource/MetadataAsSourceFileService.cs b/src/Features/Core/Portable/MetadataAsSource/MetadataAsSourceFileService.cs index d3187efe61d82..b05633d3cf97f 100644 --- a/src/Features/Core/Portable/MetadataAsSource/MetadataAsSourceFileService.cs +++ b/src/Features/Core/Portable/MetadataAsSource/MetadataAsSourceFileService.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpCodeCleanupFixerProvider.cs b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpCodeCleanupFixerProvider.cs index 93823b5ae6970..45b98a5af483a 100644 --- a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpCodeCleanupFixerProvider.cs +++ b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpCodeCleanupFixerProvider.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -26,4 +26,4 @@ public CSharpCodeCleanUpFixerProvider( { } } -} \ No newline at end of file +} diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ManagedEditAndContinueLanguageService.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ManagedEditAndContinueLanguageService.cs index 663e1bc86c070..10f0351999e98 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ManagedEditAndContinueLanguageService.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/ManagedEditAndContinueLanguageService.cs @@ -186,9 +186,15 @@ public async Task HasChangesAsync(string? sourceFilePath, CancellationToke { try { + var debuggingSession = _debuggingSession; + if (debuggingSession == null) + { + return false; + } + var solution = GetCurrentCompileTimeSolution(); var activeStatementSpanProvider = GetActiveStatementSpanProvider(solution); - return await GetDebuggingSession().HasChangesAsync(solution, activeStatementSpanProvider, sourceFilePath, cancellationToken).ConfigureAwait(false); + return await debuggingSession.HasChangesAsync(solution, activeStatementSpanProvider, sourceFilePath, cancellationToken).ConfigureAwait(false); } catch (Exception e) when (FatalError.ReportAndCatchUnlessCanceled(e, cancellationToken)) { diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs index 93cc436b09872..5c8b43b3f2553 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs @@ -101,6 +101,8 @@ internal abstract partial class VisualStudioWorkspaceImpl : VisualStudioWorkspac [Obsolete("This is a compatibility shim for TypeScript; please do not use it.")] internal VisualStudioProjectTracker? _projectTracker; + private VirtualMemoryNotificationListener? _memoryListener; + private OpenFileTracker? _openFileTracker; internal FileChangeWatcher FileChangeWatcher { get; } internal FileWatchedPortableExecutableReferenceFactory FileWatchedReferenceFactory { get; } @@ -204,6 +206,14 @@ public async Task InitializeUIAffinitizedServicesAsync(IAsyncServiceProvider asy _openFileTracker = openFileTracker; } + var memoryListener = await VirtualMemoryNotificationListener.CreateAsync(this, _threadingContext, asyncServiceProvider, _threadingContext.DisposalToken).ConfigureAwait(true); + + // Update our fields first, so any asynchronous work that needs to use these is able to see the service. + lock (_gate) + { + _memoryListener = memoryListener; + } + openFileTracker.ProcessQueuedWorkOnUIThread(); } diff --git a/src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs b/src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs index 198cc448de094..9113ca6b9c011 100644 --- a/src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs +++ b/src/VisualStudio/Core/Def/Implementation/VirtualMemoryNotificationListener.cs @@ -2,26 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable disable - using System; -using System.Composition; using System.Runtime; +using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Shared.Options; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Internal.Log; -using Microsoft.CodeAnalysis.Remote; using Microsoft.CodeAnalysis.Shared.Options; using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.VisualStudio.LanguageServices.Implementation; using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; -using Microsoft.VisualStudio.LanguageServices.Remote; -using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; +using IAsyncServiceProvider = Microsoft.VisualStudio.Shell.IAsyncServiceProvider; namespace Microsoft.VisualStudio.LanguageServices { @@ -29,7 +25,6 @@ namespace Microsoft.VisualStudio.LanguageServices /// Listens to broadcast notifications from the Visual Studio Shell indicating that the application is running /// low on available virtual memory. /// - [Export, Shared] internal sealed class VirtualMemoryNotificationListener : ForegroundThreadAffinitizedObject, IVsBroadcastMessageEvents { // memory threshold to turn off full solution analysis - 200MB @@ -39,15 +34,13 @@ internal sealed class VirtualMemoryNotificationListener : ForegroundThreadAffini private const string LowVMMoreInfoLink = "https://go.microsoft.com/fwlink/?LinkID=799402&clcid=0x409"; private readonly VisualStudioWorkspace _workspace; - private readonly WorkspaceCacheService _workspaceCacheService; + private readonly WorkspaceCacheService? _workspaceCacheService; private bool _alreadyLogged; - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public VirtualMemoryNotificationListener( + private VirtualMemoryNotificationListener( IThreadingContext threadingContext, - SVsServiceProvider serviceProvider, + IVsShell shell, VisualStudioWorkspace workspace) : base(threadingContext, assertIsForeground: true) { @@ -63,11 +56,20 @@ public VirtualMemoryNotificationListener( _workspace.WorkspaceChanged += OnWorkspaceChanged; - var shell = (IVsShell)serviceProvider.GetService(typeof(SVsShell)); // Note: We never unhook this event sink. It lives for the lifetime of the host. ErrorHandler.ThrowOnFailure(shell.AdviseBroadcastMessages(this, out var cookie)); } + public static async Task CreateAsync(VisualStudioWorkspace workspace, IThreadingContext threadingContext, IAsyncServiceProvider serviceProvider, CancellationToken cancellationToken) + { + await threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); + + var shell = (IVsShell?)await serviceProvider.GetServiceAsync(typeof(SVsShell)).ConfigureAwait(true); + Assumes.Present(shell); + + return new VirtualMemoryNotificationListener(threadingContext, shell, workspace); + } + /// /// Called by the Visual Studio Shell to notify components of a broadcast message. /// @@ -149,7 +151,7 @@ private void ShowInfoBarIfRequired() } // Show info bar. - _workspace.Services.GetService() + _workspace.Services.GetRequiredService() .ShowGlobalErrorInfo(ServicesVSResources.Visual_Studio_has_suspended_some_advanced_features_to_improve_performance, new InfoBarUI(ServicesVSResources.Re_enable, InfoBarUI.UIKind.Button, RenableBackgroundAnalysis), new InfoBarUI(ServicesVSResources.Learn_more, InfoBarUI.UIKind.HyperLink, diff --git a/src/VisualStudio/Core/Def/RoslynPackage.cs b/src/VisualStudio/Core/Def/RoslynPackage.cs index d2a635800c20f..c28ba4669a1bb 100644 --- a/src/VisualStudio/Core/Def/RoslynPackage.cs +++ b/src/VisualStudio/Core/Def/RoslynPackage.cs @@ -184,7 +184,6 @@ protected override async Task LoadComponentsAsync(CancellationToken cancellation this.ComponentModel.GetService().Initialize(this); this.ComponentModel.GetService(); - this.ComponentModel.GetService(); // The misc files workspace needs to be loaded on the UI thread. This way it will have // the appropriate task scheduler to report events on. diff --git a/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicCodeCleanupFixerProvider.vb b/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicCodeCleanupFixerProvider.vb index d1df51e52f392..850c805e40da7 100644 --- a/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicCodeCleanupFixerProvider.vb +++ b/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicCodeCleanupFixerProvider.vb @@ -1,4 +1,4 @@ -' Licensed to the .NET Foundation under one or more agreements. +' Licensed to the .NET Foundation under one or more agreements. ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. @@ -23,4 +23,4 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.CodeCleanup MyBase.New(codeCleanUpFixers) End Sub End Class -End Namespace \ No newline at end of file +End Namespace diff --git a/src/Workspaces/Core/MSBuild/MSBuild/Build/ProjectBuildManager.cs b/src/Workspaces/Core/MSBuild/MSBuild/Build/ProjectBuildManager.cs index f1c98c4de478f..d08e55cfcf188 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/Build/ProjectBuildManager.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/Build/ProjectBuildManager.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker_ResolveReferences.cs b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker_ResolveReferences.cs index cd64608f7bc44..5b1c167ea3511 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker_ResolveReferences.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker_ResolveReferences.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.cs b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.cs index ad504f88f359a..2f323d373ff82 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Workspaces/Core/MSBuild/MSBuild/ProjectFile/Extensions.cs b/src/Workspaces/Core/MSBuild/MSBuild/ProjectFile/Extensions.cs index eec1823393a06..a21ee61b0a180 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/ProjectFile/Extensions.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/ProjectFile/Extensions.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Workspaces/Core/MSBuild/MSBuild/ProjectMap.cs b/src/Workspaces/Core/MSBuild/MSBuild/ProjectMap.cs index cae640133d341..242809c13f33d 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/ProjectMap.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/ProjectMap.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/LanguageVersionExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/LanguageVersionExtensions.cs index 7c1df6fa80aa5..65ca1c846c9ce 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/LanguageVersionExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/LanguageVersionExtensions.cs @@ -10,7 +10,7 @@ public static bool IsCSharp9OrAbove(this LanguageVersion languageVersion) => languageVersion >= LanguageVersion.CSharp9; public static bool IsCSharp10OrAbove(this LanguageVersion languageVersion) - => languageVersion >= LanguageVersion.Preview; + => languageVersion >= LanguageVersion.CSharp10; public static bool HasConstantInterpolatedStrings(this LanguageVersion languageVersion) => languageVersion.IsCSharp10OrAbove();