diff --git a/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs index f4a4dc875446b..7f0b096a860f5 100644 --- a/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs @@ -186,8 +186,8 @@ private static async Task ExpandUsingDirectivesAsync( private static async Task ExpandUsingDirectiveAsync(Document document, UsingDirectiveSyntax usingDirective, CancellationToken cancellationToken) { - var newType = await Simplifier.ExpandAsync(usingDirective.Type, document, cancellationToken: cancellationToken).ConfigureAwait(false); - return usingDirective.WithType(newType); + var newType = await Simplifier.ExpandAsync(usingDirective.NamespaceOrType, document, cancellationToken: cancellationToken).ConfigureAwait(false); + return usingDirective.WithNamespaceOrType(newType); } private static CompilationUnitSyntax MoveUsingsInsideNamespace(CompilationUnitSyntax compilationUnit) diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs index 634cc150fb6d9..05671a5113c2e 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs @@ -1000,7 +1000,7 @@ private NamedTypeSymbol BindNativeIntegerSymbolIfAny(IdentifierNameSyntax node, case AttributeSyntax parent when parent.Name == node: // [nint] return null; case UsingDirectiveSyntax usingDirective: - if (usingDirective.Alias != null && usingDirective.Type == node) + if (usingDirective.Alias != null && usingDirective.NamespaceOrType == node) { // legal to write `using A = nuint;` as long as using-alias-to-type is enabled (checked later). break; diff --git a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs index cb68f09282757..86aebe43ffe7c 100644 --- a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Internal.Generated.cs @@ -19666,10 +19666,10 @@ internal sealed partial class UsingDirectiveSyntax : CSharpSyntaxNode internal readonly SyntaxToken? staticKeyword; internal readonly SyntaxToken? unsafeKeyword; internal readonly NameEqualsSyntax? alias; - internal readonly TypeSyntax type; + internal readonly TypeSyntax namespaceOrType; internal readonly SyntaxToken semicolonToken; - internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax type, SyntaxToken semicolonToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) + internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax namespaceOrType, SyntaxToken semicolonToken, DiagnosticInfo[]? diagnostics, SyntaxAnnotation[]? annotations) : base(kind, diagnostics, annotations) { this.SlotCount = 7; @@ -19695,13 +19695,13 @@ internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, Synta this.AdjustFlagsAndWidth(alias); this.alias = alias; } - this.AdjustFlagsAndWidth(type); - this.type = type; + this.AdjustFlagsAndWidth(namespaceOrType); + this.namespaceOrType = namespaceOrType; this.AdjustFlagsAndWidth(semicolonToken); this.semicolonToken = semicolonToken; } - internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax type, SyntaxToken semicolonToken, SyntaxFactoryContext context) + internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax namespaceOrType, SyntaxToken semicolonToken, SyntaxFactoryContext context) : base(kind) { this.SetFactoryContext(context); @@ -19728,13 +19728,13 @@ internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, Synta this.AdjustFlagsAndWidth(alias); this.alias = alias; } - this.AdjustFlagsAndWidth(type); - this.type = type; + this.AdjustFlagsAndWidth(namespaceOrType); + this.namespaceOrType = namespaceOrType; this.AdjustFlagsAndWidth(semicolonToken); this.semicolonToken = semicolonToken; } - internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax type, SyntaxToken semicolonToken) + internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax namespaceOrType, SyntaxToken semicolonToken) : base(kind) { this.SlotCount = 7; @@ -19760,8 +19760,8 @@ internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, Synta this.AdjustFlagsAndWidth(alias); this.alias = alias; } - this.AdjustFlagsAndWidth(type); - this.type = type; + this.AdjustFlagsAndWidth(namespaceOrType); + this.namespaceOrType = namespaceOrType; this.AdjustFlagsAndWidth(semicolonToken); this.semicolonToken = semicolonToken; } @@ -19771,7 +19771,7 @@ internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, Synta public SyntaxToken? StaticKeyword => this.staticKeyword; public SyntaxToken? UnsafeKeyword => this.unsafeKeyword; public NameEqualsSyntax? Alias => this.alias; - public TypeSyntax Type => this.type; + public TypeSyntax NamespaceOrType => this.namespaceOrType; public SyntaxToken SemicolonToken => this.semicolonToken; internal override GreenNode? GetSlot(int index) @@ -19782,7 +19782,7 @@ internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, Synta 2 => this.staticKeyword, 3 => this.unsafeKeyword, 4 => this.alias, - 5 => this.type, + 5 => this.namespaceOrType, 6 => this.semicolonToken, _ => null, }; @@ -19792,11 +19792,11 @@ internal UsingDirectiveSyntax(SyntaxKind kind, SyntaxToken? globalKeyword, Synta public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitUsingDirective(this); public override TResult Accept(CSharpSyntaxVisitor visitor) => visitor.VisitUsingDirective(this); - public UsingDirectiveSyntax Update(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, SyntaxToken unsafeKeyword, NameEqualsSyntax alias, TypeSyntax type, SyntaxToken semicolonToken) + public UsingDirectiveSyntax Update(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, SyntaxToken unsafeKeyword, NameEqualsSyntax alias, TypeSyntax namespaceOrType, SyntaxToken semicolonToken) { - if (globalKeyword != this.GlobalKeyword || usingKeyword != this.UsingKeyword || staticKeyword != this.StaticKeyword || unsafeKeyword != this.UnsafeKeyword || alias != this.Alias || type != this.Type || semicolonToken != this.SemicolonToken) + if (globalKeyword != this.GlobalKeyword || usingKeyword != this.UsingKeyword || staticKeyword != this.StaticKeyword || unsafeKeyword != this.UnsafeKeyword || alias != this.Alias || namespaceOrType != this.NamespaceOrType || semicolonToken != this.SemicolonToken) { - var newNode = SyntaxFactory.UsingDirective(globalKeyword, usingKeyword, staticKeyword, unsafeKeyword, alias, type, semicolonToken); + var newNode = SyntaxFactory.UsingDirective(globalKeyword, usingKeyword, staticKeyword, unsafeKeyword, alias, namespaceOrType, semicolonToken); var diags = GetDiagnostics(); if (diags?.Length > 0) newNode = newNode.WithDiagnosticsGreen(diags); @@ -19810,10 +19810,10 @@ public UsingDirectiveSyntax Update(SyntaxToken globalKeyword, SyntaxToken usingK } internal override GreenNode SetDiagnostics(DiagnosticInfo[]? diagnostics) - => new UsingDirectiveSyntax(this.Kind, this.globalKeyword, this.usingKeyword, this.staticKeyword, this.unsafeKeyword, this.alias, this.type, this.semicolonToken, diagnostics, GetAnnotations()); + => new UsingDirectiveSyntax(this.Kind, this.globalKeyword, this.usingKeyword, this.staticKeyword, this.unsafeKeyword, this.alias, this.namespaceOrType, this.semicolonToken, diagnostics, GetAnnotations()); internal override GreenNode SetAnnotations(SyntaxAnnotation[]? annotations) - => new UsingDirectiveSyntax(this.Kind, this.globalKeyword, this.usingKeyword, this.staticKeyword, this.unsafeKeyword, this.alias, this.type, this.semicolonToken, GetDiagnostics(), annotations); + => new UsingDirectiveSyntax(this.Kind, this.globalKeyword, this.usingKeyword, this.staticKeyword, this.unsafeKeyword, this.alias, this.namespaceOrType, this.semicolonToken, GetDiagnostics(), annotations); internal UsingDirectiveSyntax(ObjectReader reader) : base(reader) @@ -19846,9 +19846,9 @@ internal UsingDirectiveSyntax(ObjectReader reader) AdjustFlagsAndWidth(alias); this.alias = alias; } - var type = (TypeSyntax)reader.ReadValue(); - AdjustFlagsAndWidth(type); - this.type = type; + var namespaceOrType = (TypeSyntax)reader.ReadValue(); + AdjustFlagsAndWidth(namespaceOrType); + this.namespaceOrType = namespaceOrType; var semicolonToken = (SyntaxToken)reader.ReadValue(); AdjustFlagsAndWidth(semicolonToken); this.semicolonToken = semicolonToken; @@ -19862,7 +19862,7 @@ internal override void WriteTo(ObjectWriter writer) writer.WriteValue(this.staticKeyword); writer.WriteValue(this.unsafeKeyword); writer.WriteValue(this.alias); - writer.WriteValue(this.type); + writer.WriteValue(this.namespaceOrType); writer.WriteValue(this.semicolonToken); } @@ -35302,7 +35302,7 @@ public override CSharpSyntaxNode VisitExternAliasDirective(ExternAliasDirectiveS => node.Update((SyntaxToken)Visit(node.ExternKeyword), (SyntaxToken)Visit(node.AliasKeyword), (SyntaxToken)Visit(node.Identifier), (SyntaxToken)Visit(node.SemicolonToken)); public override CSharpSyntaxNode VisitUsingDirective(UsingDirectiveSyntax node) - => node.Update((SyntaxToken)Visit(node.GlobalKeyword), (SyntaxToken)Visit(node.UsingKeyword), (SyntaxToken)Visit(node.StaticKeyword), (SyntaxToken)Visit(node.UnsafeKeyword), (NameEqualsSyntax)Visit(node.Alias), (TypeSyntax)Visit(node.Type), (SyntaxToken)Visit(node.SemicolonToken)); + => node.Update((SyntaxToken)Visit(node.GlobalKeyword), (SyntaxToken)Visit(node.UsingKeyword), (SyntaxToken)Visit(node.StaticKeyword), (SyntaxToken)Visit(node.UnsafeKeyword), (NameEqualsSyntax)Visit(node.Alias), (TypeSyntax)Visit(node.NamespaceOrType), (SyntaxToken)Visit(node.SemicolonToken)); public override CSharpSyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node) => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), (SyntaxToken)Visit(node.NamespaceKeyword), (NameSyntax)Visit(node.Name), (SyntaxToken)Visit(node.OpenBraceToken), VisitList(node.Externs), VisitList(node.Usings), VisitList(node.Members), (SyntaxToken)Visit(node.CloseBraceToken), (SyntaxToken)Visit(node.SemicolonToken)); @@ -38724,7 +38724,7 @@ public ExternAliasDirectiveSyntax ExternAliasDirective(SyntaxToken externKeyword return new ExternAliasDirectiveSyntax(SyntaxKind.ExternAliasDirective, externKeyword, aliasKeyword, identifier, semicolonToken, this.context); } - public UsingDirectiveSyntax UsingDirective(SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax type, SyntaxToken semicolonToken) + public UsingDirectiveSyntax UsingDirective(SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax namespaceOrType, SyntaxToken semicolonToken) { #if DEBUG if (globalKeyword != null) @@ -38756,12 +38756,12 @@ public UsingDirectiveSyntax UsingDirective(SyntaxToken? globalKeyword, SyntaxTok default: throw new ArgumentException(nameof(unsafeKeyword)); } } - if (type == null) throw new ArgumentNullException(nameof(type)); + if (namespaceOrType == null) throw new ArgumentNullException(nameof(namespaceOrType)); if (semicolonToken == null) throw new ArgumentNullException(nameof(semicolonToken)); if (semicolonToken.Kind != SyntaxKind.SemicolonToken) throw new ArgumentException(nameof(semicolonToken)); #endif - return new UsingDirectiveSyntax(SyntaxKind.UsingDirective, globalKeyword, usingKeyword, staticKeyword, unsafeKeyword, alias, type, semicolonToken, this.context); + return new UsingDirectiveSyntax(SyntaxKind.UsingDirective, globalKeyword, usingKeyword, staticKeyword, unsafeKeyword, alias, namespaceOrType, semicolonToken, this.context); } public NamespaceDeclarationSyntax NamespaceDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken namespaceKeyword, NameSyntax name, SyntaxToken openBraceToken, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList externs, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList usings, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList members, SyntaxToken closeBraceToken, SyntaxToken? semicolonToken) @@ -43813,7 +43813,7 @@ public static ExternAliasDirectiveSyntax ExternAliasDirective(SyntaxToken extern return new ExternAliasDirectiveSyntax(SyntaxKind.ExternAliasDirective, externKeyword, aliasKeyword, identifier, semicolonToken); } - public static UsingDirectiveSyntax UsingDirective(SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax type, SyntaxToken semicolonToken) + public static UsingDirectiveSyntax UsingDirective(SyntaxToken? globalKeyword, SyntaxToken usingKeyword, SyntaxToken? staticKeyword, SyntaxToken? unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax namespaceOrType, SyntaxToken semicolonToken) { #if DEBUG if (globalKeyword != null) @@ -43845,12 +43845,12 @@ public static UsingDirectiveSyntax UsingDirective(SyntaxToken? globalKeyword, Sy default: throw new ArgumentException(nameof(unsafeKeyword)); } } - if (type == null) throw new ArgumentNullException(nameof(type)); + if (namespaceOrType == null) throw new ArgumentNullException(nameof(namespaceOrType)); if (semicolonToken == null) throw new ArgumentNullException(nameof(semicolonToken)); if (semicolonToken.Kind != SyntaxKind.SemicolonToken) throw new ArgumentException(nameof(semicolonToken)); #endif - return new UsingDirectiveSyntax(SyntaxKind.UsingDirective, globalKeyword, usingKeyword, staticKeyword, unsafeKeyword, alias, type, semicolonToken); + return new UsingDirectiveSyntax(SyntaxKind.UsingDirective, globalKeyword, usingKeyword, staticKeyword, unsafeKeyword, alias, namespaceOrType, semicolonToken); } public static NamespaceDeclarationSyntax NamespaceDeclaration(Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList attributeLists, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList modifiers, SyntaxToken namespaceKeyword, NameSyntax name, SyntaxToken openBraceToken, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList externs, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList usings, Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList members, SyntaxToken closeBraceToken, SyntaxToken? semicolonToken) diff --git a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs index a3b2fb4e72933..b9e3332315a93 100644 --- a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Main.Generated.cs @@ -1894,7 +1894,7 @@ public partial class CSharpSyntaxRewriter : CSharpSyntaxVisitor => node.Update(VisitToken(node.ExternKeyword), VisitToken(node.AliasKeyword), VisitToken(node.Identifier), VisitToken(node.SemicolonToken)); public override SyntaxNode? VisitUsingDirective(UsingDirectiveSyntax node) - => node.Update(VisitToken(node.GlobalKeyword), VisitToken(node.UsingKeyword), VisitToken(node.StaticKeyword), VisitToken(node.UnsafeKeyword), (NameEqualsSyntax?)Visit(node.Alias), (TypeSyntax?)Visit(node.Type) ?? throw new ArgumentNullException("type"), VisitToken(node.SemicolonToken)); + => node.Update(VisitToken(node.GlobalKeyword), VisitToken(node.UsingKeyword), VisitToken(node.StaticKeyword), VisitToken(node.UnsafeKeyword), (NameEqualsSyntax?)Visit(node.Alias), (TypeSyntax?)Visit(node.NamespaceOrType) ?? throw new ArgumentNullException("namespaceOrType"), VisitToken(node.SemicolonToken)); public override SyntaxNode? VisitNamespaceDeclaration(NamespaceDeclarationSyntax node) => node.Update(VisitList(node.AttributeLists), VisitList(node.Modifiers), VisitToken(node.NamespaceKeyword), (NameSyntax?)Visit(node.Name) ?? throw new ArgumentNullException("name"), VisitToken(node.OpenBraceToken), VisitList(node.Externs), VisitList(node.Usings), VisitList(node.Members), VisitToken(node.CloseBraceToken), VisitToken(node.SemicolonToken)); @@ -4664,7 +4664,7 @@ public static ExternAliasDirectiveSyntax ExternAliasDirective(string identifier) => SyntaxFactory.ExternAliasDirective(SyntaxFactory.Token(SyntaxKind.ExternKeyword), SyntaxFactory.Token(SyntaxKind.AliasKeyword), SyntaxFactory.Identifier(identifier), SyntaxFactory.Token(SyntaxKind.SemicolonToken)); /// Creates a new UsingDirectiveSyntax instance. - public static UsingDirectiveSyntax UsingDirective(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, SyntaxToken unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax type, SyntaxToken semicolonToken) + public static UsingDirectiveSyntax UsingDirective(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, SyntaxToken unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax namespaceOrType, SyntaxToken semicolonToken) { switch (globalKeyword.Kind()) { @@ -4685,18 +4685,18 @@ public static UsingDirectiveSyntax UsingDirective(SyntaxToken globalKeyword, Syn case SyntaxKind.None: break; default: throw new ArgumentException(nameof(unsafeKeyword)); } - if (type == null) throw new ArgumentNullException(nameof(type)); + if (namespaceOrType == null) throw new ArgumentNullException(nameof(namespaceOrType)); if (semicolonToken.Kind() != SyntaxKind.SemicolonToken) throw new ArgumentException(nameof(semicolonToken)); - return (UsingDirectiveSyntax)Syntax.InternalSyntax.SyntaxFactory.UsingDirective((Syntax.InternalSyntax.SyntaxToken?)globalKeyword.Node, (Syntax.InternalSyntax.SyntaxToken)usingKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken?)staticKeyword.Node, (Syntax.InternalSyntax.SyntaxToken?)unsafeKeyword.Node, alias == null ? null : (Syntax.InternalSyntax.NameEqualsSyntax)alias.Green, (Syntax.InternalSyntax.TypeSyntax)type.Green, (Syntax.InternalSyntax.SyntaxToken)semicolonToken.Node!).CreateRed(); + return (UsingDirectiveSyntax)Syntax.InternalSyntax.SyntaxFactory.UsingDirective((Syntax.InternalSyntax.SyntaxToken?)globalKeyword.Node, (Syntax.InternalSyntax.SyntaxToken)usingKeyword.Node!, (Syntax.InternalSyntax.SyntaxToken?)staticKeyword.Node, (Syntax.InternalSyntax.SyntaxToken?)unsafeKeyword.Node, alias == null ? null : (Syntax.InternalSyntax.NameEqualsSyntax)alias.Green, (Syntax.InternalSyntax.TypeSyntax)namespaceOrType.Green, (Syntax.InternalSyntax.SyntaxToken)semicolonToken.Node!).CreateRed(); } /// Creates a new UsingDirectiveSyntax instance. - public static UsingDirectiveSyntax UsingDirective(NameEqualsSyntax? alias, TypeSyntax type) - => SyntaxFactory.UsingDirective(default, SyntaxFactory.Token(SyntaxKind.UsingKeyword), default, default, alias, type, SyntaxFactory.Token(SyntaxKind.SemicolonToken)); + public static UsingDirectiveSyntax UsingDirective(NameEqualsSyntax? alias, TypeSyntax namespaceOrType) + => SyntaxFactory.UsingDirective(default, SyntaxFactory.Token(SyntaxKind.UsingKeyword), default, default, alias, namespaceOrType, SyntaxFactory.Token(SyntaxKind.SemicolonToken)); /// Creates a new UsingDirectiveSyntax instance. - public static UsingDirectiveSyntax UsingDirective(TypeSyntax type) - => SyntaxFactory.UsingDirective(default, SyntaxFactory.Token(SyntaxKind.UsingKeyword), default, default, default, type, SyntaxFactory.Token(SyntaxKind.SemicolonToken)); + public static UsingDirectiveSyntax UsingDirective(TypeSyntax namespaceOrType) + => SyntaxFactory.UsingDirective(default, SyntaxFactory.Token(SyntaxKind.UsingKeyword), default, default, default, namespaceOrType, SyntaxFactory.Token(SyntaxKind.SemicolonToken)); /// Creates a new NamespaceDeclarationSyntax instance. public static NamespaceDeclarationSyntax NamespaceDeclaration(SyntaxList attributeLists, SyntaxTokenList modifiers, SyntaxToken namespaceKeyword, NameSyntax name, SyntaxToken openBraceToken, SyntaxList externs, SyntaxList usings, SyntaxList members, SyntaxToken closeBraceToken, SyntaxToken semicolonToken) diff --git a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs index 1a9dde8232c73..f03c6b049fe45 100644 --- a/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/CSharpSyntaxGenerator/CSharpSyntaxGenerator.SourceGenerator/Syntax.xml.Syntax.Generated.cs @@ -9193,7 +9193,7 @@ public ExternAliasDirectiveSyntax Update(SyntaxToken externKeyword, SyntaxToken public sealed partial class UsingDirectiveSyntax : CSharpSyntaxNode { private NameEqualsSyntax? alias; - private TypeSyntax? type; + private TypeSyntax? namespaceOrType; internal UsingDirectiveSyntax(InternalSyntax.CSharpSyntaxNode green, SyntaxNode? parent, int position) : base(green, parent, position) @@ -9231,7 +9231,7 @@ public SyntaxToken UnsafeKeyword public NameEqualsSyntax? Alias => GetRed(ref this.alias, 4); - public TypeSyntax Type => GetRed(ref this.type, 5)!; + public TypeSyntax NamespaceOrType => GetRed(ref this.namespaceOrType, 5)!; public SyntaxToken SemicolonToken => new SyntaxToken(this, ((Syntax.InternalSyntax.UsingDirectiveSyntax)this.Green).semicolonToken, GetChildPosition(6), GetChildIndex(6)); @@ -9239,7 +9239,7 @@ public SyntaxToken UnsafeKeyword => index switch { 4 => GetRed(ref this.alias, 4), - 5 => GetRed(ref this.type, 5)!, + 5 => GetRed(ref this.namespaceOrType, 5)!, _ => null, }; @@ -9247,18 +9247,18 @@ public SyntaxToken UnsafeKeyword => index switch { 4 => this.alias, - 5 => this.type, + 5 => this.namespaceOrType, _ => null, }; public override void Accept(CSharpSyntaxVisitor visitor) => visitor.VisitUsingDirective(this); public override TResult? Accept(CSharpSyntaxVisitor visitor) where TResult : default => visitor.VisitUsingDirective(this); - public UsingDirectiveSyntax Update(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, SyntaxToken unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax type, SyntaxToken semicolonToken) + public UsingDirectiveSyntax Update(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, SyntaxToken unsafeKeyword, NameEqualsSyntax? alias, TypeSyntax namespaceOrType, SyntaxToken semicolonToken) { - if (globalKeyword != this.GlobalKeyword || usingKeyword != this.UsingKeyword || staticKeyword != this.StaticKeyword || unsafeKeyword != this.UnsafeKeyword || alias != this.Alias || type != this.Type || semicolonToken != this.SemicolonToken) + if (globalKeyword != this.GlobalKeyword || usingKeyword != this.UsingKeyword || staticKeyword != this.StaticKeyword || unsafeKeyword != this.UnsafeKeyword || alias != this.Alias || namespaceOrType != this.NamespaceOrType || semicolonToken != this.SemicolonToken) { - var newNode = SyntaxFactory.UsingDirective(globalKeyword, usingKeyword, staticKeyword, unsafeKeyword, alias, type, semicolonToken); + var newNode = SyntaxFactory.UsingDirective(globalKeyword, usingKeyword, staticKeyword, unsafeKeyword, alias, namespaceOrType, semicolonToken); var annotations = GetAnnotations(); return annotations?.Length > 0 ? newNode.WithAnnotations(annotations) : newNode; } @@ -9266,13 +9266,13 @@ public UsingDirectiveSyntax Update(SyntaxToken globalKeyword, SyntaxToken usingK return this; } - public UsingDirectiveSyntax WithGlobalKeyword(SyntaxToken globalKeyword) => Update(globalKeyword, this.UsingKeyword, this.StaticKeyword, this.UnsafeKeyword, this.Alias, this.Type, this.SemicolonToken); - public UsingDirectiveSyntax WithUsingKeyword(SyntaxToken usingKeyword) => Update(this.GlobalKeyword, usingKeyword, this.StaticKeyword, this.UnsafeKeyword, this.Alias, this.Type, this.SemicolonToken); - public UsingDirectiveSyntax WithStaticKeyword(SyntaxToken staticKeyword) => Update(this.GlobalKeyword, this.UsingKeyword, staticKeyword, this.UnsafeKeyword, this.Alias, this.Type, this.SemicolonToken); - public UsingDirectiveSyntax WithUnsafeKeyword(SyntaxToken unsafeKeyword) => Update(this.GlobalKeyword, this.UsingKeyword, this.StaticKeyword, unsafeKeyword, this.Alias, this.Type, this.SemicolonToken); - public UsingDirectiveSyntax WithAlias(NameEqualsSyntax? alias) => Update(this.GlobalKeyword, this.UsingKeyword, this.StaticKeyword, this.UnsafeKeyword, alias, this.Type, this.SemicolonToken); - public UsingDirectiveSyntax WithType(TypeSyntax type) => Update(this.GlobalKeyword, this.UsingKeyword, this.StaticKeyword, this.UnsafeKeyword, this.Alias, type, this.SemicolonToken); - public UsingDirectiveSyntax WithSemicolonToken(SyntaxToken semicolonToken) => Update(this.GlobalKeyword, this.UsingKeyword, this.StaticKeyword, this.UnsafeKeyword, this.Alias, this.Type, semicolonToken); + public UsingDirectiveSyntax WithGlobalKeyword(SyntaxToken globalKeyword) => Update(globalKeyword, this.UsingKeyword, this.StaticKeyword, this.UnsafeKeyword, this.Alias, this.NamespaceOrType, this.SemicolonToken); + public UsingDirectiveSyntax WithUsingKeyword(SyntaxToken usingKeyword) => Update(this.GlobalKeyword, usingKeyword, this.StaticKeyword, this.UnsafeKeyword, this.Alias, this.NamespaceOrType, this.SemicolonToken); + public UsingDirectiveSyntax WithStaticKeyword(SyntaxToken staticKeyword) => Update(this.GlobalKeyword, this.UsingKeyword, staticKeyword, this.UnsafeKeyword, this.Alias, this.NamespaceOrType, this.SemicolonToken); + public UsingDirectiveSyntax WithUnsafeKeyword(SyntaxToken unsafeKeyword) => Update(this.GlobalKeyword, this.UsingKeyword, this.StaticKeyword, unsafeKeyword, this.Alias, this.NamespaceOrType, this.SemicolonToken); + public UsingDirectiveSyntax WithAlias(NameEqualsSyntax? alias) => Update(this.GlobalKeyword, this.UsingKeyword, this.StaticKeyword, this.UnsafeKeyword, alias, this.NamespaceOrType, this.SemicolonToken); + public UsingDirectiveSyntax WithNamespaceOrType(TypeSyntax namespaceOrType) => Update(this.GlobalKeyword, this.UsingKeyword, this.StaticKeyword, this.UnsafeKeyword, this.Alias, namespaceOrType, this.SemicolonToken); + public UsingDirectiveSyntax WithSemicolonToken(SyntaxToken semicolonToken) => Update(this.GlobalKeyword, this.UsingKeyword, this.StaticKeyword, this.UnsafeKeyword, this.Alias, this.NamespaceOrType, semicolonToken); } /// Member declaration syntax. diff --git a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt index 4ffa14f7f9a9f..bb7e9ac87f90d 100644 --- a/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt @@ -1,11 +1,11 @@ *REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.Name.get -> Microsoft.CodeAnalysis.CSharp.Syntax.NameSyntax! static Microsoft.CodeAnalysis.CSharpExtensions.ContainsDirective(this Microsoft.CodeAnalysis.SyntaxNode! node, Microsoft.CodeAnalysis.CSharp.SyntaxKind kind) -> bool Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.Name.get -> Microsoft.CodeAnalysis.CSharp.Syntax.NameSyntax? -Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.NamespaceOrType.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.UnsafeKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken -Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken globalKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxToken staticKeyword, Microsoft.CodeAnalysis.SyntaxToken unsafeKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.NameEqualsSyntax? alias, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! -Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken globalKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxToken staticKeyword, Microsoft.CodeAnalysis.SyntaxToken unsafeKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.NameEqualsSyntax? alias, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! namespaceOrType, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! +Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.WithNamespaceOrType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! namespaceOrType) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.WithUnsafeKeyword(Microsoft.CodeAnalysis.SyntaxToken unsafeKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! -static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.UsingDirective(Microsoft.CodeAnalysis.CSharp.Syntax.NameEqualsSyntax? alias, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! -static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.UsingDirective(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! -static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.UsingDirective(Microsoft.CodeAnalysis.SyntaxToken globalKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxToken staticKeyword, Microsoft.CodeAnalysis.SyntaxToken unsafeKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.NameEqualsSyntax? alias, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! type, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! \ No newline at end of file +static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.UsingDirective(Microsoft.CodeAnalysis.CSharp.Syntax.NameEqualsSyntax? alias, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! namespaceOrType) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! +static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.UsingDirective(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! namespaceOrType) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! +static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.UsingDirective(Microsoft.CodeAnalysis.SyntaxToken globalKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxToken staticKeyword, Microsoft.CodeAnalysis.SyntaxToken unsafeKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.NameEqualsSyntax? alias, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax! namespaceOrType, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax! \ No newline at end of file diff --git a/src/Compilers/CSharp/Portable/SourceGeneration/CSharpSyntaxHelper.cs b/src/Compilers/CSharp/Portable/SourceGeneration/CSharpSyntaxHelper.cs index 091742b2eb2f7..4014712c69783 100644 --- a/src/Compilers/CSharp/Portable/SourceGeneration/CSharpSyntaxHelper.cs +++ b/src/Compilers/CSharp/Portable/SourceGeneration/CSharpSyntaxHelper.cs @@ -94,7 +94,7 @@ private static void AddAliases( // We only care about aliases from one name to another name. e.g. `using X = A.B.C;` That's because // the caller is only interested in finding a fully-qualified-metadata-name to an attribute. - if (usingDirective.Type is not Syntax.InternalSyntax.NameSyntax name) + if (usingDirective.NamespaceOrType is not Syntax.InternalSyntax.NameSyntax name) continue; var aliasName = usingDirective.Alias.Name.Identifier.ValueText; diff --git a/src/Compilers/CSharp/Portable/Symbols/AliasSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/AliasSymbol.cs index ab2d9cbc18643..c70cf192ca43b 100644 --- a/src/Compilers/CSharp/Portable/Symbols/AliasSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/AliasSymbol.cs @@ -381,12 +381,12 @@ private NamespaceOrTypeSymbol ResolveAliasTarget( { MessageID.IDS_FeatureUsingTypeAlias.CheckFeatureAvailability(diagnostics, usingDirective, usingDirective.UnsafeKeyword.GetLocation()); } - else if (usingDirective.Type is not NameSyntax) + else if (usingDirective.NamespaceOrType is not NameSyntax) { - MessageID.IDS_FeatureUsingTypeAlias.CheckFeatureAvailability(diagnostics, usingDirective.Type); + MessageID.IDS_FeatureUsingTypeAlias.CheckFeatureAvailability(diagnostics, usingDirective.NamespaceOrType); } - var syntax = usingDirective.Type; + var syntax = usingDirective.NamespaceOrType; var flags = BinderFlags.SuppressConstraintChecks | BinderFlags.SuppressObsoleteChecks; if (usingDirective.UnsafeKeyword != default) { @@ -402,7 +402,7 @@ private NamespaceOrTypeSymbol ResolveAliasTarget( var annotatedNamespaceOrType = declarationBinder.BindNamespaceOrTypeSymbol(syntax, diagnostics, basesBeingResolved); // `using X = RefType?;` is not legal. - if (usingDirective.Type is NullableTypeSyntax nullableType && + if (usingDirective.NamespaceOrType is NullableTypeSyntax nullableType && annotatedNamespaceOrType.TypeWithAnnotations.NullableAnnotation == NullableAnnotation.Annotated && annotatedNamespaceOrType.TypeWithAnnotations.Type?.IsReferenceType is true) { @@ -411,10 +411,10 @@ private NamespaceOrTypeSymbol ResolveAliasTarget( var namespaceOrType = annotatedNamespaceOrType.NamespaceOrTypeSymbol; if (namespaceOrType is TypeSymbol { IsNativeIntegerWrapperType: true } && - (usingDirective.Type.IsNint || usingDirective.Type.IsNuint)) + (usingDirective.NamespaceOrType.IsNint || usingDirective.NamespaceOrType.IsNuint)) { // using X = nint; - MessageID.IDS_FeatureUsingTypeAlias.CheckFeatureAvailability(diagnostics, usingDirective.Type); + MessageID.IDS_FeatureUsingTypeAlias.CheckFeatureAvailability(diagnostics, usingDirective.NamespaceOrType); } return namespaceOrType; diff --git a/src/Compilers/CSharp/Portable/Symbols/BaseTypeAnalysis.cs b/src/Compilers/CSharp/Portable/Symbols/BaseTypeAnalysis.cs index a238c0c34af84..8583f3cb714b9 100644 --- a/src/Compilers/CSharp/Portable/Symbols/BaseTypeAnalysis.cs +++ b/src/Compilers/CSharp/Portable/Symbols/BaseTypeAnalysis.cs @@ -233,9 +233,6 @@ internal static ManagedKind GetManagedKind(NamedTypeSymbol type, ref CompoundUse } } - // NOTE: If we do not check HasPointerType, we will unconditionally - // bind Type and that may cause infinite recursion. - // HasPointerType can use syntax directly and break recursion. internal static TypeSymbol NonPointerType(this FieldSymbol field) => field.HasPointerType ? null : field.Type; diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs index bf46d60ea5ad7..8a3b04481fee3 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs @@ -420,34 +420,10 @@ internal override bool HasPointerType { get { - if (_lazyTypeAndRefKind?.Type.DefaultType is { } defaultType) - { - bool isPointerType = defaultType.Kind switch - { - SymbolKind.PointerType => true, - SymbolKind.FunctionPointerType => true, - _ => false - }; - Debug.Assert(isPointerType == IsPointerFieldSyntactically()); - return isPointerType; - } - - return IsPointerFieldSyntactically(); + return TypeWithAnnotations.DefaultType.IsPointerOrFunctionPointer(); } } - private bool IsPointerFieldSyntactically() - { - var declaration = GetFieldDeclaration(VariableDeclaratorNode).Declaration; - if (declaration.Type.Kind() switch { SyntaxKind.PointerType => true, SyntaxKind.FunctionPointerType => true, _ => false }) - { - // public int * Blah; // pointer - return true; - } - - return IsFixedSizeBuffer; - } - internal sealed override TypeWithAnnotations GetFieldType(ConsList fieldsBeingBound) { return GetTypeAndRefKind(fieldsBeingBound).Type; @@ -605,8 +581,6 @@ private TypeAndRefKind GetTypeAndRefKind(ConsList fieldsBeingBound) } } - Debug.Assert(type.DefaultType.IsPointerOrFunctionPointer() == IsPointerFieldSyntactically()); - // update the lazyType only if it contains value last seen by the current thread: if (Interlocked.CompareExchange(ref _lazyTypeAndRefKind, new TypeAndRefKind(refKind, type.WithModifiers(this.RequiredCustomModifiers)), null) == null) { diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.AliasesAndUsings.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.AliasesAndUsings.cs index c5c45e4144a57..f71f170d083ac 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.AliasesAndUsings.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamespaceSymbol.AliasesAndUsings.cs @@ -320,7 +320,7 @@ private MergedGlobalAliasesAndUsings GetMergedGlobalAliasesAndUsings(ConsList' is a '' but is used as 'type or namespace' - diagnostics.Add(ErrorCode.ERR_BadSKknown, usingDirective.Type.Location, - usingDirective.Type, + diagnostics.Add(ErrorCode.ERR_BadSKknown, usingDirective.NamespaceOrType.Location, + usingDirective.NamespaceOrType, imported.GetKindText(), MessageID.IDS_SK_TYPE_OR_NAMESPACE.Localize()); } @@ -969,7 +969,7 @@ private static void Validate(SourceNamespaceSymbol declaringSymbol, SyntaxRefere if (target.IsType) { var typeSymbol = (TypeSymbol)target; - var location = usingDirective.Type.Location; + var location = usingDirective.NamespaceOrType.Location; typeSymbol.CheckAllConstraints(compilation, conversions, location, diagnostics); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs index 8045e4cfc5ce7..7ff1f345bc48d 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs @@ -554,17 +554,6 @@ internal override void AfterAddingTypeMembersChecks(ConversionsBase conversions, diagnostics.Add(Location, useSiteInfo); } - protected override bool HasPointerTypeSyntactically - { - get - { - var typeSyntax = GetTypeSyntax(CSharpSyntaxNode); - Debug.Assert(typeSyntax is not ScopedTypeSyntax); - typeSyntax = typeSyntax.SkipScoped(out _).SkipRef(); - return typeSyntax.Kind() switch { SyntaxKind.PointerType => true, SyntaxKind.FunctionPointerType => true, _ => false }; - } - } - private static BaseParameterListSyntax? GetParameterListSyntax(CSharpSyntaxNode syntax) => (syntax as IndexerDeclarationSyntax)?.ParameterList; } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbolBase.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbolBase.cs index 8065866324b81..1c336ceb345f8 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbolBase.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbolBase.cs @@ -355,20 +355,10 @@ internal bool HasPointerType { get { - if (_lazyType != null) - { - - var hasPointerType = _lazyType.Value.DefaultType.IsPointerOrFunctionPointer(); - Debug.Assert(hasPointerType == HasPointerTypeSyntactically); - return hasPointerType; - } - - return HasPointerTypeSyntactically; + return TypeWithAnnotations.DefaultType.IsPointerOrFunctionPointer(); } } - protected abstract bool HasPointerTypeSyntactically { get; } - /// /// To facilitate lookup, all indexer symbols have the same name. /// Check the MetadataName property to find the name that will be diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEqualityContractProperty.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEqualityContractProperty.cs index 78eafcb6a973e..a47480b65af7e 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEqualityContractProperty.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordEqualityContractProperty.cs @@ -77,8 +77,6 @@ protected override (TypeWithAnnotations Type, ImmutableArray Pa ImmutableArray.Empty); } - protected override bool HasPointerTypeSyntactically => false; - protected override void ValidatePropertyType(BindingDiagnosticBag diagnostics) { base.ValidatePropertyType(diagnostics); diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordPropertySymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordPropertySymbol.cs index 496f928ffbcfa..75349270268f2 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordPropertySymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordPropertySymbol.cs @@ -89,10 +89,6 @@ protected override (TypeWithAnnotations Type, ImmutableArray Pa ImmutableArray.Empty); } - protected override bool HasPointerTypeSyntactically - // Since we already bound the type, don't bother looking at syntax - => TypeWithAnnotations.DefaultType.IsPointerOrFunctionPointer(); - public static bool HaveCorrespondingSynthesizedRecordPropertySymbol(SourceParameterSymbol parameter) { return parameter.ContainingSymbol is SynthesizedRecordConstructor && diff --git a/src/Compilers/CSharp/Portable/Syntax/Syntax.xml b/src/Compilers/CSharp/Portable/Syntax/Syntax.xml index 10a892ad771e5..f03537bc84e44 100644 --- a/src/Compilers/CSharp/Portable/Syntax/Syntax.xml +++ b/src/Compilers/CSharp/Portable/Syntax/Syntax.xml @@ -3085,7 +3085,7 @@ - + diff --git a/src/Compilers/CSharp/Portable/Syntax/SyntaxFactory.cs b/src/Compilers/CSharp/Portable/Syntax/SyntaxFactory.cs index b6220a0769742..d9f7d9d00f158 100644 --- a/src/Compilers/CSharp/Portable/Syntax/SyntaxFactory.cs +++ b/src/Compilers/CSharp/Portable/Syntax/SyntaxFactory.cs @@ -2661,7 +2661,7 @@ public static UsingDirectiveSyntax UsingDirective(SyntaxToken usingKeyword, Synt staticKeyword, unsafeKeyword: default, alias, - type: name, + namespaceOrType: name, semicolonToken); } diff --git a/src/Compilers/CSharp/Portable/Syntax/SyntaxFacts.cs b/src/Compilers/CSharp/Portable/Syntax/SyntaxFacts.cs index 2c026feea49ba..b67d3ecae8db3 100644 --- a/src/Compilers/CSharp/Portable/Syntax/SyntaxFacts.cs +++ b/src/Compilers/CSharp/Portable/Syntax/SyntaxFacts.cs @@ -244,7 +244,7 @@ public static bool IsInNamespaceOrTypeContext(ExpressionSyntax? node) switch (parent.Kind()) { case UsingDirective: - return ((UsingDirectiveSyntax)parent).Type == node; + return ((UsingDirectiveSyntax)parent).NamespaceOrType == node; case QualifiedName: // left of QN is namespace or type. Note: when you have "a.b.c()", then diff --git a/src/Compilers/CSharp/Portable/Syntax/SyntaxNormalizer.cs b/src/Compilers/CSharp/Portable/Syntax/SyntaxNormalizer.cs index 184828c68dc65..53be7a4f8a12e 100644 --- a/src/Compilers/CSharp/Portable/Syntax/SyntaxNormalizer.cs +++ b/src/Compilers/CSharp/Portable/Syntax/SyntaxNormalizer.cs @@ -654,7 +654,9 @@ private static bool NeedsSeparator(SyntaxToken token, SyntaxToken next) } } - if (token.IsKind(SyntaxKind.GreaterThanToken) && token.Parent.IsKind(SyntaxKind.FunctionPointerParameterList)) + if (token.IsKind(SyntaxKind.GreaterThanToken) && + token.Parent.IsKind(SyntaxKind.FunctionPointerParameterList) && + token.Parent.Parent?.Parent is not UsingDirectiveSyntax) { return true; } @@ -677,11 +679,15 @@ private static bool NeedsSeparator(SyntaxToken token, SyntaxToken next) return true; } - if (token.IsKind(SyntaxKind.QuestionToken) - && (token.Parent.IsKind(SyntaxKind.ConditionalExpression) || token.Parent is TypeSyntax) - && !token.Parent.Parent.IsKind(SyntaxKind.TypeArgumentList)) + if (token.IsKind(SyntaxKind.QuestionToken)) { - return true; + if (token.Parent.IsKind(SyntaxKind.ConditionalExpression) || token.Parent is TypeSyntax) + { + if (token.Parent.Parent?.Kind() is not SyntaxKind.TypeArgumentList and not SyntaxKind.UsingDirective) + { + return true; + } + } } if (token.IsKind(SyntaxKind.ColonToken)) diff --git a/src/Compilers/CSharp/Portable/Syntax/UsingDirectiveSyntax.cs b/src/Compilers/CSharp/Portable/Syntax/UsingDirectiveSyntax.cs index dd083ee8b3943..ee33a5ec50668 100644 --- a/src/Compilers/CSharp/Portable/Syntax/UsingDirectiveSyntax.cs +++ b/src/Compilers/CSharp/Portable/Syntax/UsingDirectiveSyntax.cs @@ -16,16 +16,16 @@ public partial class UsingDirectiveSyntax /// on the right side of the = is not a name. For example using x = (X.Y.Z, A.B.C);. Here, as /// the type is a tuple-type there is no name to return. /// - public NameSyntax? Name => this.Type as NameSyntax; + public NameSyntax? Name => this.NamespaceOrType as NameSyntax; public UsingDirectiveSyntax Update(SyntaxToken usingKeyword, SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name, SyntaxToken semicolonToken) - => this.Update(this.GlobalKeyword, usingKeyword, staticKeyword, this.UnsafeKeyword, alias, type: name, semicolonToken); + => this.Update(this.GlobalKeyword, usingKeyword, staticKeyword, this.UnsafeKeyword, alias, namespaceOrType: name, semicolonToken); public UsingDirectiveSyntax Update(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name, SyntaxToken semicolonToken) - => this.Update(globalKeyword, usingKeyword, staticKeyword, this.UnsafeKeyword, alias, type: name, semicolonToken); + => this.Update(globalKeyword, usingKeyword, staticKeyword, this.UnsafeKeyword, alias, namespaceOrType: name, semicolonToken); public UsingDirectiveSyntax WithName(NameSyntax name) - => WithType(name); + => WithNamespaceOrType(name); } } @@ -35,14 +35,14 @@ public partial class SyntaxFactory { /// Creates a new UsingDirectiveSyntax instance. public static UsingDirectiveSyntax UsingDirective(SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name) - => UsingDirective(globalKeyword: default, usingKeyword: default, staticKeyword, unsafeKeyword: default, alias, type: name, semicolonToken: default); + => UsingDirective(globalKeyword: default, usingKeyword: default, staticKeyword, unsafeKeyword: default, alias, namespaceOrType: name, semicolonToken: default); /// Creates a new UsingDirectiveSyntax instance. public static UsingDirectiveSyntax UsingDirective(SyntaxToken globalKeyword, SyntaxToken usingKeyword, SyntaxToken staticKeyword, NameEqualsSyntax? alias, NameSyntax name, SyntaxToken semicolonToken) - => UsingDirective(globalKeyword, usingKeyword, staticKeyword, unsafeKeyword: default, alias, type: name, semicolonToken); + => UsingDirective(globalKeyword, usingKeyword, staticKeyword, unsafeKeyword: default, alias, namespaceOrType: name, semicolonToken); /// Creates a new UsingDirectiveSyntax instance. public static UsingDirectiveSyntax UsingDirective(NameSyntax name) - => UsingDirective(type: name); + => UsingDirective(namespaceOrType: name); } } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs index b2146c0614c7e..d31fea0da9160 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs @@ -9896,6 +9896,39 @@ unsafe void M2(X t) { } Diagnostic(ErrorCode.ERR_UnsafeNeeded, "X").WithLocation(6, 13)); } + [Fact] + public void TestUnsafeAlias14_A() + { + var csharp = @" +using unsafe X = int; + +class C +{ + void ThisMethodIsNotUnsafe(X x) { } +} +"; + var comp = CreateCompilation(csharp, options: TestOptions.UnsafeDebugDll); + comp.VerifyDiagnostics(); + } + + [Fact] + public void TestUnsafeAlias14_B() + { + var csharp = @" +using unsafe X = int; + +class C +{ + void ThisMethodIsNotUnsafe(X x) { } +} +"; + var comp = CreateCompilation(csharp, options: TestOptions.DebugDll); + comp.VerifyDiagnostics( + // (2,7): error CS0227: Unsafe code may only appear if compiling with /unsafe + // using unsafe X = int; + Diagnostic(ErrorCode.ERR_IllegalUnsafe, "unsafe").WithLocation(2, 7)); + } + [Fact] public void TestUnsafeAlias1_FP() { @@ -10044,5 +10077,64 @@ unsafe void M2(X t) { } // void M1(X t) { } Diagnostic(ErrorCode.ERR_UnsafeNeeded, "X").WithLocation(6, 13)); } + + [Fact] + public void TestStructWithReferenceToItselfThroughAliasPointer1() + { + var csharp = @" +using unsafe X = S*; + +unsafe struct S +{ + X x; +} +"; + var comp = CreateCompilation(csharp, options: TestOptions.UnsafeDebugDll); + comp.VerifyDiagnostics( + // (6,7): warning CS0169: The field 'S.x' is never used + // X x; + Diagnostic(ErrorCode.WRN_UnreferencedField, "x").WithArguments("S.x").WithLocation(6, 7)); + + Assert.Equal(ManagedKind.Unmanaged, comp.GlobalNamespace.GetMember("S").ManagedKindNoUseSiteDiagnostics); + + // Try again with a fresh compilation, without having done anything to pull on this type. + comp = CreateCompilation(csharp, options: TestOptions.UnsafeDebugDll); + Assert.Equal(ManagedKind.Unmanaged, comp.GlobalNamespace.GetMember("S").ManagedKindNoUseSiteDiagnostics); + } + + [Fact] + public void TestStructWithReferenceToItselfThroughAliasPointer2() + { + var csharp = @" +using unsafe X = S*; + +unsafe struct S +{ + X x; +} + +class C +{ + void M(S s) + { + N(s); + } + + void N(T t) where T : unmanaged { } +} + +"; + var comp = CreateCompilation(csharp, options: TestOptions.UnsafeDebugDll); + comp.VerifyDiagnostics( + // (6,7): warning CS0169: The field 'S.x' is never used + // X x; + Diagnostic(ErrorCode.WRN_UnreferencedField, "x").WithArguments("S.x").WithLocation(6, 7)); + + Assert.Equal(ManagedKind.Unmanaged, comp.GlobalNamespace.GetMember("S").ManagedKindNoUseSiteDiagnostics); + + // Try again with a fresh compilation, without having done anything to pull on this type. + comp = CreateCompilation(csharp, options: TestOptions.UnsafeDebugDll); + Assert.Equal(ManagedKind.Unmanaged, comp.GlobalNamespace.GetMember("S").ManagedKindNoUseSiteDiagnostics); + } } } diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/UsingAliasTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/UsingAliasTests.cs index 813eb340ce3cd..73d0057986bf3 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/UsingAliasTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/UsingAliasTests.cs @@ -100,6 +100,9 @@ partial class A : Object {} var model = comp.GetSemanticModel(tree); + var usingAliasType = model.GetTypeInfo(usingAlias.NamespaceOrType).Type; + Assert.Equal(SpecialType.System_Object, usingAliasType.SpecialType); + var info1 = model.GetSemanticInfoSummary(base1); Assert.NotNull(info1.Symbol); var alias1 = model.GetAliasInfo((IdentifierNameSyntax)base1); @@ -140,7 +143,7 @@ partial class A : System.Object {} partial class A : Object {} "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -150,10 +153,10 @@ partial class A : Object {} var a3 = root.Members[2] as TypeDeclarationSyntax; var a4 = root.Members[3] as TypeDeclarationSyntax; - var base1 = a1.BaseList.Types[0].Type as TypeSyntax; - var base2 = a2.BaseList.Types[0].Type as TypeSyntax; - var base3 = a3.BaseList.Types[0].Type as TypeSyntax; - var base4 = a4.BaseList.Types[0].Type as TypeSyntax; + var base1 = a1.BaseList.Types[0].Type; + var base2 = a2.BaseList.Types[0].Type; + var base3 = a3.BaseList.Types[0].Type; + var base4 = a4.BaseList.Types[0].Type; var model = comp.GetSemanticModel(tree); @@ -195,7 +198,7 @@ partial class A : System.Object {} partial class A : Object {} "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -205,13 +208,16 @@ partial class A : Object {} var a3 = root.Members[2] as TypeDeclarationSyntax; var a4 = root.Members[3] as TypeDeclarationSyntax; - var base1 = a1.BaseList.Types[0].Type as TypeSyntax; - var base2 = a2.BaseList.Types[0].Type as TypeSyntax; - var base3 = a3.BaseList.Types[0].Type as TypeSyntax; - var base4 = a4.BaseList.Types[0].Type as TypeSyntax; + var base1 = a1.BaseList.Types[0].Type; + var base2 = a2.BaseList.Types[0].Type; + var base3 = a3.BaseList.Types[0].Type; + var base4 = a4.BaseList.Types[0].Type; var model = comp.GetSemanticModel(tree); + var usingAliasType = model.GetTypeInfo(usingAlias.NamespaceOrType).Type; + Assert.Equal(SpecialType.System_Object, usingAliasType.SpecialType); + var info1 = model.GetSemanticInfoSummary(base1); Assert.Equal("System.Object", info1.Type.ToDisplayString(format: SymbolDisplayFormat.TestFormat)); var alias1 = model.GetAliasInfo((IdentifierNameSyntax)base1); @@ -238,6 +244,40 @@ partial class A : Object {} Assert.Null(alias4); } + [Theory] + [InlineData("(int a, int b)", "(System.Int32 a, System.Int32 b)")] + [InlineData("int[]", "System.Int32[]")] + [InlineData("int?", "System.Int32?")] + [InlineData("int*", "System.Int32*")] + [InlineData("delegate*", "delegate*")] + [InlineData("dynamic", "dynamic")] + [InlineData("nint", "nint")] + public void GetAliasTypeInfo(string aliasType, string expected) + { + // Should get the same results in the semantic model regardless of whether the using has the 'unsafe' + // keyword or not. + getAliasTypeInfoHelper(""); + getAliasTypeInfoHelper("unsafe"); + + void getAliasTypeInfoHelper(string unsafeString) + { + var text = $"using {unsafeString} O = {aliasType};"; + var tree = Parse(text); + var root = tree.GetCompilationUnitRoot(); + var comp = CreateCompilation(tree); + + var usingAlias = root.Usings[0]; + + var model = comp.GetSemanticModel(tree); + + var usingAliasType = model.GetTypeInfo(usingAlias.NamespaceOrType).Type; + AssertEx.Equal(expected, usingAliasType.ToDisplayString(SymbolDisplayFormat.TestFormat)); + + var alias = model.GetDeclaredSymbol(usingAlias); + Assert.Equal(alias.Target, usingAliasType); + } + } + [Fact] public void BindType() { @@ -250,7 +290,7 @@ partial class A : System.Object {} partial class A : Object {} "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -260,10 +300,10 @@ partial class A : Object {} var a3 = root.Members[2] as TypeDeclarationSyntax; var a4 = root.Members[3] as TypeDeclarationSyntax; - var base1 = a1.BaseList.Types[0].Type as TypeSyntax; - var base2 = a2.BaseList.Types[0].Type as TypeSyntax; - var base3 = a3.BaseList.Types[0].Type as TypeSyntax; - var base4 = a4.BaseList.Types[0].Type as TypeSyntax; + var base1 = a1.BaseList.Types[0].Type; + var base2 = a2.BaseList.Types[0].Type; + var base3 = a3.BaseList.Types[0].Type; + var base4 = a4.BaseList.Types[0].Type; var model = comp.GetSemanticModel(tree); @@ -296,7 +336,7 @@ partial class A : System.Object {} partial class A : Object {} "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -306,10 +346,10 @@ partial class A : Object {} var a3 = root.Members[2] as TypeDeclarationSyntax; var a4 = root.Members[3] as TypeDeclarationSyntax; - var base1 = a1.BaseList.Types[0].Type as TypeSyntax; - var base2 = a2.BaseList.Types[0].Type as TypeSyntax; - var base3 = a3.BaseList.Types[0].Type as TypeSyntax; - var base4 = a4.BaseList.Types[0].Type as TypeSyntax; + var base1 = a1.BaseList.Types[0].Type; + var base2 = a2.BaseList.Types[0].Type; + var base3 = a3.BaseList.Types[0].Type; + var base4 = a4.BaseList.Types[0].Type; var model = comp.GetSemanticModel(tree); @@ -337,7 +377,7 @@ public void GetDeclaredSymbol01() @"using O = System.Object; "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -358,7 +398,7 @@ public void GetDeclaredSymbol01_Primitive() @"using O = object; "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -377,7 +417,7 @@ public void GetDeclaredSymbol02() { var text = "using System;"; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -396,7 +436,7 @@ public void LookupNames() class C {} "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -415,7 +455,7 @@ public void LookupNames_Primitive() class C {} "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -434,7 +474,7 @@ public void LookupSymbols() class C {} "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -455,7 +495,7 @@ public void LookupSymbols_Primitive() class C {} "; var tree = Parse(text); - var root = tree.GetCompilationUnitRoot() as CompilationUnitSyntax; + var root = tree.GetCompilationUnitRoot(); var comp = CreateCompilation(tree); var usingAlias = root.Usings[0]; @@ -478,7 +518,7 @@ namespace @foreach { } "; SyntaxTree syntaxTree = Parse(text); CSharpCompilation comp = CreateCompilation(syntaxTree); - UsingDirectiveSyntax usingAlias = (syntaxTree.GetCompilationUnitRoot() as CompilationUnitSyntax).Usings.First(); + UsingDirectiveSyntax usingAlias = syntaxTree.GetCompilationUnitRoot().Usings.First(); var alias = comp.GetSemanticModel(syntaxTree).GetDeclaredSymbol(usingAlias); Assert.Equal("for", alias.Name); Assert.Equal("@for", alias.ToString()); diff --git a/src/Compilers/CSharp/Test/Syntax/Generated/Syntax.Test.xml.Generated.cs b/src/Compilers/CSharp/Test/Syntax/Generated/Syntax.Test.xml.Generated.cs index ad886fc180cc6..61aaff019f167 100644 --- a/src/Compilers/CSharp/Test/Syntax/Generated/Syntax.Test.xml.Generated.cs +++ b/src/Compilers/CSharp/Test/Syntax/Generated/Syntax.Test.xml.Generated.cs @@ -2560,7 +2560,7 @@ public void TestUsingDirectiveFactoryAndProperties() Assert.Null(node.StaticKeyword); Assert.Null(node.UnsafeKeyword); Assert.Null(node.Alias); - Assert.NotNull(node.Type); + Assert.NotNull(node.NamespaceOrType); Assert.Equal(SyntaxKind.SemicolonToken, node.SemicolonToken.Kind); AttachAndCheckDiagnostics(node); @@ -12533,9 +12533,9 @@ public void TestUsingDirectiveFactoryAndProperties() Assert.Equal(SyntaxKind.None, node.StaticKeyword.Kind()); Assert.Equal(SyntaxKind.None, node.UnsafeKeyword.Kind()); Assert.Null(node.Alias); - Assert.NotNull(node.Type); + Assert.NotNull(node.NamespaceOrType); Assert.Equal(SyntaxKind.SemicolonToken, node.SemicolonToken.Kind()); - var newNode = node.WithGlobalKeyword(node.GlobalKeyword).WithUsingKeyword(node.UsingKeyword).WithStaticKeyword(node.StaticKeyword).WithUnsafeKeyword(node.UnsafeKeyword).WithAlias(node.Alias).WithType(node.Type).WithSemicolonToken(node.SemicolonToken); + var newNode = node.WithGlobalKeyword(node.GlobalKeyword).WithUsingKeyword(node.UsingKeyword).WithStaticKeyword(node.StaticKeyword).WithUnsafeKeyword(node.UnsafeKeyword).WithAlias(node.Alias).WithNamespaceOrType(node.NamespaceOrType).WithSemicolonToken(node.SemicolonToken); Assert.Equal(node, newNode); } diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/UsingDirectiveParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/UsingDirectiveParsingTests.cs index da9e6f8b8e3ed..8529dd52b6151 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/UsingDirectiveParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/UsingDirectiveParsingTests.cs @@ -944,7 +944,44 @@ public void AliasUsingDirectivePredefinedType_CSharp11() } [Fact] - public void AliasUsingDirectivePredefinedType() + public void AliasUsingDirectivePredefinedType_CSharp12() + { + var text = @"using x = int;"; + UsingTree(text); + CreateCompilation(text, parseOptions: TestOptions.RegularNext).VerifyDiagnostics( + // (1,1): hidden CS8019: Unnecessary using directive. + // using x = int; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using x = int;").WithLocation(1, 1), + // (1,7): warning CS8981: The type name 'x' only contains lower-cased ascii characters. Such names may become reserved for the language. + // using x = int; + Diagnostic(ErrorCode.WRN_LowerCaseTypeName, "x").WithArguments("x").WithLocation(1, 7)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingDirectivePredefinedType_Preview() { var text = @"using x = int;"; UsingTree(text); @@ -1024,6 +1061,51 @@ public void AliasUsingDirectiveRefType() EOF(); } + [Fact] + public void AliasUsingDirectiveRefReadonlyType() + { + var text = @"using x = ref readonly int;"; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (1,1): hidden CS8019: Unnecessary using directive. + // using x = ref readonly int; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using x = ref readonly int;").WithLocation(1, 1), + // (1,7): warning CS8981: The type name 'x' only contains lower-cased ascii characters. Such names may become reserved for the language. + // using x = ref readonly int; + Diagnostic(ErrorCode.WRN_LowerCaseTypeName, "x").WithArguments("x").WithLocation(1, 7), + // (1,11): error CS9105: Using alias cannot be a 'ref' type. + // using x = ref readonly int; + Diagnostic(ErrorCode.ERR_BadRefInUsingAlias, "ref").WithLocation(1, 11)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "x"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.RefType); + { + N(SyntaxKind.RefKeyword); + N(SyntaxKind.ReadOnlyKeyword); + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + [Fact] public void AliasUsingDirectivePredefinedTypePointer1() { @@ -1506,7 +1588,7 @@ namespace N } [Fact] - public void AliasUsingDirectiveTuple() + public void AliasUsingDirectiveTuple1() { var text = @"using x = (int, int);"; UsingTree(text); @@ -1558,6 +1640,215 @@ public void AliasUsingDirectiveTuple() EOF(); } + [Fact] + public void AliasUsingDirectiveTuple2() + { + var text = """ + using X = (int, int); + + class C + { + X x = (0, 0); + } + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (5,7): warning CS0414: The field 'C.x' is assigned but its value is never used + // X x = (0, 0); + Diagnostic(ErrorCode.WRN_UnreferencedFieldAssg, "x").WithArguments("C.x").WithLocation(5, 7)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.TupleType); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.TupleElement); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.TupleElement); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.ClassDeclaration); + { + N(SyntaxKind.ClassKeyword); + N(SyntaxKind.IdentifierToken, "C"); + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.FieldDeclaration); + { + N(SyntaxKind.VariableDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.VariableDeclarator); + { + N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.EqualsValueClause); + { + N(SyntaxKind.EqualsToken); + N(SyntaxKind.TupleExpression); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Argument); + { + N(SyntaxKind.NumericLiteralExpression); + { + N(SyntaxKind.NumericLiteralToken, "0"); + } + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.Argument); + { + N(SyntaxKind.NumericLiteralExpression); + { + N(SyntaxKind.NumericLiteralToken, "0"); + } + } + N(SyntaxKind.CloseParenToken); + } + } + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingDirectiveTuple3() + { + var text = """ + using X = (int, int); + + class C + { + X x = (true, false); + } + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (5,12): error CS0029: Cannot implicitly convert type 'bool' to 'int' + // X x = (true, false); + Diagnostic(ErrorCode.ERR_NoImplicitConv, "true").WithArguments("bool", "int").WithLocation(5, 12), + // (5,18): error CS0029: Cannot implicitly convert type 'bool' to 'int' + // X x = (true, false); + Diagnostic(ErrorCode.ERR_NoImplicitConv, "false").WithArguments("bool", "int").WithLocation(5, 18)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.TupleType); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.TupleElement); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.TupleElement); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.ClassDeclaration); + { + N(SyntaxKind.ClassKeyword); + N(SyntaxKind.IdentifierToken, "C"); + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.FieldDeclaration); + { + N(SyntaxKind.VariableDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.VariableDeclarator); + { + N(SyntaxKind.IdentifierToken, "x"); + N(SyntaxKind.EqualsValueClause); + { + N(SyntaxKind.EqualsToken); + N(SyntaxKind.TupleExpression); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Argument); + { + N(SyntaxKind.TrueLiteralExpression); + { + N(SyntaxKind.TrueKeyword); + } + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.Argument); + { + N(SyntaxKind.FalseLiteralExpression); + { + N(SyntaxKind.FalseKeyword); + } + } + N(SyntaxKind.CloseParenToken); + } + } + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + [Fact] public void AliasUsingNullableValueType() { @@ -1600,7 +1891,7 @@ public void AliasUsingNullableValueType() } [Fact] - public void AliasUsingNullableReferenceType() + public void AliasUsingNullableReferenceType1() { var text = @"using x = string?;"; UsingTree(text); @@ -1647,41 +1938,237 @@ public void AliasUsingNullableReferenceType() } [Fact] - public void AliasUsingVoidPointer1() + public void AliasUsingNullableReferenceType2() { - var text = @"using unsafe VP = void*; - -class C -{ - void M(VP vp) { } -}"; + var text = """ + #nullable enable + using X = string?; + """; UsingTree(text); - CreateCompilation(text, options: TestOptions.UnsafeDebugDll).VerifyDiagnostics( - // (5,12): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context - // void M(VP vp) { } - Diagnostic(ErrorCode.ERR_UnsafeNeeded, "VP").WithLocation(5, 12)); + CreateCompilation(text).VerifyDiagnostics( + // (2,1): hidden CS8019: Unnecessary using directive. + // using X = string?; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = string?;").WithLocation(2, 1), + // (2,17): error CS9107: Using alias cannot be a nullable reference type. + // using X = string?; + Diagnostic(ErrorCode.ERR_BadNullableReferenceTypeInUsingAlias, "?").WithLocation(2, 17)); N(SyntaxKind.CompilationUnit); { N(SyntaxKind.UsingDirective); { N(SyntaxKind.UsingKeyword); - N(SyntaxKind.UnsafeKeyword); N(SyntaxKind.NameEquals); { N(SyntaxKind.IdentifierName); { - N(SyntaxKind.IdentifierToken, "VP"); + N(SyntaxKind.IdentifierToken, "X"); } N(SyntaxKind.EqualsToken); } - N(SyntaxKind.PointerType); + N(SyntaxKind.NullableType); { N(SyntaxKind.PredefinedType); { - N(SyntaxKind.VoidKeyword); + N(SyntaxKind.StringKeyword); } - N(SyntaxKind.AsteriskToken); + N(SyntaxKind.QuestionToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingNullableReferenceType3() + { + var text = """ + using X = string; + namespace N + { + using Y = X?; + } + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (4,5): hidden CS8019: Unnecessary using directive. + // using Y = X?; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using Y = X?;").WithLocation(4, 5), + // (4,16): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. + // using Y = X?; + Diagnostic(ErrorCode.WRN_MissingNonNullTypesContextForAnnotation, "?").WithLocation(4, 16), + // (4,16): error CS9107: Using alias cannot be a nullable reference type. + // using Y = X?; + Diagnostic(ErrorCode.ERR_BadNullableReferenceTypeInUsingAlias, "?").WithLocation(4, 16)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.StringKeyword); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.NamespaceDeclaration); + { + N(SyntaxKind.NamespaceKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "N"); + } + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "Y"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.NullableType); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.QuestionToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingNullableReferenceType4() + { + var text = """ + #nullable enable + using X = string; + namespace N + { + using Y = X?; + } + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (5,5): hidden CS8019: Unnecessary using directive. + // using Y = X?; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using Y = X?;").WithLocation(5, 5), + // (5,16): error CS9107: Using alias cannot be a nullable reference type. + // using Y = X?; + Diagnostic(ErrorCode.ERR_BadNullableReferenceTypeInUsingAlias, "?").WithLocation(5, 16)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.StringKeyword); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.NamespaceDeclaration); + { + N(SyntaxKind.NamespaceKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "N"); + } + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "Y"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.NullableType); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.QuestionToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingVoidPointer1() + { + var text = @"using unsafe VP = void*; + +class C +{ + void M(VP vp) { } +}"; + UsingTree(text); + CreateCompilation(text, options: TestOptions.UnsafeDebugDll).VerifyDiagnostics( + // (5,12): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context + // void M(VP vp) { } + Diagnostic(ErrorCode.ERR_UnsafeNeeded, "VP").WithLocation(5, 12)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.UnsafeKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "VP"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.PointerType); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.VoidKeyword); + } + N(SyntaxKind.AsteriskToken); } N(SyntaxKind.SemicolonToken); } @@ -2497,4 +2984,1097 @@ void M(D d) } EOF(); } + + [Fact] + public void AliasUsingDirectiveDynamic4() + { + var text = @" +using D = dynamic; + +class dynamic +{ + void M(D d) + { + d.Goo(); + } +}"; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (4,7): warning CS8981: The type name 'dynamic' only contains lower-cased ascii characters. Such names may become reserved for the language. + // class dynamic + Diagnostic(ErrorCode.WRN_LowerCaseTypeName, "dynamic").WithArguments("dynamic").WithLocation(4, 7), + // (8,11): error CS1061: 'dynamic' does not contain a definition for 'Goo' and no accessible extension method 'Goo' accepting a first argument of type 'dynamic' could be found (are you missing a using directive or an assembly reference?) + // d.Goo(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "Goo").WithArguments("dynamic", "Goo").WithLocation(8, 11)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "D"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "dynamic"); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.ClassDeclaration); + { + N(SyntaxKind.ClassKeyword); + N(SyntaxKind.IdentifierToken, "dynamic"); + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.MethodDeclaration); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.VoidKeyword); + } + N(SyntaxKind.IdentifierToken, "M"); + N(SyntaxKind.ParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "D"); + } + N(SyntaxKind.IdentifierToken, "d"); + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.Block); + { + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.ExpressionStatement); + { + N(SyntaxKind.InvocationExpression); + { + N(SyntaxKind.SimpleMemberAccessExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "d"); + } + N(SyntaxKind.DotToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "Goo"); + } + } + N(SyntaxKind.ArgumentList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.CloseParenToken); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.CloseBraceToken); + } + } + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingDirectiveDynamic5() + { + var text = @" +// Note: this is weird, but is supported by language. It checks just that the ValueText is `dynamic`, not the raw text. +using D = @dynamic; + +class C +{ + void M(D d) + { + d.Goo(); + } +}"; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics(); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "D"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "@dynamic"); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.ClassDeclaration); + { + N(SyntaxKind.ClassKeyword); + N(SyntaxKind.IdentifierToken, "C"); + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.MethodDeclaration); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.VoidKeyword); + } + N(SyntaxKind.IdentifierToken, "M"); + N(SyntaxKind.ParameterList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.Parameter); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "D"); + } + N(SyntaxKind.IdentifierToken, "d"); + } + N(SyntaxKind.CloseParenToken); + } + N(SyntaxKind.Block); + { + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.ExpressionStatement); + { + N(SyntaxKind.InvocationExpression); + { + N(SyntaxKind.SimpleMemberAccessExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "d"); + } + N(SyntaxKind.DotToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "Goo"); + } + } + N(SyntaxKind.ArgumentList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.CloseParenToken); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.CloseBraceToken); + } + } + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingDuplicate1() + { + var text = """ + using X = int?; + using X = System; + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (1,1): hidden CS8019: Unnecessary using directive. + // using X = int?; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = int?;").WithLocation(1, 1), + // (2,1): hidden CS8019: Unnecessary using directive. + // using X = System; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = System;").WithLocation(2, 1), + // (2,7): error CS1537: The using alias 'X' appeared previously in this namespace + // using X = System; + Diagnostic(ErrorCode.ERR_DuplicateAlias, "X").WithArguments("X").WithLocation(2, 7)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.NullableType); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.QuestionToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "System"); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingDuplicate2() + { + var text = """ + using X = int?; + using X = int; + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (1,1): hidden CS8019: Unnecessary using directive. + // using X = int?; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = int?;").WithLocation(1, 1), + // (2,1): hidden CS8019: Unnecessary using directive. + // using X = int; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = int;").WithLocation(2, 1), + // (2,7): error CS1537: The using alias 'X' appeared previously in this namespace + // using X = int; + Diagnostic(ErrorCode.ERR_DuplicateAlias, "X").WithArguments("X").WithLocation(2, 7)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.NullableType); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.QuestionToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingDuplicate3() + { + var text = """ + using X = int?; + using X = System.Int32; + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (1,1): hidden CS8019: Unnecessary using directive. + // using X = int?; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = int?;").WithLocation(1, 1), + // (2,1): hidden CS8019: Unnecessary using directive. + // using X = System.Int32; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = System.Int32;").WithLocation(2, 1), + // (2,7): error CS1537: The using alias 'X' appeared previously in this namespace + // using X = System.Int32; + Diagnostic(ErrorCode.ERR_DuplicateAlias, "X").WithArguments("X").WithLocation(2, 7)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.NullableType); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.QuestionToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.QualifiedName); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "System"); + } + N(SyntaxKind.DotToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "Int32"); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void AliasUsingNotDuplicate1() + { + var text = """ + using X = int?; + namespace N; + using X = int; + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (1,1): hidden CS8019: Unnecessary using directive. + // using X = int?; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = int?;").WithLocation(1, 1), + // (3,1): hidden CS8019: Unnecessary using directive. + // using X = int; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = int;").WithLocation(3, 1)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.NullableType); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.QuestionToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.FileScopedNamespaceDeclaration); + { + N(SyntaxKind.NamespaceKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "N"); + } + N(SyntaxKind.SemicolonToken); + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + N(SyntaxKind.SemicolonToken); + } + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void TestScopedType1() + { + var text = @" +using scoped int; +"; + + UsingTree(text, + // (2,14): error CS1002: ; expected + // using scoped int; + Diagnostic(ErrorCode.ERR_SemicolonExpected, "int").WithLocation(2, 14), + // (2,17): error CS1001: Identifier expected + // using scoped int; + Diagnostic(ErrorCode.ERR_IdentifierExpected, ";").WithLocation(2, 17)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "scoped"); + } + M(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.GlobalStatement); + { + N(SyntaxKind.LocalDeclarationStatement); + { + N(SyntaxKind.VariableDeclaration); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + M(SyntaxKind.VariableDeclarator); + { + M(SyntaxKind.IdentifierToken); + } + } + N(SyntaxKind.SemicolonToken); + } + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void TestScopedType2() + { + var text = @" +using X = scoped int; +"; + + UsingTree(text, + // (2,18): error CS1002: ; expected + // using X = scoped int; + Diagnostic(ErrorCode.ERR_SemicolonExpected, "int").WithLocation(2, 18), + // (2,21): error CS1001: Identifier expected + // using X = scoped int; + Diagnostic(ErrorCode.ERR_IdentifierExpected, ";").WithLocation(2, 21)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "scoped"); + } + M(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.GlobalStatement); + { + N(SyntaxKind.LocalDeclarationStatement); + { + N(SyntaxKind.VariableDeclaration); + { + N(SyntaxKind.PredefinedType); + { + N(SyntaxKind.IntKeyword); + } + M(SyntaxKind.VariableDeclarator); + { + M(SyntaxKind.IdentifierToken); + } + } + N(SyntaxKind.SemicolonToken); + } + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void TestScopedType3() + { + var text = @" +using X = scoped System; +"; + UsingTree(text, + // (2,18): error CS1002: ; expected + // using X = scoped System; + Diagnostic(ErrorCode.ERR_SemicolonExpected, "System").WithLocation(2, 18)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "scoped"); + } + M(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.GlobalStatement); + { + N(SyntaxKind.ExpressionStatement); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "System"); + } + N(SyntaxKind.SemicolonToken); + } + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void TestScopedType4() + { + var text = @" +using X = scoped System.AppDomain; +"; + + UsingTree(text, + // (2,18): error CS1002: ; expected + // using X = scoped System.AppDomain; + Diagnostic(ErrorCode.ERR_SemicolonExpected, "System").WithLocation(2, 18)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "scoped"); + } + M(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.GlobalStatement); + { + N(SyntaxKind.ExpressionStatement); + { + N(SyntaxKind.SimpleMemberAccessExpression); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "System"); + } + N(SyntaxKind.DotToken); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "AppDomain"); + } + } + N(SyntaxKind.SemicolonToken); + } + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void TestObsolete1() + { + var text = """ + using System; + using X = C; + + [Obsolete("", error: true)] + class C + { + } + + class D + { + X x; + C c; + } + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (11,5): error CS0619: 'C' is obsolete: '' + // X x; + Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "X").WithArguments("C", "").WithLocation(11, 5), + // (11,7): warning CS0169: The field 'D.x' is never used + // X x; + Diagnostic(ErrorCode.WRN_UnreferencedField, "x").WithArguments("D.x").WithLocation(11, 7), + // (12,5): error CS0619: 'C' is obsolete: '' + // C c; + Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "C").WithArguments("C", "").WithLocation(12, 5), + // (12,7): warning CS0169: The field 'D.c' is never used + // C c; + Diagnostic(ErrorCode.WRN_UnreferencedField, "c").WithArguments("D.c").WithLocation(12, 7)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "System"); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.ClassDeclaration); + { + N(SyntaxKind.AttributeList); + { + N(SyntaxKind.OpenBracketToken); + N(SyntaxKind.Attribute); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "Obsolete"); + } + N(SyntaxKind.AttributeArgumentList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.AttributeArgument); + { + N(SyntaxKind.StringLiteralExpression); + { + N(SyntaxKind.StringLiteralToken, "\"\""); + } + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.AttributeArgument); + { + N(SyntaxKind.NameColon); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "error"); + } + N(SyntaxKind.ColonToken); + } + N(SyntaxKind.TrueLiteralExpression); + { + N(SyntaxKind.TrueKeyword); + } + } + N(SyntaxKind.CloseParenToken); + } + } + N(SyntaxKind.CloseBracketToken); + } + N(SyntaxKind.ClassKeyword); + N(SyntaxKind.IdentifierToken, "C"); + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.ClassDeclaration); + { + N(SyntaxKind.ClassKeyword); + N(SyntaxKind.IdentifierToken, "D"); + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.FieldDeclaration); + { + N(SyntaxKind.VariableDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.VariableDeclarator); + { + N(SyntaxKind.IdentifierToken, "x"); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.FieldDeclaration); + { + N(SyntaxKind.VariableDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.VariableDeclarator); + { + N(SyntaxKind.IdentifierToken, "c"); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void TestObsolete2() + { + var text = """ + using System; + using X = C[]; + + [Obsolete("", error: true)] + class C + { + } + + class D + { + X x1; + C[] c1; + } + """; + UsingTree(text); + CreateCompilation(text).VerifyDiagnostics( + // (11,5): error CS0619: 'C' is obsolete: '' + // X x1; + Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "X").WithArguments("C", "").WithLocation(11, 5), + // (11,7): warning CS0169: The field 'D.x1' is never used + // X x1; + Diagnostic(ErrorCode.WRN_UnreferencedField, "x1").WithArguments("D.x1").WithLocation(11, 7), + // (12,5): error CS0619: 'C' is obsolete: '' + // C[] c1; + Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "C").WithArguments("C", "").WithLocation(12, 5), + // (12,9): warning CS0169: The field 'D.c1' is never used + // C[] c1; + Diagnostic(ErrorCode.WRN_UnreferencedField, "c1").WithArguments("D.c1").WithLocation(12, 9)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "System"); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + N(SyntaxKind.ArrayType); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.ArrayRankSpecifier); + { + N(SyntaxKind.OpenBracketToken); + N(SyntaxKind.OmittedArraySizeExpression); + { + N(SyntaxKind.OmittedArraySizeExpressionToken); + } + N(SyntaxKind.CloseBracketToken); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.ClassDeclaration); + { + N(SyntaxKind.AttributeList); + { + N(SyntaxKind.OpenBracketToken); + N(SyntaxKind.Attribute); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "Obsolete"); + } + N(SyntaxKind.AttributeArgumentList); + { + N(SyntaxKind.OpenParenToken); + N(SyntaxKind.AttributeArgument); + { + N(SyntaxKind.StringLiteralExpression); + { + N(SyntaxKind.StringLiteralToken, "\"\""); + } + } + N(SyntaxKind.CommaToken); + N(SyntaxKind.AttributeArgument); + { + N(SyntaxKind.NameColon); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "error"); + } + N(SyntaxKind.ColonToken); + } + N(SyntaxKind.TrueLiteralExpression); + { + N(SyntaxKind.TrueKeyword); + } + } + N(SyntaxKind.CloseParenToken); + } + } + N(SyntaxKind.CloseBracketToken); + } + N(SyntaxKind.ClassKeyword); + N(SyntaxKind.IdentifierToken, "C"); + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.ClassDeclaration); + { + N(SyntaxKind.ClassKeyword); + N(SyntaxKind.IdentifierToken, "D"); + N(SyntaxKind.OpenBraceToken); + N(SyntaxKind.FieldDeclaration); + { + N(SyntaxKind.VariableDeclaration); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.VariableDeclarator); + { + N(SyntaxKind.IdentifierToken, "x1"); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.FieldDeclaration); + { + N(SyntaxKind.VariableDeclaration); + { + N(SyntaxKind.ArrayType); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "C"); + } + N(SyntaxKind.ArrayRankSpecifier); + { + N(SyntaxKind.OpenBracketToken); + N(SyntaxKind.OmittedArraySizeExpression); + { + N(SyntaxKind.OmittedArraySizeExpressionToken); + } + N(SyntaxKind.CloseBracketToken); + } + } + N(SyntaxKind.VariableDeclarator); + { + N(SyntaxKind.IdentifierToken, "c1"); + } + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.CloseBraceToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void TestArgList() + { + var text = @" +using X = __arglist; +"; + + var comp = CreateCompilation(text); + comp.VerifyDiagnostics( + // (2,1): hidden CS8019: Unnecessary using directive. + // using X = __arglist; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = __arglist;").WithLocation(2, 1), + // (2,11): error CS1031: Type expected + // using X = __arglist; + Diagnostic(ErrorCode.ERR_TypeExpected, "__arglist").WithLocation(2, 11)); + + UsingTree(text, + // (2,11): error CS1031: Type expected + // using X = __arglist; + Diagnostic(ErrorCode.ERR_TypeExpected, "__arglist").WithLocation(2, 11)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } + + [Fact] + public void TestMakeref() + { + var text = @" +using X = __makeref; +"; + + var comp = CreateCompilation(text); + comp.VerifyDiagnostics( + // (2,1): hidden CS8019: Unnecessary using directive. + // using X = __makeref; + Diagnostic(ErrorCode.HDN_UnusedUsingDirective, "using X = __makeref;").WithLocation(2, 1), + // (2,11): error CS1031: Type expected + // using X = __makeref; + Diagnostic(ErrorCode.ERR_TypeExpected, "__makeref").WithLocation(2, 11)); + + UsingTree(text, + // (2,11): error CS1031: Type expected + // using X = __makeref; + Diagnostic(ErrorCode.ERR_TypeExpected, "__makeref").WithLocation(2, 11)); + + N(SyntaxKind.CompilationUnit); + { + N(SyntaxKind.UsingDirective); + { + N(SyntaxKind.UsingKeyword); + N(SyntaxKind.NameEquals); + { + N(SyntaxKind.IdentifierName); + { + N(SyntaxKind.IdentifierToken, "X"); + } + N(SyntaxKind.EqualsToken); + } + M(SyntaxKind.IdentifierName); + { + M(SyntaxKind.IdentifierToken); + } + N(SyntaxKind.SemicolonToken); + } + N(SyntaxKind.EndOfFileToken); + } + EOF(); + } } diff --git a/src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxNormalizerTests.cs b/src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxNormalizerTests.cs index 31c0230e2ba6d..9ed99dfe79149 100644 --- a/src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxNormalizerTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxNormalizerTests.cs @@ -5882,6 +5882,22 @@ void M() """); } + [Theory] + [InlineData("using X=int ;", "using X = int;")] + [InlineData("global using X=int ;", "global using X = int;")] + [InlineData("using X=nint;", "using X = nint;")] + [InlineData("using X=dynamic;", "using X = dynamic;")] + [InlineData("using X=int [] ;", "using X = int[];")] + [InlineData("using X=(int,int) ;", "using X = (int, int);")] + [InlineData("using unsafe X=int * ;", "using unsafe X = int*;")] + [InlineData("global using unsafe X=int * ;", "global using unsafe X = int*;")] + [InlineData("using X=int ?;", "using X = int?;")] + [InlineData("using X=delegate * ;", "using X = delegate*;")] + public void TestNormalizeUsingAlias(string text, string expected) + { + TestNormalizeDeclaration(text, expected); + } + private static void VerifySingleLineInitializer(string text, string expected) { TestNormalizeExpression( diff --git a/src/EditorFeatures/CSharp/AutomaticCompletion/AutomaticLineEnderCommandHandler.cs b/src/EditorFeatures/CSharp/AutomaticCompletion/AutomaticLineEnderCommandHandler.cs index ccf7391ee54b8..681bf87c5f920 100644 --- a/src/EditorFeatures/CSharp/AutomaticCompletion/AutomaticLineEnderCommandHandler.cs +++ b/src/EditorFeatures/CSharp/AutomaticCompletion/AutomaticLineEnderCommandHandler.cs @@ -223,7 +223,7 @@ private static bool CheckLocation(SourceText text, int position, SyntaxNode owni } // check whether using has contents - if (owningNode is UsingDirectiveSyntax u && u.Type.IsMissing) + if (owningNode is UsingDirectiveSyntax u && u.NamespaceOrType.IsMissing) { return false; } diff --git a/src/EditorFeatures/CSharpTest/Classification/SemanticClassifierTests.cs b/src/EditorFeatures/CSharpTest/Classification/SemanticClassifierTests.cs index cffa1ed465e82..aed6dec49cdc8 100644 --- a/src/EditorFeatures/CSharpTest/Classification/SemanticClassifierTests.cs +++ b/src/EditorFeatures/CSharpTest/Classification/SemanticClassifierTests.cs @@ -41,8 +41,7 @@ protected override async Task> GetClassificationS return await GetSemanticClassificationsAsync(document, span); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericClassDeclaration(TestHost testHost) { await TestInMethodAsync( @@ -53,8 +52,7 @@ await TestInMethodAsync( Class("Class")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task RefVar(TestHost testHost) { await TestInMethodAsync( @@ -63,8 +61,7 @@ await TestInMethodAsync( Classifications(Keyword("var"), Local("i"))); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UsingAlias1(TestHost testHost) { await TestAsync( @@ -76,8 +73,7 @@ await TestAsync( Static("Math")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsTypeArgument(TestHost testHost) { await TestInMethodAsync( @@ -88,8 +84,7 @@ await TestInMethodAsync( Classifications(Class("Class"), Keyword("dynamic"))); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UsingTypeAliases(TestHost testHost) { var code = @"using Alias = Test; @@ -106,8 +101,7 @@ await TestAsync(code, Class("Alias")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicTypeAlias(TestHost testHost) { await TestAsync( @@ -125,8 +119,7 @@ class C Class("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsDelegateName(TestHost testHost) { await TestAsync( @@ -143,8 +136,7 @@ void M() Delegate("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsInterfaceName(TestHost testHost) { await TestAsync( @@ -160,8 +152,7 @@ class C Interface("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsEnumName(TestHost testHost) { await TestAsync( @@ -177,8 +168,7 @@ class C Enum("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsClassName(TestHost testHost) { await TestAsync( @@ -194,8 +184,7 @@ class C Class("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(46985, "https://github.com/dotnet/roslyn/issues/46985")] public async Task DynamicAsRecordName(TestHost testHost) { @@ -212,8 +201,7 @@ class C RecordClass("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsClassNameAndLocalVariableName(TestHost testHost) { await TestAsync( @@ -228,8 +216,7 @@ await TestAsync( Class("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsStructName(TestHost testHost) { await TestAsync( @@ -245,8 +232,7 @@ class C Struct("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericClassName(TestHost testHost) { await TestAsync( @@ -262,8 +248,7 @@ class C Class("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericClassNameButOtherArity(TestHost testHost) { await TestAsync( @@ -279,8 +264,7 @@ class C Keyword("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsUndefinedGenericType(TestHost testHost) { await TestAsync( @@ -296,8 +280,7 @@ class C Class("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsExternAlias(TestHost testHost) { await TestAsync( @@ -311,8 +294,7 @@ class C Namespace("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericClassNameButOtherArity(TestHost testHost) { await TestAsync( @@ -327,8 +309,7 @@ class C Class("A")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericTypeParameter(TestHost testHost) { await TestAsync( @@ -342,8 +323,7 @@ void M() TypeParameter("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericMethodTypeParameter(TestHost testHost) { await TestAsync( @@ -360,8 +340,7 @@ T M(T t) TypeParameter("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericMethodTypeParameterInLocalVariableDeclaration(TestHost testHost) { await TestAsync( @@ -376,8 +355,7 @@ void M() TypeParameter("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ParameterOfLambda1(TestHost testHost) { await TestAsync( @@ -393,8 +371,7 @@ await TestAsync( Class("C")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ParameterOfAnonymousMethod(TestHost testHost) { await TestAsync( @@ -410,8 +387,7 @@ await TestAsync( Class("C")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericTypeParameterAfterWhere(TestHost testHost) { await TestAsync( @@ -423,8 +399,7 @@ await TestAsync( TypeParameter("B")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BaseClass(TestHost testHost) { await TestAsync( @@ -439,8 +414,7 @@ class C2 : C Class("C")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BaseInterfaceOnInterface(TestHost testHost) { await TestAsync( @@ -455,8 +429,7 @@ interface T2 : T Interface("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BaseInterfaceOnClass(TestHost testHost) { await TestAsync( @@ -471,8 +444,7 @@ class T2 : T Interface("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task InterfaceColorColor(TestHost testHost) { await TestAsync( @@ -489,8 +461,7 @@ class T2 : T Interface("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DelegateColorColor(TestHost testHost) { await TestAsync( @@ -504,8 +475,7 @@ class T2 Delegate("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DelegateReturnsItself(TestHost testHost) { await TestAsync( @@ -521,8 +491,7 @@ class C Delegate("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StructColorColor(TestHost testHost) { await TestAsync( @@ -534,8 +503,7 @@ await TestAsync( Struct("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task EnumColorColor(TestHost testHost) { await TestAsync( @@ -553,8 +521,7 @@ class C Enum("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericTypeParameter(TestHost testHost) { await TestAsync( @@ -566,8 +533,7 @@ await TestAsync( TypeParameter("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericFieldName(TestHost testHost) { await TestAsync( @@ -579,8 +545,7 @@ await TestAsync( TypeParameter("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PropertySameNameAsClass(TestHost testHost) { await TestAsync( @@ -605,8 +570,7 @@ void M() Property("N")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeWithoutAttributeSuffix(TestHost testHost) { await TestAsync( @@ -621,8 +585,7 @@ class C Class("Obsolete")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeOnNonExistingMember(TestHost testHost) { await TestAsync( @@ -637,8 +600,7 @@ class A Class("Obsolete")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeWithoutAttributeSuffixOnAssembly(TestHost testHost) { await TestAsync( @@ -655,8 +617,7 @@ class MyAttribute : Attribute Class("Attribute")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeViaNestedClassOrDerivedClass(TestHost testHost) { await TestAsync( @@ -684,8 +645,7 @@ class Derived : Base Class("Base")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NamedAndOptional(TestHost testHost) { await TestAsync( @@ -706,8 +666,7 @@ void M() Parameter("C")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PartiallyWrittenGenericName1(TestHost testHost) { await TestInMethodAsync( @@ -718,8 +677,7 @@ await TestInMethodAsync( Class("Class")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PartiallyWrittenGenericName2(TestHost testHost) { await TestInMethodAsync( @@ -734,8 +692,7 @@ await TestInMethodAsync( // a property name is the same as a type name // and the resulting ambiguities that the spec // resolves in favor of properties - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor(TestHost testHost) { await TestAsync( @@ -747,8 +704,7 @@ await TestAsync( Class("Color")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor2(TestHost testHost) { await TestAsync( @@ -768,8 +724,7 @@ await TestAsync( Class("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor3(TestHost testHost) { await TestAsync( @@ -795,8 +750,7 @@ await TestAsync( /// Instance field should be preferred to type /// §7.5.4.1 /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor4(TestHost testHost) { await TestAsync( @@ -819,8 +773,7 @@ void M() /// Type should be preferred to a static field /// §7.5.4.1 /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor5(TestHost testHost) { await TestAsync( @@ -843,8 +796,7 @@ void M() /// /// Needs to prefer the local /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor6(TestHost testHost) { await TestAsync( @@ -868,8 +820,7 @@ void M() /// /// Needs to prefer the type /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor7(TestHost testHost) { await TestAsync( @@ -891,8 +842,7 @@ void M() Static("field")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor8(TestHost testHost) { await TestAsync( @@ -916,8 +866,7 @@ void M2() Local("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor9(TestHost testHost) { await TestAsync( @@ -937,8 +886,7 @@ T M(T T) Parameter("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor10(TestHost testHost) { // note: 'var' now binds to the type of the local. @@ -958,8 +906,7 @@ void M() Class("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor11(TestHost testHost) { await TestAsync( @@ -977,8 +924,7 @@ void M() Class("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor12(TestHost testHost) { await TestAsync( @@ -997,8 +943,7 @@ void M() Class("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor13(TestHost testHost) { await TestAsync( @@ -1017,8 +962,7 @@ void M() Class("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ColorColor14(TestHost testHost) { await TestAsync( @@ -1037,8 +981,7 @@ void M() Local("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NamespaceNameSameAsTypeName1(TestHost testHost) { await TestAsync( @@ -1058,8 +1001,7 @@ void M() Class("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NamespaceNameSameAsTypeNameWithGlobal(TestHost testHost) { await TestAsync( @@ -1081,8 +1023,7 @@ void M() Class("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AmbiguityTypeAsGenericMethodArgumentVsLocal(TestHost testHost) { await TestAsync( @@ -1100,8 +1041,7 @@ void M() TypeParameter("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AmbiguityTypeAsGenericArgumentVsLocal(TestHost testHost) { await TestAsync( @@ -1125,8 +1065,7 @@ void M() Class("T")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AmbiguityTypeAsGenericArgumentVsField(TestHost testHost) { await TestAsync( @@ -1154,8 +1093,7 @@ void M() /// /// §7.5.4.2 /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GrammarAmbiguity_7_5_4_2(TestHost testHost) { await TestAsync( @@ -1192,8 +1130,7 @@ class B Class("B")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AnonymousTypePropertyName(TestHost testHost) { await TestAsync( @@ -1210,8 +1147,7 @@ void M() Property("String")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task YieldAsATypeName(TestHost testHost) { await TestAsync( @@ -1236,8 +1172,7 @@ IEnumerable M() Local("yield")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TypeNameDottedNames(TestHost testHost) { await TestAsync( @@ -1254,8 +1189,7 @@ class Nested Class("Nested")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BindingTypeNameFromBCLViaGlobalAlias(TestHost testHost) { await TestAsync( @@ -1271,8 +1205,7 @@ class C Class("String")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BindingTypeNames(TestHost testHost) { var code = @"using System; @@ -1308,8 +1241,7 @@ await TestAsync(code, Class("String")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task Constructors(TestHost testHost) { await TestAsync( @@ -1340,8 +1272,7 @@ public C() Class("C")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TypesOfClassMembers(TestHost testHost) { await TestAsync( @@ -1406,8 +1337,7 @@ static operator Type(int other) /// /// NAQ = Namespace Alias Qualifier (?) /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQTypeNameCtor(TestHost testHost) { await TestInMethodAsync( @@ -1421,8 +1351,7 @@ await TestInMethodAsync( Class("BufferedStream")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQEnum(TestHost testHost) { await TestAsync( @@ -1439,8 +1368,7 @@ void M() Enum("DriveType")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQDelegate(TestHost testHost) { await TestAsync( @@ -1456,8 +1384,7 @@ void M() Delegate("AssemblyLoadEventHandler")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQTypeNameMethodCall(TestHost testHost) { await TestInMethodAsync(@"global::System.String.Clone("");", @@ -1467,8 +1394,7 @@ public async Task NAQTypeNameMethodCall(TestHost testHost) Method("Clone")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQEventSubscription(TestHost testHost) { await TestInMethodAsync( @@ -1484,8 +1410,7 @@ await TestInMethodAsync( Class("AssemblyLoadEventArgs")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AnonymousDelegateParameterType(TestHost testHost) { await TestAsync( @@ -1506,8 +1431,7 @@ void M() Class("EventArgs")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQCtor(TestHost testHost) { await TestInMethodAsync( @@ -1521,8 +1445,7 @@ await TestInMethodAsync( Struct("DictionaryEntry")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQSameFileClass(TestHost testHost) { var code = @"class C { static void M() { global::C.M(); } }"; @@ -1535,8 +1458,7 @@ await TestAsync(code, Static("M")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task InteractiveNAQSameFileClass(TestHost testHost) { var code = @"class C { static void M() { global::Script.C.M(); } }"; @@ -1550,8 +1472,7 @@ await TestAsync(code, Static("M")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQSameFileClassWithNamespace(TestHost testHost) { await TestAsync( @@ -1577,8 +1498,7 @@ static void M() Static("M")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQSameFileClassWithNamespaceAndEscapedKeyword(TestHost testHost) { await TestAsync( @@ -1604,8 +1524,7 @@ static void M() Static("M")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQGlobalWarning(TestHost testHost) { await TestAsync( @@ -1631,8 +1550,7 @@ static void M() Static("M")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQUserDefinedNAQNamespace(TestHost testHost) { await TestAsync( @@ -1658,8 +1576,7 @@ static void M() Static("M")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQUserDefinedNAQNamespaceDoubleColon(TestHost testHost) { await TestAsync( @@ -1685,8 +1602,7 @@ static void M() Static("M")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQUserDefinedNamespace1(TestHost testHost) { await TestAsync( @@ -1715,8 +1631,7 @@ class D Namespace("B")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQUserDefinedNamespaceWithGlobal(TestHost testHost) { await TestAsync( @@ -1745,8 +1660,7 @@ class D Namespace("B")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQUserDefinedNAQForClass(TestHost testHost) { await TestAsync( @@ -1767,8 +1681,7 @@ void M() Class("BinaryReader")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NAQUserDefinedTypes(TestHost testHost) { await TestAsync( @@ -1856,8 +1769,7 @@ enum MyEnum Delegate("MyDelegate")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PreferPropertyOverNestedClass(TestHost testHost) { await TestAsync( @@ -1884,8 +1796,7 @@ void M() Field("B")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TypeNameInsideNestedClass(TestHost testHost) { await TestAsync( @@ -1914,8 +1825,7 @@ void M() Static("WriteLine")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StructEnumTypeNames(TestHost testHost) { await TestAsync( @@ -1943,8 +1853,7 @@ static void Main() Struct("Int32")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PreferFieldOverClassWithSameName(TestHost testHost) { await TestAsync( @@ -1960,8 +1869,7 @@ void M() Field("C")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeBinding(TestHost testHost) { await TestAsync( @@ -2008,8 +1916,7 @@ class ObsoleteAttribute : Attribute Class("Attribute")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ShouldNotClassifyNamespacesAsTypes(TestHost testHost) { await TestAsync( @@ -2025,8 +1932,7 @@ namespace Roslyn.Compilers.Internal Namespace("Internal")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NestedTypeCantHaveSameNameAsParentType(TestHost testHost) { await TestAsync( @@ -2047,8 +1953,7 @@ static void Main(Program p) Class("Program")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NestedTypeCantHaveSameNameAsParentTypeWithGlobalNamespaceAlias(TestHost testHost) { var code = @"class Program @@ -2066,8 +1971,7 @@ await TestAsync(code, Class("Program")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task InteractiveNestedTypeCantHaveSameNameAsParentTypeWithGlobalNamespaceAlias(TestHost testHost) { var code = @"class Program @@ -2086,8 +1990,7 @@ await TestAsync(code, Class("Program")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task EnumFieldWithSameNameShouldBePreferredToType(TestHost testHost) { await TestAsync( @@ -2491,8 +2394,7 @@ struct Type Struct("Type")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NameOf1(TestHost testHost) { await TestAsync( @@ -2508,8 +2410,7 @@ void goo() Keyword("nameof")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NameOf2(TestHost testHost) { await TestAsync( @@ -2526,8 +2427,7 @@ void goo() Class("C")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NameOfLocalMethod(TestHost testHost) { await TestAsync( @@ -2556,8 +2456,7 @@ void M(string s) Method("M")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task MethodCalledNameOfInScope(TestHost testHost) { await TestAsync( @@ -2612,8 +2511,7 @@ public async Task TestCreateWithBufferNotInWorkspace() await waiter.ExpeditedWaitAsync(); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task Tuples(TestHost testHost) { await TestAsync( @@ -2625,8 +2523,7 @@ await TestAsync( ParseOptions(TestOptions.Regular, Options.Script)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(261049, "https://devdiv.visualstudio.com/DevDiv/_workitems/edit/261049")] public async Task DevDiv261049RegressionTest(TestHost testHost) { @@ -2640,8 +2537,7 @@ await TestInMethodAsync( Keyword("var"), Local("a"), Local("a")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(633, "https://github.com/dotnet/roslyn/issues/633")] public async Task InXmlDocCref_WhenTypeOnlyIsSpecified_ItIsClassified(TestHost testHost) { @@ -2659,8 +2555,7 @@ public MyClass(int x) Class("MyClass")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(633, "https://github.com/dotnet/roslyn/issues/633")] public async Task InXmlDocCref_WhenConstructorOnlyIsSpecified_NothingIsClassified(TestHost testHost) { @@ -2677,8 +2572,7 @@ public MyClass(int x) Class("MyClass")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(633, "https://github.com/dotnet/roslyn/issues/633")] public async Task InXmlDocCref_WhenTypeAndConstructorSpecified_OnlyTypeIsClassified(TestHost testHost) { @@ -2697,8 +2591,7 @@ public MyClass(int x) Class("MyClass")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(13174, "https://github.com/dotnet/roslyn/issues/13174")] public async Task TestMemberBindingThatLooksGeneric(TestHost testHost) { @@ -2731,8 +2624,7 @@ static void Main(string[] args) Property("Length")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(23940, "https://github.com/dotnet/roslyn/issues/23940")] public async Task TestAliasQualifiedClass(TestHost testHost) { @@ -2763,8 +2655,7 @@ static void Main(string[] args) Class("List")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_InsideMethod(TestHost testHost) { // Asserts no Keyword("unmanaged") because it is an identifier. @@ -2776,8 +2667,7 @@ await TestInMethodAsync(@" Local("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_Keyword(TestHost testHost) { await TestAsync( @@ -2787,8 +2677,7 @@ await TestAsync( Keyword("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -2799,8 +2688,7 @@ class X where T : unmanaged { }", Interface("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -2815,8 +2703,7 @@ class X where T : unmanaged { }", Keyword("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_Keyword(TestHost testHost) { await TestAsync(@" @@ -2829,8 +2716,7 @@ void M() where T : unmanaged { } Keyword("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -2844,8 +2730,7 @@ void M() where T : unmanaged { } Interface("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -2863,8 +2748,7 @@ void M() where T : unmanaged { } Keyword("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_Keyword(TestHost testHost) { await TestAsync( @@ -2874,8 +2758,7 @@ await TestAsync( Keyword("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -2886,8 +2769,7 @@ interface unmanaged {} Interface("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -2902,8 +2784,7 @@ interface unmanaged {} Keyword("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex1(TestHost testHost) { await TestAsync( @@ -2985,8 +2866,7 @@ void Goo() Regex.Anchor("^")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex2(TestHost testHost) { await TestAsync( @@ -3068,8 +2948,7 @@ void Goo() Regex.Anchor("^")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex3(TestHost testHost) { await TestAsync( @@ -3151,8 +3030,7 @@ void Goo() Regex.Anchor("^")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex4(TestHost testHost) { await TestAsync( @@ -3176,8 +3054,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex4_utf8_1(TestHost testHost) { await TestAsync( @@ -3201,8 +3078,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex4_utf8_2(TestHost testHost) { await TestAsync( @@ -3226,8 +3102,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex5(TestHost testHost) { await TestAsync( @@ -3251,8 +3126,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex6(TestHost testHost) { await TestAsync( @@ -3277,8 +3151,7 @@ void Goo() Regex.Text(" # not end of line comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex7(TestHost testHost) { await TestAsync( @@ -3303,8 +3176,7 @@ void Goo() Regex.Comment("# is end of line comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex8(TestHost testHost) { await TestAsync( @@ -3329,8 +3201,7 @@ void Goo() Regex.Comment("# is end of line comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex9(TestHost testHost) { await TestAsync( @@ -3358,8 +3229,7 @@ void Goo() EnumMember("IgnorePatternWhitespace")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex10(TestHost testHost) { await TestAsync( @@ -3385,8 +3255,7 @@ void Goo() Regex.Text(" # is not end of line comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex10_utf8(TestHost testHost) { await TestAsync( @@ -3412,8 +3281,7 @@ void Goo() Regex.Text(" # is not end of line comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegex11(TestHost testHost) { await TestAsync( @@ -3440,8 +3308,7 @@ class Program Regex.Grouping(")")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexSingleLineRawStringLiteral(TestHost testHost) { await TestAsync( @@ -3465,8 +3332,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexSingleLineRawStringLiteral_utf8(TestHost testHost) { await TestAsync( @@ -3490,8 +3356,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexMultiLineRawStringLiteral(TestHost testHost) { await TestAsync( @@ -3517,8 +3382,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexMultiLineRawStringLiteral_utf8(TestHost testHost) { await TestAsync( @@ -3590,8 +3454,7 @@ class Program Regex.Anchor("$")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_Field(TestHost testHost) { await TestAsync( @@ -3617,8 +3480,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_Field2(TestHost testHost) { await TestAsync( @@ -3638,8 +3500,7 @@ class Program Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_Property(TestHost testHost) { await TestAsync( @@ -3665,8 +3526,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_Property2(TestHost testHost) { await TestAsync( @@ -3686,8 +3546,7 @@ class Program Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_Argument(TestHost testHost) { await TestAsync( @@ -3714,8 +3573,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_ParamsArgument(TestHost testHost) { await TestAsync( @@ -3774,8 +3632,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_ArrayArgument(TestHost testHost) { await TestAsync( @@ -3802,8 +3659,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_ImplicitArrayArgument(TestHost testHost) { await TestAsync( @@ -3830,8 +3686,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_CollectionArgument(TestHost testHost) { await TestAsync( @@ -3860,8 +3715,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_ImplicitCollectionArgument(TestHost testHost) { await TestAsync( @@ -3889,8 +3743,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_Argument_Options(TestHost testHost) { await TestAsync( @@ -3920,8 +3773,7 @@ void Goo() EnumMember("IgnorePatternWhitespace")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_Attribute(TestHost testHost) { await TestAsync( @@ -4015,8 +3867,7 @@ class Program Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_ParamsAttribute(TestHost testHost) { await TestAsync( @@ -4044,8 +3895,7 @@ class Program Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_ArrayAttribute(TestHost testHost) { await TestAsync( @@ -4073,8 +3923,7 @@ class Program Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRegexOnApiWithStringSyntaxAttribute_ImplicitArrayAttribute(TestHost testHost) { await TestAsync( @@ -4102,8 +3951,7 @@ class Program Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestIncompleteRegexLeadingToStringInsideSkippedTokensInsideADirective(TestHost testHost) { await TestAsync( @@ -4174,8 +4022,7 @@ void Goo() Regex.Comment("(?#comment)")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestJson1(TestHost testHost) { await TestAsync( @@ -4217,8 +4064,7 @@ void Goo() Json.Comment("// comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestJson_RawString(TestHost testHost) { await TestAsync( @@ -4243,8 +4089,7 @@ void Goo() Json.Array("]")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestMultiLineJson1(TestHost testHost) { await TestAsync( @@ -4299,8 +4144,7 @@ void Goo() Json.Comment("// comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestJson_NoComment_NotLikelyJson(TestHost testHost) { var input = @" @@ -4316,8 +4160,7 @@ await TestAsync(input, Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestJson_NoComment_LikelyJson(TestHost testHost) { var input = @" @@ -4344,8 +4187,7 @@ await TestAsync(input, Json.Array("]")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestJsonOnApiWithStringSyntaxAttribute_Field(TestHost testHost) { await TestAsync( @@ -4372,8 +4214,7 @@ void Goo() Json.Array("]")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestJsonOnApiWithStringSyntaxAttribute_Property(TestHost testHost) { await TestAsync( @@ -4400,8 +4241,7 @@ void Goo() Json.Array("]")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestJsonOnApiWithStringSyntaxAttribute_Argument(TestHost testHost) { await TestAsync( @@ -4430,8 +4270,7 @@ void Goo() Json.Array("]")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_Keyword(TestHost testHost) { await TestAsync(@" @@ -4447,8 +4286,7 @@ void M() where T : unmanaged { } Keyword("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -4465,8 +4303,7 @@ void M() where T : unmanaged { } Interface("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -4487,8 +4324,7 @@ void M() where T : unmanaged { } Keyword("unmanaged")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape1(TestHost testHost) { await TestInMethodAsync(@"var goo = ""goo\r\nbar"";", @@ -4498,8 +4334,7 @@ public async Task TestStringEscape1(TestHost testHost) Escape(@"\n")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape1_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = ""goo\r\nbar""u8;", @@ -4509,8 +4344,7 @@ public async Task TestStringEscape1_utf8(TestHost testHost) Escape(@"\n")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape2(TestHost testHost) { await TestInMethodAsync(@"var goo = @""goo\r\nbar"";", @@ -4518,8 +4352,7 @@ public async Task TestStringEscape2(TestHost testHost) Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape2_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = @""goo\r\nbar""u8;", @@ -4527,8 +4360,7 @@ public async Task TestStringEscape2_utf8(TestHost testHost) Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape3(TestHost testHost) { await TestInMethodAsync(@"var goo = $""goo{{1}}bar"";", @@ -4538,8 +4370,7 @@ public async Task TestStringEscape3(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape3_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $""goo{{1}}bar""u8;", @@ -4549,8 +4380,7 @@ public async Task TestStringEscape3_utf8(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape4(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""goo{{1}}bar"";", @@ -4560,8 +4390,7 @@ public async Task TestStringEscape4(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape4_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""goo{{1}}bar""u8;", @@ -4571,8 +4400,7 @@ public async Task TestStringEscape4_utf8(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape5(TestHost testHost) { await TestInMethodAsync(@"var goo = $""goo\r{{1}}\nbar"";", @@ -4584,8 +4412,7 @@ public async Task TestStringEscape5(TestHost testHost) Escape(@"\n")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape5_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $""goo\r{{1}}\nbar""u8;", @@ -4597,8 +4424,7 @@ public async Task TestStringEscape5_utf8(TestHost testHost) Escape(@"\n")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape6(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""goo\r{{1}}\nbar"";", @@ -4608,8 +4434,7 @@ public async Task TestStringEscape6(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape6_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""goo\r{{1}}\nbar""u8;", @@ -4619,8 +4444,7 @@ public async Task TestStringEscape6_utf8(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape7(TestHost testHost) { await TestInMethodAsync(@"var goo = $""goo\r{1}\nbar"";", @@ -4630,8 +4454,7 @@ public async Task TestStringEscape7(TestHost testHost) Escape(@"\n")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape7_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $""goo\r{1}\nbar""u8;", @@ -4641,8 +4464,7 @@ public async Task TestStringEscape7_utf8(TestHost testHost) Escape(@"\n")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape8(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""{{goo{1}bar}}"";", @@ -4652,8 +4474,7 @@ public async Task TestStringEscape8(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape8_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""{{goo{1}bar}}""u8;", @@ -4663,8 +4484,7 @@ public async Task TestStringEscape8_utf8(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape9(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""{{{12:X}}}"";", @@ -4674,8 +4494,7 @@ public async Task TestStringEscape9(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape9_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""{{{12:X}}}""u8;", @@ -4685,8 +4504,7 @@ public async Task TestStringEscape9_utf8(TestHost testHost) Escape(@"}}")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral1(TestHost testHost) { await TestInMethodAsync(@"var goo = """"""goo\r\nbar"""""";", @@ -4694,8 +4512,7 @@ public async Task TestNotStringEscapeInRawLiteral1(TestHost testHost) Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral1_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = """"""goo\r\nbar""""""u8;", @@ -4703,8 +4520,7 @@ public async Task TestNotStringEscapeInRawLiteral1_utf8(TestHost testHost) Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral2(TestHost testHost) { await TestInMethodAsync(@"var goo = """""" @@ -4714,8 +4530,7 @@ await TestInMethodAsync(@"var goo = """""" Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral2_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = """""" @@ -4725,8 +4540,7 @@ await TestInMethodAsync(@"var goo = """""" Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral3(TestHost testHost) { await TestInMethodAsync(@"var goo = $"""""" @@ -4736,8 +4550,7 @@ await TestInMethodAsync(@"var goo = $"""""" Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral3_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $"""""" @@ -4747,8 +4560,7 @@ await TestInMethodAsync(@"var goo = $"""""" Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral4(TestHost testHost) { await TestInMethodAsync(@"var goo = """"""\"""""";", @@ -4756,8 +4568,7 @@ public async Task TestNotStringEscapeInRawLiteral4(TestHost testHost) Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral4_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = """"""\""""""u8;", @@ -4765,8 +4576,7 @@ public async Task TestNotStringEscapeInRawLiteral4_utf8(TestHost testHost) Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral5(TestHost testHost) { await TestInMethodAsync(@"var goo = """""" @@ -4776,8 +4586,7 @@ await TestInMethodAsync(@"var goo = """""" Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral5_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = """""" @@ -4787,8 +4596,7 @@ await TestInMethodAsync(@"var goo = """""" Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral6(TestHost testHost) { await TestInMethodAsync(@"var goo = $"""""" @@ -4798,8 +4606,7 @@ await TestInMethodAsync(@"var goo = $"""""" Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotStringEscapeInRawLiteral6_utf8(TestHost testHost) { await TestInMethodAsync(@"var goo = $"""""" @@ -4998,8 +4805,7 @@ class True Class("True")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestCatchDeclarationVariable(TestHost testHost) { await TestInMethodAsync(@" @@ -5014,8 +4820,7 @@ await TestInMethodAsync(@" Local("ex")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_InsideMethod(TestHost testHost) { // Asserts no Keyword("notnull") because it is an identifier. @@ -5027,8 +4832,7 @@ await TestInMethodAsync(@" Local("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_Keyword(TestHost testHost) { await TestAsync( @@ -5038,8 +4842,7 @@ await TestAsync( Keyword("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -5050,8 +4853,7 @@ class X where T : notnull { }", Interface("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -5066,8 +4868,7 @@ class X where T : notnull { }", Keyword("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_Keyword(TestHost testHost) { await TestAsync(@" @@ -5080,8 +4881,7 @@ void M() where T : notnull { } Keyword("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -5095,8 +4895,7 @@ void M() where T : notnull { } Interface("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -5114,8 +4913,7 @@ void M() where T : notnull { } Keyword("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_Keyword(TestHost testHost) { await TestAsync( @@ -5125,8 +4923,7 @@ await TestAsync( Keyword("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -5137,8 +4934,7 @@ interface notnull {} Interface("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -5153,8 +4949,7 @@ interface notnull {} Keyword("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_Keyword(TestHost testHost) { await TestAsync(@" @@ -5170,8 +4965,7 @@ void M() where T : notnull { } Keyword("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -5188,8 +4982,7 @@ void M() where T : notnull { } Interface("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -5210,8 +5003,7 @@ void M() where T : notnull { } Keyword("notnull")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NonDiscardVariableDeclaration(TestHost testHost) { await TestAsync(@" @@ -5228,8 +5020,7 @@ void N() Static("Parse")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NonDiscardVariableDeclarationMultipleDeclarators(TestHost testHost) { await TestAsync(@" @@ -5243,8 +5034,7 @@ void N() }", testHost); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardAssignment(TestHost testHost) { await TestAsync(@" @@ -5261,8 +5051,7 @@ void N() Static("Parse")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInOutDeclaration(TestHost testHost) { await TestAsync(@" @@ -5280,8 +5069,7 @@ void N() Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInOutAssignment(TestHost testHost) { await TestAsync(@" @@ -5298,8 +5086,7 @@ void N() Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInDeconstructionAssignment(TestHost testHost) { await TestAsync(@" @@ -5314,8 +5101,7 @@ void N() Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInDeconstructionDeclaration(TestHost testHost) { await TestAsync(@" @@ -5330,8 +5116,7 @@ void N() Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInPatternMatch(TestHost testHost) { await TestAsync(@" @@ -5347,8 +5132,7 @@ bool N(object x) Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInSwitch(TestHost testHost) { await TestAsync(@" @@ -5370,8 +5154,7 @@ bool N(object x) Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInSwitchPatternMatch(TestHost testHost) { await TestAsync(@" @@ -5390,8 +5173,7 @@ bool N(object x) Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UnusedUnderscoreParameterInLambda(TestHost testHost) { await TestAsync(@" @@ -5407,8 +5189,7 @@ void N() Delegate("Func")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UsedUnderscoreParameterInLambda(TestHost testHost) { await TestAsync(@" @@ -5425,8 +5206,7 @@ void N() Parameter("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardsInLambda(TestHost testHost) { await TestAsync(@" @@ -5444,8 +5224,7 @@ void N() Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardsInLambdaWithInferredType(TestHost testHost) { await TestAsync(@" @@ -5463,8 +5242,7 @@ void N() Keyword("_")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NativeInteger(TestHost testHost) { await TestInMethodAsync( @@ -5473,8 +5251,7 @@ await TestInMethodAsync( Classifications(Keyword("nint"), Keyword("nuint"))); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NotNativeInteger(TestHost testHost) { await TestInMethodAsync( @@ -5485,8 +5262,7 @@ await TestInMethodAsync( Classifications(Class("nint"))); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NotNativeUnsignedInteger(TestHost testHost) { await TestInMethodAsync( @@ -5497,8 +5273,7 @@ await TestInMethodAsync( Classifications(Class("nuint"))); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StaticBoldingMethodName(TestHost testHost) { await TestAsync( @@ -5516,8 +5291,7 @@ public static void Method() Static("Method")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StaticBoldingMethodNameNestedInNameof(TestHost testHost) { await TestAsync( @@ -5535,8 +5309,7 @@ public static void Method() Method("Method")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BoldingMethodNameStaticAndNot(TestHost testHost) { await TestAsync( @@ -5563,8 +5336,7 @@ public void Test() { Method("Method")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(46985, "https://github.com/dotnet/roslyn/issues/46985")] public async Task BasicRecordClassification(TestHost testHost) { @@ -5579,8 +5351,7 @@ await TestAsync( RecordClass("R")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(46985, "https://github.com/dotnet/roslyn/issues/46985")] public async Task ParameterizedRecordClassification(TestHost testHost) { @@ -5595,8 +5366,7 @@ class C RecordClass("R")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BasicRecordClassClassification(TestHost testHost) { await TestAsync( @@ -5610,8 +5380,7 @@ await TestAsync( RecordClass("R")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BasicRecordStructClassification(TestHost testHost) { await TestAsync( @@ -5623,8 +5392,7 @@ await TestAsync( RecordStruct("R")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BasicFileScopedNamespaceClassification(TestHost testHost) { await TestAsync( @@ -5635,8 +5403,7 @@ class C { }", Namespace("NS")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NullCheckedParameterClassification(TestHost testHost) { await TestAsync( @@ -5648,8 +5415,7 @@ void M(string s!!) { } testHost); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(57184, "https://github.com/dotnet/roslyn/issues/57184")] public async Task MethodGroupClassifications(TestHost testHost) { @@ -5675,8 +5441,7 @@ int m(Delegate d) { }", /// /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LocalFunctionUse(TestHost testHost) { await TestAsync( diff --git a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs index af44fd194e762..6885a75d88286 100644 --- a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs +++ b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs @@ -26,8 +26,7 @@ protected override async Task> GetClassificationS return await GetSyntacticClassificationsAsync(document, span); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAtTypeMemberLevel(TestHost testHost) { await TestAsync( @@ -43,8 +42,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNamespace(TestHost testHost) { await TestAsync( @@ -58,8 +56,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestFileScopedNamespace(TestHost testHost) { await TestAsync( @@ -71,8 +68,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsLocalVariableType(TestHost testHost) { await TestInMethodAsync("var goo = 42", @@ -83,8 +79,7 @@ await TestInMethodAsync("var goo = 42", Number("42")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarOptimisticallyColored(TestHost testHost) { await TestInMethodAsync("var", @@ -92,8 +87,7 @@ await TestInMethodAsync("var", Keyword("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarNotColoredInClass(TestHost testHost) { await TestInClassAsync("var", @@ -101,8 +95,7 @@ await TestInClassAsync("var", Identifier("var")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarInsideLocalAndExpressions(TestHost testHost) { await TestInMethodAsync( @@ -120,8 +113,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsMethodParameter(TestHost testHost) { await TestAsync( @@ -146,8 +138,7 @@ void M(var v) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task YieldYield(TestHost testHost) { await TestAsync( @@ -196,8 +187,7 @@ IEnumerable M() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task YieldReturn(TestHost testHost) { await TestInMethodAsync("yield return 42", @@ -207,8 +197,7 @@ public async Task YieldReturn(TestHost testHost) Number("42")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task YieldFixed(TestHost testHost) { await TestInMethodAsync( @@ -239,8 +228,7 @@ await TestInMethodAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PartialClass(TestHost testHost) { await TestAsync("public partial class Goo", @@ -251,8 +239,7 @@ await TestAsync("public partial class Goo", Class("Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PartialMethod(TestHost testHost) { await TestInClassAsync( @@ -273,8 +260,7 @@ await TestInClassAsync( /// /// Partial is only valid in a type declaration /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(536313, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/536313")] public async Task PartialAsLocalVariableType(TestHost testHost) { @@ -288,8 +274,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PartialClassStructInterface(TestHost testHost) { await TestAsync( @@ -327,8 +312,7 @@ partial interface T3 /// /// Check for items only valid within a method declaration /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ContextualKeywordsOnlyValidInMethods(TestHost testHost) { foreach (var kw in s_contextualKeywordsOnlyValidInMethods) @@ -340,8 +324,7 @@ await TestInNamespaceAsync(kw + " goo", } } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiterals1(TestHost testHost) { await TestInMethodAsync(@"@""goo""", @@ -349,8 +332,7 @@ await TestInMethodAsync(@"@""goo""", Verbatim(@"@""goo""")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiteralsUtf8_01(TestHost testHost) { await TestInMethodAsync(@"@""goo""u8", @@ -359,8 +341,7 @@ await TestInMethodAsync(@"@""goo""u8", Keyword("u8")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiteralsUtf8_02(TestHost testHost) { await TestInMethodAsync(@"@""goo""U8", @@ -372,8 +353,7 @@ await TestInMethodAsync(@"@""goo""U8", /// /// Should show up as soon as we get the @\" typed out /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiterals2(TestHost testHost) { await TestAsync(@"@""", @@ -384,8 +364,7 @@ await TestAsync(@"@""", /// /// Parser does not currently support strings of this type /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiterals3(TestHost testHost) { await TestAsync(@"goo @""", @@ -397,8 +376,7 @@ await TestAsync(@"goo @""", /// /// Uncompleted ones should span new lines /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiterals4(TestHost testHost) { var code = @" @@ -413,8 +391,7 @@ await TestAsync(code, ")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiterals5(TestHost testHost) { var code = @" @@ -432,8 +409,7 @@ await TestInMethodAsync(code, Local("stuff")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiteralsUtf8_03(TestHost testHost) { var code = @" @@ -452,8 +428,7 @@ await TestInMethodAsync(code, Local("stuff")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiteralsUtf8_04(TestHost testHost) { var code = @" @@ -492,8 +467,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiteralsUtf8_05(bool script, TestHost testHost) { var code = @"string s = @""""""/*""u8;"; @@ -513,8 +487,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VerbatimStringLiteralsUtf8_06(bool script, TestHost testHost) { var code = @"string s = @""""""/*""u8;"; @@ -534,8 +507,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StringLiteral1(TestHost testHost) { await TestAsync(@"""goo""", @@ -543,8 +515,7 @@ await TestAsync(@"""goo""", String(@"""goo""")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StringLiteralUtf8_01(TestHost testHost) { await TestAsync(@"""goo""u8", @@ -553,8 +524,7 @@ await TestAsync(@"""goo""u8", Keyword("u8")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StringLiteralUtf8_02(TestHost testHost) { await TestAsync(@"""goo""U8", @@ -563,8 +533,7 @@ await TestAsync(@"""goo""U8", Keyword("U8")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StringLiteral2(TestHost testHost) { await TestAsync(@"""""", @@ -572,8 +541,7 @@ await TestAsync(@"""""", String(@"""""")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StringLiteralUtf8_03(TestHost testHost) { await TestAsync(@"""""u8", @@ -582,8 +550,7 @@ await TestAsync(@"""""u8", Keyword("u8")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StringLiteralUtf8_04(TestHost testHost) { await TestAsync(@"""""U8", @@ -592,8 +559,7 @@ await TestAsync(@"""""U8", Keyword("U8")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CharacterLiteral1(TestHost testHost) { var code = @"'f'"; @@ -602,8 +568,7 @@ await TestInMethodAsync(code, String("'f'")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqFrom1(TestHost testHost) { var code = @"from it in goo"; @@ -615,8 +580,7 @@ await TestInExpressionAsync(code, Identifier("goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqFrom2(TestHost testHost) { var code = @"from it in goo.Bar()"; @@ -632,8 +596,7 @@ await TestInExpressionAsync(code, Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqFrom3(TestHost testHost) { // query expression are not statement expressions, but the parser parses them anyways to give better errors @@ -645,8 +608,7 @@ await TestInMethodAsync(code, Keyword("in")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqFrom4(TestHost testHost) { var code = @"from it in "; @@ -657,8 +619,7 @@ await TestInExpressionAsync(code, Keyword("in")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqWhere1(TestHost testHost) { var code = "from it in goo where it > 42"; @@ -674,8 +635,7 @@ await TestInExpressionAsync(code, Number("42")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqWhere2(TestHost testHost) { var code = @"from it in goo where it > ""bar"""; @@ -768,8 +728,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ContextualKeywordsAsFieldName(TestHost testHost) { await TestAsync( @@ -805,8 +764,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqKeywordsInFieldInitializer(TestHost testHost) { await TestAsync( @@ -863,8 +821,7 @@ where a Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqKeywordsAsTypeName(TestHost testHost) { await TestAsync( @@ -979,8 +936,7 @@ class select Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqKeywordsAsMethodParameters(TestHost testHost) { await TestAsync( @@ -1044,8 +1000,7 @@ orderby M(var goo, from goo, join goo, on goo, equals goo, group goo, by goo, in Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqKeywordsInLocalVariableDeclarations(TestHost testHost) { await TestAsync( @@ -1200,8 +1155,7 @@ void M() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqKeywordsAsFieldNames(TestHost testHost) { await TestAsync( @@ -1245,8 +1199,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LinqKeywordsAtFieldLevelInvalid(TestHost testHost) { await TestAsync( @@ -1299,8 +1252,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CommentSingle(TestHost testHost) { var code = "// goo"; @@ -1310,8 +1262,7 @@ await TestAsync(code, Comment("// goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CommentAsTrailingTrivia1(TestHost testHost) { var code = "class Bar { // goo"; @@ -1323,8 +1274,7 @@ await TestAsync(code, Comment("// goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CommentAsLeadingTrivia1(TestHost testHost) { var code = @" @@ -1347,8 +1297,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ShebangAsFirstCommentInScript(TestHost testHost) { var code = @"#!/usr/bin/env scriptcs @@ -1370,8 +1319,7 @@ public async Task ShebangAsFirstCommentInScript(TestHost testHost) await TestAsync(code, code, testHost, Options.Script, expected); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ShebangAsFirstCommentInNonScript(TestHost testHost) { var code = @"#!/usr/bin/env scriptcs @@ -1394,8 +1342,7 @@ public async Task ShebangAsFirstCommentInNonScript(TestHost testHost) await TestAsync(code, code, testHost, Options.Regular, expected); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ShebangNotAsFirstCommentInScript(TestHost testHost) { var code = @" #!/usr/bin/env scriptcs @@ -1418,8 +1365,7 @@ public async Task ShebangNotAsFirstCommentInScript(TestHost testHost) await TestAsync(code, code, testHost, Options.Script, expected); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CommentAsMethodBodyContent(TestHost testHost) { var code = @" @@ -1443,8 +1389,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CommentMix1(TestHost testHost) { await TestAsync( @@ -1462,8 +1407,7 @@ class cl Comment("//comment2 */")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CommentMix2(TestHost testHost) { await TestInMethodAsync( @@ -1478,8 +1422,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocCommentOnClass(TestHost testHost) { var code = @" @@ -1502,8 +1445,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocCommentOnClassWithIndent(TestHost testHost) { var code = @" @@ -1531,8 +1473,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_EntityReference(TestHost testHost) { var code = @" @@ -1555,8 +1496,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_ExteriorTriviaInsideCloseTag(TestHost testHost) { var code = @" @@ -1612,8 +1552,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocCommentOnClassWithExteriorTrivia(TestHost testHost) { var code = @" @@ -1641,8 +1580,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_ExteriorTriviaNoText(TestHost testHost) { var code = @@ -1668,8 +1606,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_EmptyElement(TestHost testHost) { var code = @" @@ -1688,8 +1625,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_Attribute(TestHost testHost) { var code = @" @@ -1718,8 +1654,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_AttributeInEmptyElement(TestHost testHost) { var code = @" @@ -1743,8 +1678,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_ExtraSpaces(TestHost testHost) { var code = @" @@ -1768,8 +1702,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_XmlComment(TestHost testHost) { var code = @" @@ -1787,8 +1720,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_XmlCommentWithExteriorTrivia(TestHost testHost) { var code = @" @@ -1809,8 +1741,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_XmlCommentInElement(TestHost testHost) { var code = @" @@ -1834,8 +1765,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(31410, "https://github.com/dotnet/roslyn/pull/31410")] public async Task XmlDocComment_MalformedXmlDocComment(TestHost testHost) { @@ -1869,8 +1799,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task MultilineXmlDocComment_ExteriorTrivia(TestHost testHost) { var code = @@ -1897,8 +1826,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_CDataWithExteriorTrivia(TestHost testHost) { var code = @" @@ -1919,8 +1847,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task XmlDocComment_ProcessingDirective(TestHost testHost) { await TestAsync( @@ -1961,8 +1888,7 @@ static void Main() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(536321, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/536321")] public async Task KeywordTypeParameters(TestHost testHost) { @@ -1978,8 +1904,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(536853, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/536853")] public async Task TypeParametersWithAttribute(TestHost testHost) { @@ -1998,8 +1923,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ClassTypeDeclaration1(TestHost testHost) { var code = "class C1 { } "; @@ -2011,8 +1935,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ClassTypeDeclaration2(TestHost testHost) { var code = "class ClassName1 { } "; @@ -2024,8 +1947,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task StructTypeDeclaration1(TestHost testHost) { var code = "struct Struct1 { }"; @@ -2037,8 +1959,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task InterfaceDeclaration1(TestHost testHost) { var code = "interface I1 { }"; @@ -2050,8 +1971,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task EnumDeclaration1(TestHost testHost) { var code = "enum Weekday { }"; @@ -2083,8 +2003,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DelegateDeclaration1(TestHost testHost) { var code = "delegate void Action();"; @@ -2098,8 +2017,7 @@ await TestAsync(code, Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericTypeArgument(TestHost testHost) { await TestInMethodAsync( @@ -2113,8 +2031,7 @@ await TestInMethodAsync( Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericParameter(TestHost testHost) { var code = "class C1 {}"; @@ -2129,8 +2046,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericParameters(TestHost testHost) { var code = "class C1 {}"; @@ -2147,8 +2063,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericParameter_Interface(TestHost testHost) { var code = "interface I1 {}"; @@ -2163,8 +2078,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericParameter_Struct(TestHost testHost) { var code = "struct S1 {}"; @@ -2179,8 +2093,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericParameter_Delegate(TestHost testHost) { var code = "delegate void D1 {}"; @@ -2196,8 +2109,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task GenericParameter_Method(TestHost testHost) { await TestInClassAsync( @@ -2225,8 +2137,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TernaryExpression(TestHost testHost) { await TestInExpressionAsync("true ? 1 : 0", @@ -2238,8 +2149,7 @@ await TestInExpressionAsync("true ? 1 : 0", Number("0")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BaseClass(TestHost testHost) { await TestAsync( @@ -2255,8 +2165,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestLabel(TestHost testHost) { await TestInMethodAsync("goo:", @@ -2265,8 +2174,7 @@ await TestInMethodAsync("goo:", Punctuation.Colon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task Attribute(TestHost testHost) { await TestAsync( @@ -2279,8 +2187,7 @@ await TestAsync( Punctuation.CloseBracket); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestAngleBracketsOnGenericConstraints_Bug932262(TestHost testHost) { await TestAsync( @@ -2304,8 +2211,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestYieldPositive(TestHost testHost) { await TestInMethodAsync( @@ -2317,8 +2223,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestYieldNegative(TestHost testHost) { await TestInMethodAsync( @@ -2329,8 +2234,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestFromPositive(TestHost testHost) { await TestInExpressionAsync( @@ -2342,8 +2246,7 @@ await TestInExpressionAsync( Identifier("y")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestFromNegative(TestHost testHost) { await TestInMethodAsync( @@ -2354,8 +2257,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersModule(TestHost testHost) { await TestAsync( @@ -2368,8 +2270,7 @@ await TestAsync( Punctuation.CloseBracket); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersAssembly(TestHost testHost) { await TestAsync( @@ -2382,8 +2283,7 @@ await TestAsync( Punctuation.CloseBracket); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnDelegate(TestHost testHost) { await TestInClassAsync( @@ -2409,8 +2309,7 @@ await TestInClassAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnMethod(TestHost testHost) { await TestInClassAsync( @@ -2438,8 +2337,7 @@ void M() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnCtor(TestHost testHost) { await TestAsync( @@ -2467,8 +2365,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnDtor(TestHost testHost) { await TestAsync( @@ -2497,8 +2394,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnOperator(TestHost testHost) { await TestInClassAsync( @@ -2533,8 +2429,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnEventDeclaration(TestHost testHost) { await TestInClassAsync( @@ -2592,8 +2487,7 @@ event A E Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnPropertyAccessors(TestHost testHost) { await TestInClassAsync( @@ -2644,8 +2538,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnIndexers(TestHost testHost) { await TestInClassAsync( @@ -2671,8 +2564,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnIndexerAccessors(TestHost testHost) { await TestInClassAsync( @@ -2727,8 +2619,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task AttributeTargetSpecifiersOnField(TestHost testHost) { await TestInClassAsync( @@ -2749,8 +2640,7 @@ await TestInClassAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestAllKeywords(TestHost testHost) { await TestAsync( @@ -3464,8 +3354,7 @@ interface Bar PPText("TaoRegion")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestAllOperators(TestHost testHost) { await TestAsync( @@ -3797,8 +3686,7 @@ public void method() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestPartialMethodWithNamePartial(TestHost testHost) { await TestAsync( @@ -3861,8 +3749,7 @@ public partial void partial void Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ValueInSetterAndAnonymousTypePropertyName(TestHost testHost) { await TestAsync( @@ -4190,8 +4077,7 @@ void Main(string[] args) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task InterpolatedStrings1(TestHost testHost) { var code = @" @@ -4217,8 +4103,7 @@ await TestInMethodAsync(code, Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task InterpolatedStrings2(TestHost testHost) { var code = @" @@ -4253,8 +4138,7 @@ await TestInMethodAsync(code, Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task InterpolatedStrings3(TestHost testHost) { var code = @" @@ -4289,8 +4173,7 @@ await TestInMethodAsync(code, Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ExceptionFilter1(TestHost testHost) { var code = @" @@ -4315,8 +4198,7 @@ await TestInMethodAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ExceptionFilter2(TestHost testHost) { var code = @" @@ -4346,8 +4228,7 @@ await TestInMethodAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task OutVar(TestHost testHost) { var code = @" @@ -4362,8 +4243,7 @@ await TestInMethodAsync(code, Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ReferenceDirective(TestHost testHost) { var code = @" @@ -4375,8 +4255,7 @@ await TestAsync(code, String("\"file.dll\"")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LoadDirective(TestHost testHost) { var code = @" @@ -4388,8 +4267,7 @@ await TestAsync(code, String("\"file.csx\"")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task IncompleteAwaitInNonAsyncContext(TestHost testHost) { var code = @" @@ -4411,8 +4289,7 @@ await TestInClassAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CompleteAwaitInNonAsyncContext(TestHost testHost) { var code = @" @@ -4435,8 +4312,7 @@ await TestInClassAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TupleDeclaration(TestHost testHost) { await TestInMethodAsync("(int, string) x", @@ -4450,8 +4326,7 @@ await TestInMethodAsync("(int, string) x", Local("x")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TupleDeclarationWithNames(TestHost testHost) { await TestInMethodAsync("(int a, string b) x", @@ -4467,8 +4342,7 @@ await TestInMethodAsync("(int a, string b) x", Local("x")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TupleLiteral(TestHost testHost) { await TestInMethodAsync("var values = (1, 2)", @@ -4484,8 +4358,7 @@ await TestInMethodAsync("var values = (1, 2)", Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TupleLiteralWithNames(TestHost testHost) { await TestInMethodAsync("var values = (a: 1, b: 2)", @@ -4505,8 +4378,7 @@ await TestInMethodAsync("var values = (a: 1, b: 2)", Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestConflictMarkers1(TestHost testHost) { await TestAsync( @@ -4540,8 +4412,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestConflictMarkers2(TestHost testHost) { await TestAsync( @@ -4581,8 +4452,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_InsideMethod(TestHost testHost) { await TestInMethodAsync(@" @@ -4599,8 +4469,7 @@ await TestInMethodAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_Keyword(TestHost testHost) { await TestAsync( @@ -4619,8 +4488,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -4644,8 +4512,7 @@ class X where T : unmanaged { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -4676,8 +4543,7 @@ class X where T : unmanaged { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_Keyword(TestHost testHost) { await TestAsync(@" @@ -4705,8 +4571,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -4739,8 +4604,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -4780,8 +4644,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_Keyword(TestHost testHost) { await TestAsync( @@ -4802,8 +4665,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -4829,8 +4691,7 @@ interface unmanaged {} Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -4863,8 +4724,7 @@ interface unmanaged {} Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_Keyword(TestHost testHost) { await TestAsync(@" @@ -4901,8 +4761,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -4944,8 +4803,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -4994,8 +4852,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestDeclarationIsPattern(TestHost testHost) { await TestInMethodAsync(@" @@ -5019,8 +4876,7 @@ await TestInMethodAsync(@" Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestDeclarationSwitchPattern(TestHost testHost) { await TestInMethodAsync(@" @@ -5049,8 +4905,7 @@ await TestInMethodAsync(@" Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestDeclarationExpression(TestHost testHost) { await TestInMethodAsync(@" @@ -5071,8 +4926,7 @@ await TestInMethodAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(18956, "https://github.com/dotnet/roslyn/issues/18956")] public async Task TestListPattern(TestHost testHost) { @@ -5117,8 +4971,7 @@ await TestInMethodAsync(@" Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(18956, "https://github.com/dotnet/roslyn/issues/18956")] public async Task TestListPattern2(TestHost testHost) { @@ -5146,8 +4999,7 @@ await TestInMethodAsync(@" Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(18956, "https://github.com/dotnet/roslyn/issues/18956")] public async Task TestVarPattern(TestHost testHost) { @@ -5164,8 +5016,7 @@ await TestInMethodAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestTupleTypeSyntax(TestHost testHost) { await TestInClassAsync(@" @@ -5187,8 +5038,7 @@ await TestInClassAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestOutParameter(TestHost testHost) { await TestInMethodAsync(@" @@ -5213,8 +5063,7 @@ await TestInMethodAsync(@" Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestOutParameter2(TestHost testHost) { await TestInClassAsync(@" @@ -5242,8 +5091,7 @@ await TestInClassAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUsingDirective(TestHost testHost) { var code = @"using System.Collections.Generic;"; @@ -5259,8 +5107,7 @@ await TestAsync(code, Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUsingAliasDirectiveForIdentifier(TestHost testHost) { var code = @"using Col = System.Collections;"; @@ -5276,8 +5123,7 @@ await TestAsync(code, Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUsingAliasDirectiveForClass(TestHost testHost) { var code = @"using Con = System.Console;"; @@ -5293,8 +5139,7 @@ await TestAsync(code, Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUsingStaticDirective(TestHost testHost) { var code = @"using static System.Console;"; @@ -5340,8 +5185,7 @@ await TestInMethodAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CatchDeclarationStatement(TestHost testHost) { await TestInMethodAsync(@" @@ -5360,8 +5204,7 @@ await TestInMethodAsync(@" Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_InsideMethod(TestHost testHost) { await TestInMethodAsync(@" @@ -5378,8 +5221,7 @@ await TestInMethodAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_Keyword(TestHost testHost) { await TestAsync( @@ -5398,8 +5240,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -5423,8 +5264,7 @@ class X where T : notnull { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -5455,8 +5295,7 @@ class X where T : notnull { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_Keyword(TestHost testHost) { await TestAsync(@" @@ -5484,8 +5323,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -5518,8 +5356,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -5559,8 +5396,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_Keyword(TestHost testHost) { await TestAsync( @@ -5581,8 +5417,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -5608,8 +5443,7 @@ interface notnull {} Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -5642,8 +5476,7 @@ interface notnull {} Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_Keyword(TestHost testHost) { await TestAsync(@" @@ -5680,8 +5513,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -5723,8 +5555,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -5773,8 +5604,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(45807, "https://github.com/dotnet/roslyn/issues/45807")] public async Task FunctionPointer(TestHost testHost) { @@ -5937,8 +5767,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteral(TestHost testHost) { var code = @" @@ -5974,8 +5803,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteralUtf8_01(TestHost testHost) { var code = @" @@ -6012,8 +5840,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteralUtf8_02(TestHost testHost) { var code = @" @@ -6050,8 +5877,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteralMultiline(TestHost testHost) { var code = @" @@ -6091,8 +5917,7 @@ Hello world Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteralMultilineUtf8_01(TestHost testHost) { var code = @" @@ -6133,8 +5958,7 @@ Hello world Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteralMultilineUtf8_02(TestHost testHost) { var code = @" @@ -6175,8 +5999,7 @@ Hello world Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteralInterpolation1(TestHost testHost) { var code = @" @@ -6216,8 +6039,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteralInterpolation2(TestHost testHost) { var code = @" @@ -6257,8 +6079,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRawStringLiteralInterpolation3(TestHost testHost) { var code = @" @@ -6300,8 +6121,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CheckedUserDefinedOperators_01(TestHost testHost) { await TestInClassAsync( @@ -6323,8 +6143,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CheckedUserDefinedOperators_02(TestHost testHost) { await TestInClassAsync( @@ -6349,8 +6168,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CheckedUserDefinedOperators_03(TestHost testHost) { await TestInClassAsync( @@ -6372,8 +6190,7 @@ static explicit operator checked T(T a) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CheckedUserDefinedOperators_04(TestHost testHost) { await TestInClassAsync( @@ -6397,8 +6214,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CheckedUserDefinedOperators_05(TestHost testHost) { await TestInClassAsync( @@ -6425,8 +6241,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CheckedUserDefinedOperators_06(TestHost testHost) { await TestInClassAsync( @@ -6450,8 +6265,7 @@ static explicit I1.operator checked T(T a) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UnsignedRightShift_01(TestHost testHost) { await TestInClassAsync( @@ -6475,8 +6289,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UnsignedRightShift_02(TestHost testHost) { await TestInClassAsync( @@ -6503,8 +6316,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestExclamationExclamation(TestHost testHost) { await TestAsync( @@ -6533,8 +6345,7 @@ void M(string v!!) /// /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LocalFunctionDeclaration(TestHost testHost) { await TestAsync( @@ -6592,8 +6403,7 @@ static void staticLocalFunction() { }|] Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ScopedParameter(TestHost testHost) { await TestInMethodAsync(@"interface I { void F(scoped R r); }", @@ -6612,8 +6422,7 @@ public async Task ScopedParameter(TestHost testHost) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ScopedLocalDeclaration(TestHost testHost) { await TestInMethodAsync(@"scoped var v;", @@ -6624,8 +6433,7 @@ public async Task ScopedLocalDeclaration(TestHost testHost) Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ScopedOutDeclaration(TestHost testHost) { await TestInMethodAsync(@"F(x, out scoped R y);", @@ -6642,8 +6450,7 @@ public async Task ScopedOutDeclaration(TestHost testHost) Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LambdaDefaultParameter_01(TestHost testHost) { await TestAsync( @@ -6704,8 +6511,7 @@ void M() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LambdaDefaultParameter_02(TestHost testHost) { await TestAsync( @@ -6744,8 +6550,7 @@ void M() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LambdaParamsArray(TestHost testHost) { await TestInMethodAsync("var lam = (params int[] xs) => xs.Length;", @@ -6767,8 +6572,7 @@ public async Task LambdaParamsArray(TestHost testHost) Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LambdaParamsArray_Multiple(TestHost testHost) { await TestInMethodAsync("var lam = (int a, int b = 1, params int[] xs, params int[] ys.Length) => { };", diff --git a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs index edb1b6ff0c82f..46ad3f8b5af81 100644 --- a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs +++ b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.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; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Remote.Testing; @@ -17,8 +15,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Classification [Trait(Traits.Feature, Traits.Features.Classification)] public partial class SyntacticClassifierTests { - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfTrue(TestHost testHost) { var code = @@ -33,8 +30,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfTrueWithComment(TestHost testHost) { var code = @@ -50,8 +46,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfFalse(TestHost testHost) { var code = @@ -66,8 +61,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfGOO(TestHost testHost) { var code = @@ -82,8 +76,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfNotTrue(TestHost testHost) { var code = @@ -99,8 +92,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfNotFalse(TestHost testHost) { var code = @@ -116,8 +108,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfNotGOO(TestHost testHost) { var code = @@ -133,8 +124,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfTrueWithParens(TestHost testHost) { var code = @@ -151,8 +141,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfFalseWithParens(TestHost testHost) { var code = @@ -169,8 +158,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfGOOWithParens(TestHost testHost) { var code = @@ -187,8 +175,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfOrExpression(TestHost testHost) { var code = @@ -206,8 +193,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfAndExpression(TestHost testHost) { var code = @@ -225,8 +211,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfOrAndExpression(TestHost testHost) { var code = @@ -246,8 +231,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfOrExpressionWithParens(TestHost testHost) { var code = @@ -267,8 +251,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfAndExpressionWithParens(TestHost testHost) { var code = @@ -288,8 +271,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfOrAndExpressionWithParens(TestHost testHost) { var code = @@ -311,8 +293,7 @@ await TestInMethodAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_If1(TestHost testHost) { await TestAsync("#if goo", @@ -322,8 +303,7 @@ await TestAsync("#if goo", Identifier("goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_If2(TestHost testHost) { await TestAsync(" #if goo", @@ -333,8 +313,7 @@ await TestAsync(" #if goo", Identifier("goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_If3(TestHost testHost) { var code = @@ -349,8 +328,7 @@ await TestAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_If4(TestHost testHost) { var code = @@ -364,8 +342,7 @@ await TestAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_If5(TestHost testHost) { var code = @@ -384,8 +361,7 @@ await TestAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_If6(TestHost testHost) { var code = @@ -401,8 +377,7 @@ await TestAsync(code, Identifier("aeu")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_If7(TestHost testHost) { var code = @@ -488,8 +463,7 @@ await TestAsync( script ? Field("aeu") : Identifier("aeu")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_Region1(TestHost testHost) { await TestAsync("#region Goo", @@ -499,8 +473,7 @@ await TestAsync("#region Goo", PPText("Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_Region2(TestHost testHost) { await TestAsync(" #region goo", @@ -510,8 +483,7 @@ await TestAsync(" #region goo", PPText("goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_EndRegion1(TestHost testHost) { await TestAsync("#endregion", @@ -520,8 +492,7 @@ await TestAsync("#endregion", PPKeyword("endregion")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_EndRegion2(TestHost testHost) { await TestAsync(" #endregion", @@ -530,8 +501,7 @@ await TestAsync(" #endregion", PPKeyword("endregion")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_EndRegion3(TestHost testHost) { await TestAsync("#endregion adsf", @@ -541,8 +511,7 @@ await TestAsync("#endregion adsf", PPText("adsf")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_EndRegion4(TestHost testHost) { await TestAsync(" #endregion adsf", @@ -552,8 +521,7 @@ await TestAsync(" #endregion adsf", PPText("adsf")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_RegionEndRegion1(TestHost testHost) { await TestAsync( @@ -566,8 +534,7 @@ await TestAsync( PPKeyword("endregion")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_CommentAfterRegion1(TestHost testHost) { await TestAsync( @@ -581,8 +548,7 @@ await TestAsync( PPKeyword("endregion")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_CommentAfterRegion2(TestHost testHost) { await TestAsync( @@ -596,8 +562,7 @@ await TestAsync( PPKeyword("endregion")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_CommentAfterEndRegion1(TestHost testHost) { await TestAsync( @@ -611,8 +576,7 @@ await TestAsync( PPText("adsf //comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_CommentAfterEndRegion2(TestHost testHost) { await TestAsync( @@ -626,8 +590,7 @@ await TestAsync( Comment("//comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_DeclarationDirectives(TestHost testHost) { await TestAsync( @@ -642,8 +605,7 @@ await TestAsync( Identifier("B")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_IfElseEndIfDirectives(TestHost testHost) { var code = @@ -665,8 +627,7 @@ await TestAsync(code, PPKeyword("endif")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_DefineDirective(TestHost testHost) { var code = @"#define GOO"; @@ -677,8 +638,7 @@ await TestAsync(code, Identifier("GOO")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_DefineDirectiveWithCommentAndNoName(TestHost testHost) { var code = @"#define //Goo"; @@ -689,8 +649,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_DefineDirectiveWithComment(TestHost testHost) { var code = @"#define GOO //Goo"; @@ -702,8 +661,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_UndefDirectives(TestHost testHost) { var code = @"#undef GOO"; @@ -715,8 +673,7 @@ await TestAsync(code, Identifier("GOO")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_UndefDirectiveWithCommentAndNoName(TestHost testHost) { var code = @"#undef //Goo"; @@ -727,8 +684,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_UndefDirectiveWithComment(TestHost testHost) { var code = @"#undef GOO //Goo"; @@ -740,8 +696,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_ErrorDirective(TestHost testHost) { var code = @"#error GOO"; @@ -753,8 +708,7 @@ await TestAsync(code, PPText("GOO")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_ErrorDirectiveWithComment(TestHost testHost) { var code = @"#error GOO //Goo"; @@ -766,8 +720,7 @@ await TestAsync(code, PPText("GOO //Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_WarningDirective(TestHost testHost) { var code = @"#warning GOO"; @@ -779,8 +732,7 @@ await TestAsync(code, PPText("GOO")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_WarningDirectiveWithComment(TestHost testHost) { var code = @"#warning GOO //Goo"; @@ -792,8 +744,7 @@ await TestAsync(code, PPText("GOO //Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineHidden(TestHost testHost) { var code = @"#line hidden"; @@ -805,8 +756,7 @@ await TestAsync(code, PPKeyword("hidden")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineHiddenWithComment(TestHost testHost) { var code = @"#line hidden //Goo"; @@ -819,8 +769,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineDefault(TestHost testHost) { var code = @"#line default"; @@ -832,8 +781,7 @@ await TestAsync(code, PPKeyword("default")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineDefaultWithComment(TestHost testHost) { var code = @"#line default //Goo"; @@ -846,8 +794,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineNumber(TestHost testHost) { var code = @"#line 100"; @@ -859,8 +806,7 @@ await TestAsync(code, Number("100")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineNumberWithComment(TestHost testHost) { var code = @"#line 100 //Goo"; @@ -873,8 +819,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineNumberWithFilename(TestHost testHost) { var code = @"#line 100 ""C:\Goo"""; @@ -887,8 +832,7 @@ await TestAsync(code, String("\"C:\\Goo\"")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineNumberWithFilenameAndComment(TestHost testHost) { var code = @"#line 100 ""C:\Goo"" //Goo"; @@ -902,8 +846,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineSpanWithCharacterOffset(TestHost testHost) { var code = @"#line (1, 2) - (3, 4) 5 ""file.txt"""; @@ -927,8 +870,7 @@ await TestAsync(code, String("\"file.txt\"")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_LineSpanWithComment(TestHost testHost) { var code = @"#line (1, 2) - (3, 4) """" //comment"; @@ -952,8 +894,7 @@ await TestAsync(code, Comment("//comment")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_NullableEnable(TestHost testHost) { var code = @"#nullable enable"; @@ -965,8 +906,7 @@ await TestAsync(code, PPKeyword("enable")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_NullableEnableWithComment(TestHost testHost) { var code = @"#nullable enable //Goo"; @@ -979,8 +919,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_NullableEnableWarnings(TestHost testHost) { var code = @"#nullable enable warnings"; @@ -993,8 +932,7 @@ await TestAsync(code, PPKeyword("warnings")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_NullableEnableWarningsWithComment(TestHost testHost) { var code = @"#nullable enable warnings //Goo"; @@ -1008,8 +946,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_NullableEnableAnnotations(TestHost testHost) { var code = @"#nullable enable annotations"; @@ -1022,8 +959,7 @@ await TestAsync(code, PPKeyword("annotations")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_NullableEnableAnnotationsWithComment(TestHost testHost) { var code = @"#nullable enable annotations //Goo"; @@ -1037,8 +973,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_NullableDisable(TestHost testHost) { var code = @"#nullable disable"; @@ -1050,8 +985,7 @@ await TestAsync(code, PPKeyword("disable")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_NullableDisableWithComment(TestHost testHost) { var code = @"#nullable disable //Goo"; @@ -1064,8 +998,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaChecksum1(TestHost testHost) { await TestAsync( @@ -1077,8 +1010,7 @@ await TestAsync( PPText("stuff")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaChecksum2(TestHost testHost) { await TestAsync( @@ -1092,8 +1024,7 @@ await TestAsync( String("\"2453\"")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaChecksum3(TestHost testHost) { await TestAsync( @@ -1108,8 +1039,7 @@ await TestAsync( Comment("// Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaWarningDisableOne(TestHost testHost) { var code = @"#pragma warning disable 100"; @@ -1123,8 +1053,7 @@ await TestAsync(code, Number("100")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaWarningDisableOneWithComment(TestHost testHost) { var code = @"#pragma warning disable 100 //Goo"; @@ -1139,8 +1068,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(30783, "https://github.com/dotnet/roslyn/issues/30783")] public async Task PP_PragmaWarningDisableAllWithComment(TestHost testHost) { @@ -1155,8 +1083,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaWarningRestoreOne(TestHost testHost) { var code = @"#pragma warning restore 100"; @@ -1170,8 +1097,7 @@ await TestAsync(code, Number("100")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaWarningRestoreOneWithComment(TestHost testHost) { var code = @"#pragma warning restore 100 //Goo"; @@ -1186,8 +1112,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(30783, "https://github.com/dotnet/roslyn/issues/30783")] public async Task PP_PragmaWarningRestoreAllWithComment(TestHost testHost) { @@ -1202,8 +1127,7 @@ await TestAsync(code, Comment("//Goo")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaWarningDisableTwo(TestHost testHost) { var code = @"#pragma warning disable 100, 101"; @@ -1219,8 +1143,7 @@ await TestAsync(code, Number("101")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaWarningRestoreTwo(TestHost testHost) { var code = @"#pragma warning restore 100, 101"; @@ -1236,8 +1159,7 @@ await TestAsync(code, Number("101")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaWarningDisableThree(TestHost testHost) { var code = @"#pragma warning disable 100, 101, 102"; @@ -1255,8 +1177,7 @@ await TestAsync(code, Number("102")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PP_PragmaWarningRestoreThree(TestHost testHost) { var code = @"#pragma warning restore 100, 101, 102"; @@ -1274,8 +1195,7 @@ await TestAsync(code, Number("102")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInOutDeclaration(TestHost testHost) { await TestInMethodAsync( @@ -1285,8 +1205,7 @@ await TestInMethodAsync( Keyword("_"), Punctuation.CloseParen, Punctuation.Semicolon)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInCasePattern(TestHost testHost) { await TestInMethodAsync( @@ -1296,8 +1215,7 @@ await TestInMethodAsync( Punctuation.OpenCurly, ControlKeyword("case"), Keyword("int"), Keyword("_"), Punctuation.Colon, Punctuation.CloseCurly)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInDeconstruction(TestHost testHost) { await TestInMethodAsync( @@ -1308,8 +1226,7 @@ await TestInMethodAsync( Punctuation.Comma, Number("2"), Punctuation.CloseParen, Punctuation.Semicolon)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInDeconstruction2(TestHost testHost) { await TestInMethodAsync( @@ -1320,8 +1237,7 @@ await TestInMethodAsync( Number("1"), Punctuation.Comma, Number("2"), Punctuation.CloseParen, Punctuation.Semicolon)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ShortDiscardInDeconstruction(TestHost testHost) { await TestInMethodAsync( @@ -1333,8 +1249,7 @@ await TestInMethodAsync( Punctuation.Semicolon)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ShortDiscardInOutDeclaration(TestHost testHost) { await TestInMethodAsync( @@ -1344,8 +1259,7 @@ await TestInMethodAsync( Punctuation.Semicolon)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ShortDiscardInAssignment(TestHost testHost) { await TestInMethodAsync( @@ -1354,8 +1268,7 @@ await TestInMethodAsync( expected: Classifications(Identifier("_"), Operators.Equals, Number("1"), Punctuation.Semicolon)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UnderscoreInLambda(TestHost testHost) { await TestInMethodAsync( @@ -1365,8 +1278,7 @@ await TestInMethodAsync( Operators.EqualsGreaterThan, Number("1"), Punctuation.Semicolon)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DiscardInLambda(TestHost testHost) { await TestInMethodAsync( @@ -1376,8 +1288,7 @@ await TestInMethodAsync( Operators.EqualsGreaterThan, Number("1"), Punctuation.Semicolon)); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UnderscoreInAssignment(TestHost testHost) { await TestInMethodAsync(code: @"int _; _ = 1;", diff --git a/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests.cs b/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests.cs index fe9866db7e8be..1ba1e35ec495f 100644 --- a/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests.cs +++ b/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests.cs @@ -28,8 +28,7 @@ protected override async Task> GetClassificationS return await GetAllClassificationsAsync(document, span); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsUsingAliasForNamespace(TestHost testHost) { await TestAsync( @@ -42,8 +41,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(547068, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/547068")] public async Task Bug17819(TestHost testHost) { @@ -71,8 +69,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsUsingAliasForClass(TestHost testHost) { await TestAsync( @@ -88,8 +85,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsUsingAliasForDelegate(TestHost testHost) { await TestAsync( @@ -104,8 +100,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsUsingAliasForStruct(TestHost testHost) { await TestAsync( @@ -120,8 +115,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsUsingAliasForEnum(TestHost testHost) { await TestAsync( @@ -136,8 +130,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsUsingAliasForInterface(TestHost testHost) { await TestAsync( @@ -152,8 +145,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task VarAsConstructorName(TestHost testHost) { await TestAsync( @@ -175,8 +167,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRecordClass(TestHost testHost) { await TestAsync( @@ -199,8 +190,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestRecordStruct(TestHost testHost) { await TestAsync( @@ -225,8 +215,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task UsingAliasGlobalNamespace(TestHost testHost) { await TestAsync( @@ -243,8 +232,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task PartialDynamicWhere(TestHost testHost) { var code = @"partial class partial where where : partial @@ -294,8 +282,7 @@ await TestAsync(code, Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(543123, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543123")] public async Task VarInForeach(TestHost testHost) { @@ -312,8 +299,7 @@ await TestInMethodAsync(@"foreach (var v in args) { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ValueInSetterAndAnonymousTypePropertyName(TestHost testHost) { await TestAsync( @@ -351,8 +337,7 @@ int P Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestValueInEvent(TestHost testHost) { await TestInClassAsync( @@ -395,8 +380,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestValueInProperty(TestHost testHost) { await TestInClassAsync( @@ -438,8 +422,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task ValueFieldInSetterAccessedThroughThis(TestHost testHost) { await TestInClassAsync( @@ -466,8 +449,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NewOfInterface(TestHost testHost) { await TestInMethodAsync( @@ -658,8 +640,7 @@ namespace C Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task NameAttributeValue(TestHost testHost) { await TestAsync( @@ -698,8 +679,7 @@ void Goo(int x) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task Cref1(TestHost testHost) { await TestAsync( @@ -739,8 +719,7 @@ void Goo() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task CrefNamespaceIsNotClass(TestHost testHost) { await TestAsync( @@ -772,8 +751,7 @@ class Program Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task InterfacePropertyWithSameNameShouldBePreferredToType(TestHost testHost) { await TestAsync( @@ -807,8 +785,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(633, "https://github.com/dotnet/roslyn/issues/633")] public async Task XmlDocCref(TestHost testHost) { @@ -862,8 +839,7 @@ public MyClass(int x) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestGenericTypeWithNoArity(TestHost testHost) { await TestAsync( @@ -889,8 +865,7 @@ class Program : IReadOnlyCollection Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestGenericTypeWithWrongArity(TestHost testHost) { await TestAsync( @@ -921,8 +896,7 @@ class Program : IReadOnlyCollection Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestExtensionMethodDeclaration(TestHost testHost) { await TestAsync( @@ -954,8 +928,7 @@ public static void TestMethod(this C c) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestExtensionMethodUsage(TestHost testHost) { await TestAsync( @@ -1028,8 +1001,7 @@ void Test() Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestConstLocals(TestHost testHost) { await TestInMethodAsync( @@ -1050,8 +1022,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_InsideMethod(TestHost testHost) { await TestInMethodAsync(@" @@ -1068,8 +1039,7 @@ await TestInMethodAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_Keyword(TestHost testHost) { await TestAsync( @@ -1088,8 +1058,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -1113,8 +1082,7 @@ class X where T : unmanaged { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Type_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -1145,8 +1113,7 @@ class X where T : unmanaged { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_Keyword(TestHost testHost) { await TestAsync(@" @@ -1174,8 +1141,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -1208,8 +1174,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Method_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -1249,8 +1214,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_Keyword(TestHost testHost) { await TestAsync( @@ -1271,8 +1235,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -1298,8 +1261,7 @@ interface unmanaged {} Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_Delegate_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -1332,8 +1294,7 @@ interface unmanaged {} Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_Keyword(TestHost testHost) { await TestAsync(@" @@ -1370,8 +1331,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -1413,8 +1373,7 @@ void M() where T : unmanaged { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestUnmanagedConstraint_LocalFunction_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -1540,8 +1499,7 @@ class True Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_InsideMethod(TestHost testHost) { await TestInMethodAsync(@" @@ -1558,8 +1516,7 @@ await TestInMethodAsync(@" Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_Keyword(TestHost testHost) { await TestAsync( @@ -1578,8 +1535,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -1603,8 +1559,7 @@ class X where T : notnull { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Type_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -1635,8 +1590,7 @@ class X where T : notnull { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_Keyword(TestHost testHost) { await TestAsync(@" @@ -1664,8 +1618,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -1698,8 +1651,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Method_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -1739,8 +1691,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_Keyword(TestHost testHost) { await TestAsync( @@ -1761,8 +1712,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -1788,8 +1738,7 @@ interface notnull {} Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_Delegate_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -1822,8 +1771,7 @@ interface notnull {} Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_Keyword(TestHost testHost) { await TestAsync(@" @@ -1860,8 +1808,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_ExistingInterface(TestHost testHost) { await TestAsync(@" @@ -1903,8 +1850,7 @@ void M() where T : notnull { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestNotNullConstraint_LocalFunction_ExistingInterfaceButOutOfScope(TestHost testHost) { await TestAsync(@" @@ -2180,8 +2126,7 @@ void Goo(object o) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task BasicFileScopedNamespaceClassification(TestHost testHost) { await TestAsync( @@ -2198,8 +2143,7 @@ class C { }", Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestStringEscape(TestHost testHost) { await TestInMethodAsync(@"var goo = $@""{{{12:X}}}"";", @@ -2219,8 +2163,7 @@ public async Task TestStringEscape(TestHost testHost) Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(55313, "https://github.com/dotnet/roslyn/issues/55313")] public async Task TestStaticConstructorClass(TestHost testHost) { @@ -2244,8 +2187,7 @@ static C() { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(55313, "https://github.com/dotnet/roslyn/issues/55313")] public async Task TestStaticConstructorInterface(TestHost testHost) { @@ -2269,8 +2211,7 @@ static C() { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(59569, "https://github.com/dotnet/roslyn/issues/59569")] public async Task TestArgsInTopLevel(TestHost testHost) { @@ -2292,8 +2233,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(59569, "https://github.com/dotnet/roslyn/issues/59569")] public async Task TestArgsInNormalProgram(TestHost testHost) { @@ -2321,8 +2261,7 @@ static void Main(string[] args) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncInIncompleteMember(TestHost testHost) { @@ -2341,8 +2280,7 @@ public async Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncInIncompleteMemberWhenAsyncTypeIsDefined(TestHost testHost) { @@ -2365,8 +2303,7 @@ class async Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncInPotentialLocalFunctionDeclaration(TestHost testHost) { @@ -2386,8 +2323,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncInPotentialLocalFunctionDeclarationWhenAsyncTypeIsDefined(TestHost testHost) { @@ -2411,8 +2347,7 @@ class async Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncAsLocalMemberType_NoAsyncInScope(TestHost testHost) { @@ -2431,8 +2366,7 @@ void M() Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncAsLocalMemberType_AsyncInScope(TestHost testHost) { @@ -2454,8 +2388,7 @@ void M() Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncAsPropertyType_NoAsyncInScope(TestHost testHost) { @@ -2477,8 +2410,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncAsPropertyType_AsyncInScope(TestHost testHost) { @@ -2503,8 +2435,7 @@ class Test Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncAsMethodReturnType_NoAsyncInScope(TestHost testHost) { @@ -2522,8 +2453,7 @@ await TestAsync( Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncAsMethodReturnType_AsyncInScope(TestHost testHost) { @@ -2544,8 +2474,7 @@ class Test Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncAsAccessingName(TestHost testHost) { @@ -2571,8 +2500,7 @@ class C Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] [WorkItem(60399, "https://github.com/dotnet/roslyn/issues/60339")] public async Task TestAsyncInIncompleteDelegateOrLambda(TestHost testHost) { @@ -2595,8 +2523,7 @@ void M() /// /// - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task LocalFunctionDeclarationAndUse(TestHost testHost) { await TestAsync( @@ -2656,8 +2583,7 @@ static void staticLocalFunction() { }|] Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task TestScopedVar(TestHost testHost) { await TestAsync(""" @@ -2695,8 +2621,7 @@ file readonly ref struct S { } Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task Lambda_DefaultParameterValue(TestHost testHost) { await TestAsync( @@ -2723,5 +2648,97 @@ void M() Operators.EqualsGreaterThan, Parameter("x")); } + + [Theory, CombinatorialData] + public async Task UsingAliasToType1(TestHost testHost) + { + await TestAsync( + """ + using X = int; + """, + testHost, + Keyword("using"), + Struct("X"), + Operators.Equals, + Keyword("int"), + Punctuation.Semicolon); + } + + [Theory, CombinatorialData] + public async Task UsingAliasToType2(TestHost testHost) + { + await TestAsync( + """ + using X = int[]; + """, + testHost, + Keyword("using"), + Identifier("X"), + Operators.Equals, + Keyword("int"), + Punctuation.OpenBracket, + Punctuation.CloseBracket, + Punctuation.Semicolon); + } + + [Theory, CombinatorialData] + public async Task UsingAliasToType3(TestHost testHost) + { + await TestAsync( + """ + using unsafe X = int*; + """, + testHost, + Keyword("using"), + Keyword("unsafe"), + Identifier("X"), + Operators.Equals, + Keyword("int"), + Operators.Asterisk, + Punctuation.Semicolon); + } + + [Theory, CombinatorialData] + public async Task UsingAliasToType4(TestHost testHost) + { + await TestAsync( + """ + using unsafe X = delegate*; + """, + testHost, + Keyword("using"), + Keyword("unsafe"), + Identifier("X"), + Operators.Equals, + Keyword("delegate"), + Operators.Asterisk, + Punctuation.OpenAngle, + Keyword("int"), + Punctuation.Comma, + Keyword("int"), + Punctuation.CloseAngle, + Punctuation.Semicolon); + } + + [Theory, CombinatorialData] + public async Task UsingAliasToType5(TestHost testHost) + { + await TestAsync( + """ + using X = (int x, string b); + """, + testHost, + Keyword("using"), + Struct("X"), + Operators.Equals, + Punctuation.OpenParen, + Keyword("int"), + Identifier("x"), + Punctuation.Comma, + Keyword("string"), + Identifier("b"), + Punctuation.CloseParen, + Punctuation.Semicolon); + } } } diff --git a/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests_Dynamic.cs b/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests_Dynamic.cs index a6f14eea32093..b48fefdb3c96d 100644 --- a/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests_Dynamic.cs +++ b/src/EditorFeatures/CSharpTest/Classification/TotalClassifierTests_Dynamic.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.Threading.Tasks; using Microsoft.CodeAnalysis.Remote.Testing; using Microsoft.CodeAnalysis.Test.Utilities; @@ -15,8 +13,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Classification { public partial class TotalClassifierTests { - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsParamTypeAndDefault(TestHost testHost) { await TestInClassAsync(@"void M(dynamic d = default(dynamic", @@ -32,8 +29,7 @@ public async Task DynamicAsParamTypeAndDefault(TestHost testHost) Keyword("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicExplicitConversion(TestHost testHost) { await TestInMethodAsync( @@ -49,8 +45,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicMethodCall(TestHost testHost) { await TestInMethodAsync(@"dynamic.Equals(1, 1);", @@ -66,8 +61,7 @@ public async Task DynamicMethodCall(TestHost testHost) Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicNullable(TestHost testHost) { await TestInMethodAsync(@"dynamic? a", @@ -77,8 +71,7 @@ await TestInMethodAsync(@"dynamic? a", Local("a")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsUsingAliasForClass(TestHost testHost) { await TestAsync( @@ -93,8 +86,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsUsingAliasForDelegate(TestHost testHost) { await TestAsync( @@ -109,8 +101,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsUsingAliasForStruct(TestHost testHost) { await TestAsync( @@ -125,8 +116,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsUsingAliasForEnum(TestHost testHost) { await TestAsync( @@ -141,8 +131,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsUsingAliasForInterface(TestHost testHost) { await TestAsync( @@ -157,8 +146,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsExternAlias(TestHost testHost) { await TestAsync( @@ -184,8 +172,7 @@ class C Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsDelegateType(TestHost testHost) { await TestAsync(@"delegate void dynamic()", @@ -197,8 +184,7 @@ await TestAsync(@"delegate void dynamic()", Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsDelegateReturnTypeAndParam(TestHost testHost) { await TestAsync(@"delegate dynamic MyDelegate (dynamic d)", @@ -212,8 +198,7 @@ await TestAsync(@"delegate dynamic MyDelegate (dynamic d)", Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsDelegateLocalVariable(TestHost testHost) { await TestInMethodAsync( @@ -247,8 +232,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericTypeName(TestHost testHost) { await TestAsync( @@ -281,8 +265,7 @@ class C Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericField(TestHost testHost) { await TestAsync( @@ -303,8 +286,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsIndexerTypeAndParameter(TestHost testHost) { await TestInClassAsync(@"dynamic this[dynamic i]", @@ -317,8 +299,7 @@ await TestInClassAsync(@"dynamic this[dynamic i]", Punctuation.CloseBracket); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsOperatorTypeAndParameter(TestHost testHost) { await TestInClassAsync(@"static dynamic operator +(dynamic d1)", @@ -333,8 +314,7 @@ await TestInClassAsync(@"static dynamic operator +(dynamic d1)", Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsOperatorName(TestHost testHost) { await TestInClassAsync(@"static explicit operator dynamic(dynamic s)", @@ -349,8 +329,7 @@ await TestInClassAsync(@"static explicit operator dynamic(dynamic s)", Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsPropertyTypeAndName(TestHost testHost) { await TestInClassAsync(@"dynamic dynamic { get; set; }", @@ -365,8 +344,7 @@ public async Task DynamicAsPropertyTypeAndName(TestHost testHost) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsEventName(TestHost testHost) { await TestInClassAsync(@"event Action dynamic", @@ -376,8 +354,7 @@ await TestInClassAsync(@"event Action dynamic", Event("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsLinqLocalVariable(TestHost testHost) { await TestInMethodAsync(@"var v = from dynamic in names", @@ -391,8 +368,7 @@ await TestInMethodAsync(@"var v = from dynamic in names", Identifier("names")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsAnonymousTypePropertyName(TestHost testHost) { await TestInMethodAsync( @@ -416,8 +392,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsArgumentToLambdaExpression(TestHost testHost) { await TestInMethodAsync( @@ -439,8 +414,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsAnonymousMethodLocalVariable(TestHost testHost) { await TestInMethodAsync( @@ -469,8 +443,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsMethodName(TestHost testHost) { await TestInClassAsync( @@ -486,8 +459,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsStaticMethodTypeAndParams(TestHost testHost) { await TestInClassAsync( @@ -510,8 +482,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicArraysInMethodSignature(TestHost testHost) { await TestInClassAsync( @@ -539,8 +510,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicInPartialMethods(TestHost testHost) { await TestInClassAsync( @@ -569,8 +539,7 @@ partial void F(dynamic d) Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicRefAndOutParameters(TestHost testHost) { await TestInClassAsync( @@ -593,8 +562,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicInExtensionMethod(TestHost testHost) { await TestInClassAsync( @@ -616,8 +584,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsBaseClass(TestHost testHost) { await TestAsync( @@ -633,8 +600,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericConstraint(TestHost testHost) { await TestAsync( @@ -655,8 +621,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicSizeOf(TestHost testHost) { await TestInClassAsync( @@ -680,8 +645,7 @@ await TestInClassAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicTypeOf(TestHost testHost) { await TestInMethodAsync(@"typeof(dynamic)", @@ -719,8 +683,7 @@ await TestAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicInForeach(TestHost testHost) { await TestInMethodAsync(@"foreach (dynamic dynamic in dynamic", @@ -733,8 +696,7 @@ await TestInMethodAsync(@"foreach (dynamic dynamic in dynamic", Identifier("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicInUsing(TestHost testHost) { await TestInMethodAsync(@"using(dynamic d", @@ -745,8 +707,7 @@ await TestInMethodAsync(@"using(dynamic d", Local("d")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsLocalVariableName(TestHost testHost) { await TestInMethodAsync( @@ -757,8 +718,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsNamespaceName(TestHost testHost) { await TestAsync( @@ -772,8 +732,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsClassName(TestHost testHost) { await TestAsync( @@ -787,8 +746,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsConstructorDeclarationName(TestHost testHost) { await TestAsync( @@ -810,8 +768,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsNamespaceAlias(TestHost testHost) { await TestInMethodAsync( @@ -824,8 +781,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGotoLabel(TestHost testHost) { await TestInMethodAsync( @@ -844,8 +800,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsEnumField(TestHost testHost) { await TestInMethodAsync( @@ -860,8 +815,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsEnumFieldDefinition(TestHost testHost) { await TestAsync( @@ -877,8 +831,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsEnumType(TestHost testHost) { await TestAsync( @@ -892,8 +845,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericTypeParameter(TestHost testHost) { await TestAsync( @@ -920,8 +872,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsFieldType(TestHost testHost) { await TestInClassAsync(@"dynamic d", @@ -930,8 +881,7 @@ await TestInClassAsync(@"dynamic d", Field("d")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsStaticFieldType(TestHost testHost) { await TestInClassAsync(@"static dynamic d", @@ -942,8 +892,7 @@ await TestInClassAsync(@"static dynamic d", Static("d")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsLocalVariableType(TestHost testHost) { await TestInMethodAsync(@"dynamic d", @@ -952,8 +901,7 @@ await TestInMethodAsync(@"dynamic d", Local("d")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsArrayLocalVariableType(TestHost testHost) { await TestInMethodAsync(@"dynamic[] d", @@ -964,8 +912,7 @@ await TestInMethodAsync(@"dynamic[] d", Local("d")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsLambdaParameterType(TestHost testHost) { await TestInMethodAsync( @@ -990,8 +937,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicArray(TestHost testHost) { await TestInMethodAsync( @@ -1008,8 +954,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicConstructor(TestHost testHost) { await TestInMethodAsync( @@ -1025,8 +970,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAfterIs(TestHost testHost) { await TestInMethodAsync(@"if (a is dynamic)", @@ -1039,8 +983,7 @@ await TestInMethodAsync(@"if (a is dynamic)", Punctuation.CloseParen); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAfterAs(TestHost testHost) { await TestInMethodAsync(@"a = a as dynamic", @@ -1052,8 +995,7 @@ await TestInMethodAsync(@"a = a as dynamic", Keyword("dynamic")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsGenericTypeArgument(TestHost testHost) { await TestInMethodAsync( @@ -1075,8 +1017,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsSecondGenericTypeArgument(TestHost testHost) { await TestInMethodAsync( @@ -1092,8 +1033,7 @@ await TestInMethodAsync( Punctuation.Semicolon); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsRegionLabel(TestHost testHost) { var code = @@ -1108,8 +1048,7 @@ await TestAsync(code, PPKeyword("endregion")); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsInterfaceType(TestHost testHost) { await TestAsync( @@ -1123,8 +1062,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsStructType(TestHost testHost) { await TestAsync( @@ -1138,8 +1076,7 @@ await TestAsync( Punctuation.CloseCurly); } - [Theory] - [CombinatorialData] + [Theory, CombinatorialData] public async Task DynamicAsUndefinedGenericType(TestHost testHost) { await TestInMethodAsync( diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs index 1eef94e730226..33190030f99eb 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/TopLevelEditingTests.cs @@ -25,7 +25,7 @@ public class TopLevelEditingTests : EditingTestBase #region Usings [Fact] - public void Using_Global_Insert() + public void Using_Global_Insert1() { var src1 = @" using System.Collections.Generic; @@ -44,6 +44,26 @@ public void Using_Global_Insert() edits.VerifySemanticDiagnostics(); } + [Fact] + public void Using_Global_Insert2() + { + var src1 = @" +using unsafe D3 = int*; +"; + var src2 = @" +global using D1 = int; +using D2 = (int, int); +using unsafe D3 = int*; +"; + var edits = GetTopEdits(src1, src2); + + edits.VerifyEdits( + "Insert [global using D1 = int;]@2", + "Insert [using D2 = (int, int);]@26"); + + edits.VerifySemanticDiagnostics(); + } + [Fact] public void Using_Delete1() { @@ -79,7 +99,27 @@ public void Using_Delete2() } [Fact] - public void Using_Insert() + public void Using_Delete3() + { + var src1 = @" +global using D1 = int; +using D2 = (int, int); +using unsafe D3 = int*; +"; + var src2 = @" +using D2 = (int, int); +"; + var edits = GetTopEdits(src1, src2); + + edits.VerifyEdits( + "Delete [global using D1 = int;]@2", + "Delete [using unsafe D3 = int*;]@50"); + + edits.VerifySemanticDiagnostics(); + } + + [Fact] + public void Using_Insert1() { var src1 = @" using System.Collections.Generic; @@ -98,6 +138,28 @@ public void Using_Insert() edits.VerifySemanticDiagnostics(); } + [Fact] + public void Using_Insert2() + { + var src1 = @" +using System.Collections.Generic; +"; + var src2 = @" +global using D1 = int; +using D2 = (int, int); +using unsafe D3 = int*; +using System.Collections.Generic; +"; + var edits = GetTopEdits(src1, src2); + + edits.VerifyEdits( + "Insert [global using D1 = int;]@2", + "Insert [using D2 = (int, int);]@26", + "Insert [using unsafe D3 = int*;]@50"); + + edits.VerifySemanticDiagnostics(); + } + [Fact] public void Using_Update1() { @@ -161,6 +223,29 @@ public void Using_Update3() edits.VerifySemanticDiagnostics(); } + [Fact] + public void Using_Update4() + { + var src1 = @" +using X = int; +using Y = int; +using Z = int; +"; + var src2 = @" +using X = string; +using unsafe Y = int*; +global using Z = int; +"; + var edits = GetTopEdits(src1, src2); + + edits.VerifyEdits( + "Update [using X = int;]@2 -> [using X = string;]@2", + "Update [using Y = int;]@18 -> [using unsafe Y = int*;]@21", + "Update [using Z = int;]@34 -> [global using Z = int;]@45"); + + edits.VerifySemanticDiagnostics(); + } + [Fact] public void Using_Reorder1() { @@ -180,6 +265,23 @@ public void Using_Reorder1() "Reorder [using System.Diagnostics;]@2 -> @64"); } + [Fact] + public void Using_Reorder2() + { + var src1 = @" +using X = int; +using Y = string; +"; + var src2 = @" +using Y = string; +using X = int; +"; + var edits = GetTopEdits(src1, src2); + + edits.VerifyEdits( + "Reorder [using Y = string;]@18 -> @2"); + } + [Fact] public void Using_InsertDelete1() { diff --git a/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs b/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs index 81cc77795b828..7a58d184f74d7 100644 --- a/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs +++ b/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs @@ -8624,5 +8624,84 @@ static void Main() await TestAsync(source, MainDescription($"({FeaturesResources.local_variable}) scoped ref int r")); } + + [Fact] + public async Task TestUsingAliasToType1() + { + var source = +@"using X = $$int;"; + await TestAsync(source, + MainDescription($"struct System.Int32")); + } + + [Fact] + public async Task TestUsingAliasToType1_A() + { + var source = +@"using $$X = int;"; + await TestAsync(source, + MainDescription($"struct System.Int32")); + } + + [Fact] + public async Task TestUsingAliasToType2() + { + var source = +@"using X = ($$int a, int b);"; + await TestAsync(source, + MainDescription($"struct System.Int32")); + } + + [Fact] + public async Task TestUsingAliasToType2_A() + { + var source = +@"using $$X = (int a, int b);"; + await TestAsync(source, + MainDescription($"(int a, int b)")); + } + + [Fact] + public async Task TestUsingAliasToType3() + { + var source = +@"using X = $$(int a, int b);"; + await TestAsync(source); + } + + [Fact] + public async Task TestUsingAliasToType4() + { + var source = +@"using unsafe X = $$delegate*;"; + await TestAsync(source); + } + + [Fact] + public async Task TestUsingAliasToType4_A() + { + var source = +@"using unsafe $$X = delegate*;"; + await TestAsync(source, + MainDescription($"delegate*")); + } + + [Fact] + public async Task TestUsingAliasToType5() + { + var source = +@"using unsafe X = $$int*;"; + await TestAsync(source, + MainDescription($"struct System.Int32")); + } + + [Fact] + public async Task TestUsingAliasToType5_A() + { + var source = +@"using unsafe $$X = int*;"; + await TestAsync(source, + MainDescription($"int*")); + } } } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/BoolKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/BoolKeywordRecommenderTests.cs index 2ceeaa92c1524..0311ffa7876fd 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/BoolKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/BoolKeywordRecommenderTests.cs @@ -44,16 +44,23 @@ await VerifyKeywordAsync( } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TesInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ByteKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ByteKeywordRecommenderTests.cs index b8aff259dfea4..60c9f53d1d296 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ByteKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ByteKeywordRecommenderTests.cs @@ -44,16 +44,23 @@ await VerifyKeywordAsync( } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/CharKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/CharKeywordRecommenderTests.cs index 62dc9a5db6443..c44a5443c74b3 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/CharKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/CharKeywordRecommenderTests.cs @@ -43,17 +43,24 @@ await VerifyKeywordAsync(SourceCodeKind.Script, $$"); } - [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInUsingAlias() + [Fact] + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/DecimalKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/DecimalKeywordRecommenderTests.cs index 780f27840012f..b2843b6ee4e17 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/DecimalKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/DecimalKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/DelegateKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/DelegateKeywordRecommenderTests.cs index 2cde666183ac0..c0434eb2dff62 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/DelegateKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/DelegateKeywordRecommenderTests.cs @@ -44,20 +44,27 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"using Goo = d$$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = d$$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/DoubleKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/DoubleKeywordRecommenderTests.cs index 952c936337ff8..08114fa5f5e98 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/DoubleKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/DoubleKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/DynamicKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/DynamicKeywordRecommenderTests.cs index 65b1b8a61f44e..19abe717a6774 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/DynamicKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/DynamicKeywordRecommenderTests.cs @@ -55,17 +55,24 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInUsingAlias_Tuple() { - await VerifyAbsenceAsync( -@"global using Goo = $$"); + await VerifyKeywordAsync( +@"using Goo = ($$"); } [Fact] diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/FloatKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/FloatKeywordRecommenderTests.cs index 4a0b5d88dbf26..5b6a83acb23d9 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/FloatKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/FloatKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/IntKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/IntKeywordRecommenderTests.cs index e37d084789a3f..b6073094b12ac 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/IntKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/IntKeywordRecommenderTests.cs @@ -59,16 +59,37 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInUsingAlias_Tuple() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( +@"using Goo = ($$"); + } + + [Fact] + public async Task TestInUsingAlias_FuncPointer() + { + await VerifyKeywordAsync( +@"using Goo = delegate*<$$"); + } + + [Fact] + public async Task TestInGlobalUsingAlias() + { + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/LongKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/LongKeywordRecommenderTests.cs index 873ca30570cfc..f505106077f97 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/LongKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/LongKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/NativeIntegerKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/NativeIntegerKeywordRecommenderTests.cs index 1f25aad3f428b..ca517f09baaaa 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/NativeIntegerKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/NativeIntegerKeywordRecommenderTests.cs @@ -222,10 +222,16 @@ await VerifyKeywordAsync( nint* p = stackalloc $$"); } + [Fact] + public async Task TestNotInUsing() + { + await VerifyAbsenceAsync( +@"using $$"); + } + [Fact] public async Task TestInUsingAliasFirst() { - // Ideally, keywords should not be recommended as first token in target. await VerifyKeywordAsync( @"using A = $$"); } @@ -233,7 +239,6 @@ await VerifyKeywordAsync( [Fact] public async Task TestInGlobalUsingAliasFirst() { - // Ideally, keywords should not be recommended as first token in target. await VerifyKeywordAsync( @"global using A = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ObjectKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ObjectKeywordRecommenderTests.cs index af410741c1ca2..c5d6a0e8595dd 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ObjectKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ObjectKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/SByteKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/SByteKeywordRecommenderTests.cs index 22874eddc4592..29e9edcbbff61 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/SByteKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/SByteKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ShortKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ShortKeywordRecommenderTests.cs index 233aa121bdc35..810cf0ab77150 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ShortKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ShortKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/StringKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/StringKeywordRecommenderTests.cs index 52b3cd0ee7328..91797e65a67ac 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/StringKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/StringKeywordRecommenderTests.cs @@ -44,16 +44,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/UIntKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/UIntKeywordRecommenderTests.cs index 371721df65dde..60b47abe65162 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/UIntKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/UIntKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ULongKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ULongKeywordRecommenderTests.cs index d0030a3272468..9337a53e8e8c1 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ULongKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ULongKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/UShortKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/UShortKeywordRecommenderTests.cs index 67430834633af..07b059cd937a9 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/UShortKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/UShortKeywordRecommenderTests.cs @@ -45,16 +45,23 @@ await VerifyKeywordAsync(SourceCodeKind.Script, } [Fact] - public async Task TestNotInUsingAlias() + public async Task TestNotInUsing() { await VerifyAbsenceAsync( +@"using $$"); + } + + [Fact] + public async Task TestInUsingAlias() + { + await VerifyKeywordAsync( @"using Goo = $$"); } [Fact] - public async Task TestNotInGlobalUsingAlias() + public async Task TestInGlobalUsingAlias() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"global using Goo = $$"); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractNativeIntegerKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractNativeIntegerKeywordRecommender.cs index 711ab8e938644..1ce83ccae3be4 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractNativeIntegerKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractNativeIntegerKeywordRecommender.cs @@ -25,6 +25,7 @@ private static bool IsValidContext(CSharpSyntaxContext context) context.IsGlobalStatementContext || context.IsPossibleTupleContext || context.IsAtStartOfPattern || + context.IsUsingAliasTypeContext || (context.IsTypeContext && !context.IsEnumBaseListContext)) { return true; diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/BoolKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/BoolKeywordRecommender.cs index e4fc2557c5601..cdd0621901768 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/BoolKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/BoolKeywordRecommender.cs @@ -38,6 +38,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ByteKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ByteKeywordRecommender.cs index f382666eefb1e..3970c12758f2b 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ByteKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ByteKeywordRecommender.cs @@ -39,6 +39,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/CharKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/CharKeywordRecommender.cs index 3ea3e68a4dcf5..07566624eaef7 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/CharKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/CharKeywordRecommender.cs @@ -38,6 +38,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DecimalKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DecimalKeywordRecommender.cs index 218cf5154f7e0..fb9c3b8208ee6 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DecimalKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DecimalKeywordRecommender.cs @@ -38,6 +38,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs index b46a43967db44..a46f022c971b4 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs @@ -30,6 +30,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context { return context.IsGlobalStatementContext || + context.IsUsingAliasTypeContext || ValidTypeContext(context) || IsAfterAsyncKeywordInExpressionContext(context, cancellationToken) || context.IsTypeDeclarationContext( diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DoubleKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DoubleKeywordRecommender.cs index b094e83c3f8cd..b69d01a653219 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DoubleKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DoubleKeywordRecommender.cs @@ -38,6 +38,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DynamicKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DynamicKeywordRecommender.cs index 9f4ea1c06bb8e..7249f3ae4d521 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DynamicKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DynamicKeywordRecommender.cs @@ -58,6 +58,8 @@ protected static bool IsDynamicTypeContext( context.IsParameterTypeContext || context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext || context.IsDelegateReturnTypeContext || + context.IsUsingAliasTypeContext || + context.IsPossibleTupleContext || syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: SyntaxKindSet.AllMemberModifiers, diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/FloatKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/FloatKeywordRecommender.cs index f639605b7c6f0..bc266d22e55d2 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/FloatKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/FloatKeywordRecommender.cs @@ -38,6 +38,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/GlobalKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/GlobalKeywordRecommender.cs index 430822733b537..fc1ad7136303b 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/GlobalKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/GlobalKeywordRecommender.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Threading; -using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -24,21 +23,13 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context if (syntaxTree.IsMemberDeclarationContext(position, context.LeftToken)) { var token = context.TargetToken; - if (token.GetAncestor() == null) - { return true; - } } return context.IsTypeContext || - UsingKeywordRecommender.IsUsingDirectiveContext(context, forGlobalKeyword: true, cancellationToken) || - context.IsAnyExpressionContext || - syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || - syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || - syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || - syntaxTree.IsUsingAliasContext(position, cancellationToken); + UsingKeywordRecommender.IsUsingDirectiveContext(context, forGlobalKeyword: true, cancellationToken); } } } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/IntKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/IntKeywordRecommender.cs index ef83b4fadc4e8..4fcaaf2438016 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/IntKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/IntKeywordRecommender.cs @@ -39,6 +39,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/LongKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/LongKeywordRecommender.cs index 5e3a25f616cc0..348ed5f0a20e9 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/LongKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/LongKeywordRecommender.cs @@ -39,6 +39,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ObjectKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ObjectKeywordRecommender.cs index 723fa9629bd2f..0fcccaf8854d1 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ObjectKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ObjectKeywordRecommender.cs @@ -37,6 +37,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsTypeOfExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsDefaultExpressionContext(position, context.LeftToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/SByteKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/SByteKeywordRecommender.cs index cd264773d59be..44edb156967a2 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/SByteKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/SByteKeywordRecommender.cs @@ -39,6 +39,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ShortKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ShortKeywordRecommender.cs index 7df11c939ecc8..8f9fa472ed5d4 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ShortKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ShortKeywordRecommender.cs @@ -39,6 +39,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StringKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StringKeywordRecommender.cs index 397a8d2a64a0d..3059cd5a02e04 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StringKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StringKeywordRecommender.cs @@ -37,6 +37,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsTypeOfExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsDefaultExpressionContext(position, context.LeftToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UIntKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UIntKeywordRecommender.cs index d6a055c98c083..e6fcfaa6f15a6 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UIntKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UIntKeywordRecommender.cs @@ -39,6 +39,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ULongKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ULongKeywordRecommender.cs index 2d4a8e8da6b83..3e8213505ec04 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ULongKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ULongKeywordRecommender.cs @@ -39,6 +39,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UShortKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UShortKeywordRecommender.cs index 45fbe5bff6c58..e8adc8b7945b5 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UShortKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UShortKeywordRecommender.cs @@ -46,6 +46,7 @@ protected override bool IsValidContextWorker(int position, CSharpSyntaxContext c context.IsImplicitOrExplicitOperatorTypeContext || context.IsPrimaryFunctionExpressionContext || context.IsCrefContext || + context.IsUsingAliasTypeContext || syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.RefKeyword, cancellationToken) || syntaxTree.IsAfterKeyword(position, SyntaxKind.ReadOnlyKeyword, cancellationToken) || diff --git a/src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs b/src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs index df4310648e714..5bac6a333b59f 100644 --- a/src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs +++ b/src/Features/CSharp/Portable/EditAndContinue/SyntaxComparer.cs @@ -790,27 +790,53 @@ protected override bool TryComputeWeightedDistance(SyntaxNode leftNode, SyntaxNo } case SyntaxKind.UsingStatement: - var leftUsing = (UsingStatementSyntax)leftNode; - var rightUsing = (UsingStatementSyntax)rightNode; - - if (leftUsing.Declaration != null && rightUsing.Declaration != null) { - distance = ComputeWeightedDistance( - leftUsing.Declaration, - leftUsing.Statement, - rightUsing.Declaration, - rightUsing.Statement); + var leftUsing = (UsingStatementSyntax)leftNode; + var rightUsing = (UsingStatementSyntax)rightNode; + + if (leftUsing.Declaration != null && rightUsing.Declaration != null) + { + distance = ComputeWeightedDistance( + leftUsing.Declaration, + leftUsing.Statement, + rightUsing.Declaration, + rightUsing.Statement); + } + else + { + distance = ComputeWeightedDistance( + (SyntaxNode?)leftUsing.Expression ?? leftUsing.Declaration!, + leftUsing.Statement, + (SyntaxNode?)rightUsing.Expression ?? rightUsing.Declaration!, + rightUsing.Statement); + } + + return true; } - else + + case SyntaxKind.UsingDirective: { - distance = ComputeWeightedDistance( - (SyntaxNode?)leftUsing.Expression ?? leftUsing.Declaration!, - leftUsing.Statement, - (SyntaxNode?)rightUsing.Expression ?? rightUsing.Declaration!, - rightUsing.Statement); - } + var leftUsing = (UsingDirectiveSyntax)leftNode; + var rightUsing = (UsingDirectiveSyntax)rightNode; - return true; + // For now, just compute the distances of both the alias and name and combine their weights + // 50/50. We could consider weighting the alias more heavily. i.e. if you have `using X = ...` + // and `using X = ...` it's more likely that this is the same alias, and just the name portion + // changed versus thinking that some other using became this alias. + distance = + ComputeDistance(leftUsing.Alias, rightUsing.Alias) + + ComputeDistance(leftUsing.NamespaceOrType, rightUsing.NamespaceOrType); + + // Consider two usings that only differ by presence/absence of 'global' to be a near match. + if (leftUsing.GlobalKeyword.IsKind(SyntaxKind.None) != rightUsing.GlobalKeyword.IsKind(SyntaxKind.None)) + distance += EpsilonDist; + + // Consider two usings that only differ by presence/absence of 'unsafe' to be a near match. + if (leftUsing.UnsafeKeyword.IsKind(SyntaxKind.None) != rightUsing.UnsafeKeyword.IsKind(SyntaxKind.None)) + distance += EpsilonDist; + + return true; + } case SyntaxKind.LockStatement: var leftLock = (LockStatementSyntax)leftNode; @@ -1381,7 +1407,7 @@ private static double CombineOptional( return ((ExternAliasDirectiveSyntax)node).Identifier; case SyntaxKind.UsingDirective: - return ((UsingDirectiveSyntax)node).Name; + return ((UsingDirectiveSyntax)node).NamespaceOrType; case SyntaxKind.NamespaceDeclaration: case SyntaxKind.FileScopedNamespaceDeclaration: diff --git a/src/VisualStudio/CSharp/Impl/CodeModel/CSharpCodeModelService.cs b/src/VisualStudio/CSharp/Impl/CodeModel/CSharpCodeModelService.cs index 0879b75f5c555..73dc9fc2d06ab 100644 --- a/src/VisualStudio/CSharp/Impl/CodeModel/CSharpCodeModelService.cs +++ b/src/VisualStudio/CSharp/Impl/CodeModel/CSharpCodeModelService.cs @@ -1838,7 +1838,7 @@ public override string GetImportNamespaceOrType(SyntaxNode importNode) { if (importNode is UsingDirectiveSyntax usingDirective) { - return usingDirective.Type.ToString(); + return usingDirective.NamespaceOrType.ToString(); } throw new InvalidOperationException(); @@ -1852,7 +1852,7 @@ public override void GetImportParentAndName(SyntaxNode importNode, out SyntaxNod ? null : usingDirective.Parent; - name = usingDirective.Type.ToString(); + name = usingDirective.NamespaceOrType.ToString(); return; } diff --git a/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/UsingDirectiveSyntaxClassifier.cs b/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/UsingDirectiveSyntaxClassifier.cs index 6cbc8a663d0eb..345f67edc9092 100644 --- a/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/UsingDirectiveSyntaxClassifier.cs +++ b/src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/UsingDirectiveSyntaxClassifier.cs @@ -41,7 +41,7 @@ private static void ClassifyUsingDirectiveSyntax( { var token = usingDirective.Alias.Name; - var symbolInfo = semanticModel.GetSymbolInfo(usingDirective.Type, cancellationToken); + var symbolInfo = semanticModel.GetSymbolInfo(usingDirective.NamespaceOrType, cancellationToken); if (symbolInfo.Symbol is ITypeSymbol typeSymbol) { var classification = GetClassificationForType(typeSymbol); diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs index 0afd2a1d2aa04..c83483e49aa11 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs @@ -1929,7 +1929,7 @@ private SyntaxNode WithNameInternal(SyntaxNode declaration, string name) EnumMemberDeclarationSyntax enumMemberDeclaration => ReplaceWithTrivia(declaration, enumMemberDeclaration.Identifier, id), EventDeclarationSyntax eventDeclaration => ReplaceWithTrivia(declaration, eventDeclaration.Identifier, id), BaseNamespaceDeclarationSyntax namespaceDeclaration => ReplaceWithTrivia(declaration, namespaceDeclaration.Name, this.DottedName(name)), - UsingDirectiveSyntax usingDeclaration => ReplaceWithTrivia(declaration, usingDeclaration.Type, this.DottedName(name)), + UsingDirectiveSyntax usingDeclaration => ReplaceWithTrivia(declaration, usingDeclaration.NamespaceOrType, this.DottedName(name)), ParameterSyntax parameter => ReplaceWithTrivia(declaration, parameter.Identifier, id), LocalDeclarationStatementSyntax localDeclaration when localDeclaration.Declaration.Variables.Count == 1 => diff --git a/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs b/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs index f086b80d3ec87..d1853d3f02e92 100644 --- a/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs +++ b/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs @@ -674,7 +674,7 @@ protected override bool TryGetAliasesFromUsingDirective( if (usingDirectiveNode.Alias != null) { if (TryGetSimpleTypeName(usingDirectiveNode.Alias.Name, typeParameterNames: null, out var aliasName, out _) && - TryGetSimpleTypeName(usingDirectiveNode.Type, typeParameterNames: null, out var name, out _)) + TryGetSimpleTypeName(usingDirectiveNode.NamespaceOrType, typeParameterNames: null, out var name, out _)) { aliases = ImmutableArray.Create<(string, string)>((aliasName, name)); return true; diff --git a/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs b/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs index 86d350c972f94..db05961d62174 100644 --- a/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs +++ b/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs @@ -10708,5 +10708,33 @@ await AssertFormatAsync( var s = $""""""{s, 0 : x }"""""" "); } + + [Fact] + public async Task FormatUsingAliasToType1() + { + await AssertFormatAsync( + expected: @" +f([Attribute] () => { }); +", + code: @" +f( [Attribute] () => { }); +"); + } + + [Theory] + [InlineData("using X=int ;", "using X = int;")] + [InlineData("global using X=int ;", "global using X = int;")] + [InlineData("using X=nint;", "using X = nint;")] + [InlineData("using X=dynamic;", "using X = dynamic;")] + [InlineData("using X=int [] ;", "using X = int[];")] + [InlineData("using X=(int,int) ;", "using X = (int, int);")] + [InlineData("using unsafe X=int * ;", "using unsafe X = int*;")] + [InlineData("global using unsafe X=int * ;", "global using unsafe X = int*;")] + [InlineData("using X=int ?;", "using X = int?;")] + [InlineData("using X=delegate * ;", "using X = delegate*;")] + public async Task TestNormalizeUsingAlias(string text, string expected) + { + await AssertFormatAsync(expected, text); + } } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SemanticModelExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SemanticModelExtensions.cs index 70f6369893be5..24eb4e7bac13b 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SemanticModelExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Extensions/SemanticModelExtensions.cs @@ -169,8 +169,8 @@ public static ISet GetUsingNamespacesInScope(this SemanticMode { if (@using.Alias == null) { - Contract.ThrowIfNull(@using.Type); - var symbolInfo = semanticModel.GetSymbolInfo(@using.Type); + Contract.ThrowIfNull(@using.NamespaceOrType); + var symbolInfo = semanticModel.GetSymbolInfo(@using.NamespaceOrType); if (symbolInfo.Symbol != null && symbolInfo.Symbol.Kind == SymbolKind.Namespace) { result ??= new HashSet(); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs index e50f68c670a20..36ad8a89e0340 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Services/SyntaxFacts/CSharpSyntaxFacts.cs @@ -191,7 +191,7 @@ public bool IsParameterList([NotNullWhen(true)] SyntaxNode? node) public bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node) => node?.Parent is UsingDirectiveSyntax usingDirective && - usingDirective.Type == node; + usingDirective.NamespaceOrType == node; public bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node) => node is UsingDirectiveSyntax usingDirectiveNode && usingDirectiveNode.Alias != null; @@ -201,7 +201,7 @@ public void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globa var usingDirective = (UsingDirectiveSyntax)node; globalKeyword = usingDirective.GlobalKeyword; alias = usingDirective.Alias!.Name.Identifier; - name = usingDirective.Type; + name = usingDirective.NamespaceOrType; } public bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs index a4d750cd4dc39..ffd6386a5e968 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/CSharpSyntaxContext.cs @@ -44,6 +44,7 @@ internal sealed class CSharpSyntaxContext : SyntaxContext public readonly bool IsPrimaryFunctionExpressionContext; public readonly bool IsTypeArgumentOfConstraintContext; public readonly bool IsTypeOfExpressionContext; + public readonly bool IsUsingAliasTypeContext; public readonly ISet PrecedingModifiers; @@ -105,6 +106,7 @@ private CSharpSyntaxContext( bool isTypeArgumentOfConstraintContext, bool isTypeContext, bool isTypeOfExpressionContext, + bool isUsingAliasTypeContext, bool isWithinAsyncMethod, ISet precedingModifiers, CancellationToken cancellationToken) @@ -170,6 +172,7 @@ private CSharpSyntaxContext( this.IsPrimaryFunctionExpressionContext = isPrimaryFunctionExpressionContext; this.IsTypeArgumentOfConstraintContext = isTypeArgumentOfConstraintContext; this.IsTypeOfExpressionContext = isTypeOfExpressionContext; + this.IsUsingAliasTypeContext = isUsingAliasTypeContext; this.PrecedingModifiers = precedingModifiers; } @@ -177,7 +180,8 @@ private CSharpSyntaxContext( public static CSharpSyntaxContext CreateContext(Document document, SemanticModel semanticModel, int position, CancellationToken cancellationToken) => CreateContextWorker(document, semanticModel, position, cancellationToken); - private static CSharpSyntaxContext CreateContextWorker(Document document, SemanticModel semanticModel, int position, CancellationToken cancellationToken) + private static CSharpSyntaxContext CreateContextWorker( + Document document, SemanticModel semanticModel, int position, CancellationToken cancellationToken) { var syntaxTree = semanticModel.SyntaxTree; @@ -298,6 +302,7 @@ private static CSharpSyntaxContext CreateContextWorker(Document document, Semant isTypeArgumentOfConstraintContext: syntaxTree.IsTypeArgumentOfConstraintClause(position, cancellationToken), isTypeContext: syntaxTree.IsTypeContext(position, cancellationToken, semanticModel), isTypeOfExpressionContext: syntaxTree.IsTypeOfExpressionContext(position, leftToken), + isUsingAliasTypeContext: syntaxTree.IsUsingAliasTypeContext(position, cancellationToken), isWithinAsyncMethod: ComputeIsWithinAsyncMethod(), precedingModifiers: precedingModifiers, cancellationToken: cancellationToken); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs index e00ec3bd809ab..9e2e452dbff07 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -749,7 +749,7 @@ public static bool IsTypeContext( syntaxTree.IsStatementContext(position, tokenOnLeftOfPosition, cancellationToken) || syntaxTree.IsGlobalStatementContext(position, cancellationToken) || syntaxTree.IsTypeParameterConstraintContext(position, tokenOnLeftOfPosition) || - syntaxTree.IsUsingAliasContext(position, cancellationToken) || + syntaxTree.IsUsingAliasTypeContext(position, cancellationToken) || syntaxTree.IsUsingStaticContext(position, cancellationToken) || syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || syntaxTree.IsPossibleTupleContext(tokenOnLeftOfPosition, position) || @@ -784,7 +784,7 @@ public static bool IsBaseClassOrInterfaceContext(this SyntaxTree syntaxTree, int return false; } - public static bool IsUsingAliasContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken) + public static bool IsUsingAliasTypeContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken) { // using Goo = |