diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/PartialKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/PartialKeywordRecommenderTests.cs index eeaff78bda0bc..6ddbcaa616131 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/PartialKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/PartialKeywordRecommenderTests.cs @@ -344,9 +344,9 @@ await VerifyKeywordAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterNestedReadOnly() + public async Task TestAfterNestedReadOnly() { - await VerifyAbsenceAsync(@"class C { + await VerifyKeywordAsync(@"class C { readonly $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs index 6ea5811d6465c..a0f694315f44e 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs @@ -55,15 +55,15 @@ await VerifyAbsenceAsync(AddInsideMethod( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInCompilationUnit() + public async Task TestInCompilationUnit() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"$$"); + await VerifyKeywordAsync(SourceCodeKind.Regular, @"$$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterExtern() + public async Task TestAfterExtern() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"extern alias Goo; + await VerifyKeywordAsync(SourceCodeKind.Regular, @"extern alias Goo; $$"); } @@ -75,9 +75,9 @@ public async Task TestAfterExtern_Interactive() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterUsing() + public async Task TestAfterUsing() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"using Goo; + await VerifyKeywordAsync(SourceCodeKind.Regular, @"using Goo; $$"); } @@ -89,23 +89,23 @@ public async Task TestAfterUsing_Interactive() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterNamespace() + public async Task TestAfterNamespace() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"namespace N {} + await VerifyKeywordAsync(SourceCodeKind.Regular, @"namespace N {} $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterTypeDeclaration() + public async Task TestAfterTypeDeclaration() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"class C {} + await VerifyKeywordAsync(SourceCodeKind.Regular, @"class C {} $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterDelegateDeclaration() + public async Task TestAfterDelegateDeclaration() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"delegate void Goo(); + await VerifyKeywordAsync(SourceCodeKind.Regular, @"delegate void Goo(); $$"); } @@ -153,9 +153,9 @@ await VerifyAbsenceAsync(SourceCodeKind.Script, } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterAssemblyAttribute() + public async Task TestAfterAssemblyAttribute() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"[assembly: goo] + await VerifyKeywordAsync(SourceCodeKind.Regular, @"[assembly: goo] $$"); } @@ -167,9 +167,9 @@ await VerifyKeywordAsync(SourceCodeKind.Script, @"[assembly: goo] } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterRootAttribute() + public async Task TestAfterRootAttribute() { - await VerifyAbsenceAsync(@"[goo] + await VerifyKeywordAsync(@"[goo] $$"); } @@ -213,21 +213,21 @@ await VerifyKeywordAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterPartial() + public async Task TestAfterPartial() { - await VerifyAbsenceAsync(@"partial $$"); + await VerifyKeywordAsync(@"partial $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterAbstract() + public async Task TestAfterAbstract() { - await VerifyAbsenceAsync(@"abstract $$"); + await VerifyKeywordAsync(@"abstract $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterInternal() + public async Task TestAfterInternal() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"internal $$"); + await VerifyKeywordAsync(SourceCodeKind.Regular, @"internal $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -245,9 +245,9 @@ await VerifyKeywordAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterPublic() + public async Task TestAfterPublic() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"public $$"); + await VerifyKeywordAsync(SourceCodeKind.Regular, @"public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -265,9 +265,9 @@ await VerifyKeywordAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterPrivate() + public async Task TestAfterPrivate() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, + await VerifyKeywordAsync(SourceCodeKind.Regular, @"private $$"); } @@ -287,9 +287,9 @@ await VerifyKeywordAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterProtected() + public async Task TestAfterProtected() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"protected $$"); } @@ -302,23 +302,23 @@ await VerifyKeywordAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterSealed() + public async Task TestAfterSealed() { - await VerifyAbsenceAsync(@"sealed $$"); + await VerifyKeywordAsync(@"sealed $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterNestedSealed() + public async Task TestAfterNestedSealed() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"class C { sealed $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterStatic() + public async Task TestAfterStatic() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"static $$"); + await VerifyKeywordAsync(SourceCodeKind.Regular, @"static $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -336,9 +336,9 @@ await VerifyKeywordAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterStaticPublic() + public async Task TestAfterStaticPublic() { - await VerifyAbsenceAsync(SourceCodeKind.Regular, @"static public $$"); + await VerifyKeywordAsync(SourceCodeKind.Regular, @"static public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -378,9 +378,9 @@ await VerifyAbsenceAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterReadOnly() + public async Task TestAfterReadOnly() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"class C { readonly $$"); } @@ -394,10 +394,33 @@ await VerifyAbsenceAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterNew() + public async Task TestAfterRef() { - await VerifyAbsenceAsync( -@"new $$"); + await VerifyKeywordAsync(SourceCodeKind.Regular, @"ref $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestInRefStruct() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, @"ref $$ struct { }"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestInRefStructBeforeRef() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, @"$$ ref struct { }"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterNew() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, @"new $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterNewInClass() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, @"class C { new $$ }"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/RefKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/RefKeywordRecommenderTests.cs index d85c87e31bb8f..910732702e638 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/RefKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/RefKeywordRecommenderTests.cs @@ -532,9 +532,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterPartial() + public async Task TestAfterPartial() { - await VerifyAbsenceAsync(@"partial $$"); + await VerifyKeywordAsync(@"partial $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -546,9 +546,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterAbstract() + public async Task TestAfterAbstract() { - await VerifyAbsenceWithRefsAsync(@"abstract $$"); + await VerifyKeywordWithRefsAsync(@"abstract $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -560,9 +560,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterInternal() + public async Task TestAfterInternal() { - await VerifyAbsenceWithRefsAsync(SourceCodeKind.Regular, @"internal $$"); + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, @"internal $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -580,9 +580,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterPublic() + public async Task TestAfterPublic() { - await VerifyAbsenceWithRefsAsync(SourceCodeKind.Regular, @"public $$"); + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, @"public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -600,9 +600,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterPrivate() + public async Task TestAfterPrivate() { - await VerifyAbsenceWithRefsAsync(SourceCodeKind.Regular, + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, @"private $$"); } @@ -622,9 +622,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterProtected() + public async Task TestAfterProtected() { - await VerifyAbsenceWithRefsAsync( + await VerifyKeywordWithRefsAsync( @"protected $$"); } @@ -637,9 +637,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterSealed() + public async Task TestAfterSealed() { - await VerifyAbsenceWithRefsAsync(@"sealed $$"); + await VerifyKeywordWithRefsAsync(@"sealed $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -651,9 +651,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterStatic() + public async Task TestAfterStatic() { - await VerifyAbsenceWithRefsAsync(SourceCodeKind.Regular, @"static $$"); + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, @"static $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -663,7 +663,7 @@ public async Task TestAfterStatic_Interactive() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestAfterStatic() + public async Task TestAfterStatic_InClass() { await VerifyKeywordWithRefsAsync( @"class C { @@ -671,9 +671,9 @@ await VerifyKeywordWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterStaticPublic() + public async Task TestAfterStaticPublic() { - await VerifyAbsenceWithRefsAsync(SourceCodeKind.Regular, @"static public $$"); + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, @"static public $$"); } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] @@ -721,12 +721,47 @@ await VerifyAbsenceWithRefsAsync( } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotAfterNew() + public async Task TestAfterReadonly() { - await VerifyAbsenceWithRefsAsync( + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, +@"readonly $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestInReadonlyStruct() + { + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, +@"readonly $$ struct { }"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestInReadonlyStruct_AfterReadonly() + { + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, +@"$$ readonly struct { }"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterNew() + { + await VerifyKeywordWithRefsAsync(SourceCodeKind.Regular, @"new $$"); } + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterNewInClass() + { + await VerifyKeywordWithRefsAsync( +@"class C { new $$ }"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterNewInStruct() + { + await VerifyKeywordWithRefsAsync( +@"struct S { new $$ }"); + } + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestAfterNestedNew() { diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/StructKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/StructKeywordRecommenderTests.cs index d60f572c4d218..6bc55158a93c2 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/StructKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/StructKeywordRecommenderTests.cs @@ -136,6 +136,62 @@ await VerifyAbsenceAsync(SourceCodeKind.Regular, using Goo;"); } + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterReadonly() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, +@"readonly $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterRef() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, +@"ref $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterRefReadonly() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, +@"ref readonly $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterPublicRefReadonly() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, +@"public ref readonly $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterReadonlyRef() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, +@"readonly ref $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestAfterInternalReadonlyRef() + { + await VerifyKeywordAsync(SourceCodeKind.Regular, +@"internal readonly ref $$"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestNotAfterReadonlyInMethod() + { + await VerifyAbsenceAsync(SourceCodeKind.Regular, +@"class C { void M() { readonly $$ } }"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestNotAfterRefInMethod() + { + await VerifyAbsenceAsync(SourceCodeKind.Regular, +@"class C { void M() { ref $$ } }"); + } + [WpfFact(Skip = "https://github.com/dotnet/roslyn/issues/9880"), Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestNotBeforeUsing_Interactive() { diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs index fe4b6731b6cf2..53d5ce247bb71 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs @@ -30,6 +30,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context return context.IsGlobalStatementContext || IsRefReadOnlyContext(context) || + IsValidContextForType(context, cancellationToken) || context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: s_validMemberModifiers, @@ -41,5 +42,11 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context private static bool IsRefReadOnlyContext(CSharpSyntaxContext context) => context.TargetToken.IsKind(SyntaxKind.RefKeyword) && context.TargetToken.Parent.IsKind(SyntaxKind.RefType); + + private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) + { + return context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, + validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: true, cancellationToken); + } } } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs index 4e4468228066c..5327f84c415b0 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs @@ -60,6 +60,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context return syntaxTree.IsParameterModifierContext(position, context.LeftToken, cancellationToken) || syntaxTree.IsAnonymousMethodParameterModifierContext(position, context.LeftToken, cancellationToken) || + IsValidContextForType(context, cancellationToken) || syntaxTree.IsPossibleLambdaParameterModifierContext(position, context.LeftToken, cancellationToken) || context.TargetToken.IsConstructorOrMethodParameterArgumentContext() || context.TargetToken.IsXmlCrefParameterModifierContext() || @@ -141,5 +142,11 @@ private static bool IsValidRefExpressionContext(SyntaxTree syntaxTree, int posit return false; } + + private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) + { + return context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, + validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: true, cancellationToken); + } } } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs index 762b16dfdb100..7cc8ce7305975 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs @@ -15,7 +15,9 @@ internal class StructKeywordRecommender : AbstractSyntacticSingleKeywordRecommen SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, - SyntaxKind.UnsafeKeyword + SyntaxKind.UnsafeKeyword, + SyntaxKind.RefKeyword, + SyntaxKind.ReadOnlyKeyword }; public StructKeywordRecommender() diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs index 6ff555359dac7..e5b2d9924070b 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -577,6 +577,14 @@ public static bool IsTypeDeclarationContext( // the parent is the member // the grandparent is the container of the member var container = token.Parent.GetParent(); + + // ref $$ + // readonly ref $$ + if (container.IsKind(SyntaxKind.IncompleteMember)) + { + return ((IncompleteMemberSyntax)container).Type.IsKind(SyntaxKind.RefType); + } + if (container.IsKind(SyntaxKind.CompilationUnit) || container.IsKind(SyntaxKind.NamespaceDeclaration) || container.IsKind(SyntaxKind.ClassDeclaration) || diff --git a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs index e2848f8fccba3..6409e033fdddb 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs @@ -53,6 +53,7 @@ public static ISet GetPrecedingModifiers( case SyntaxKind.VolatileKeyword: case SyntaxKind.UnsafeKeyword: case SyntaxKind.AsyncKeyword: + case SyntaxKind.RefKeyword: result.Add(token.Kind()); token = token.GetPreviousToken(includeSkipped: true); continue; diff --git a/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs b/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs index 4207b933c72cd..133ff2d9ecb07 100644 --- a/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs +++ b/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs @@ -16,7 +16,9 @@ internal class SyntaxKindSet SyntaxKind.ProtectedKeyword, SyntaxKind.SealedKeyword, SyntaxKind.StaticKeyword, - SyntaxKind.UnsafeKeyword + SyntaxKind.UnsafeKeyword, + SyntaxKind.ReadOnlyKeyword, + SyntaxKind.RefKeyword }; public static readonly ISet AllMemberModifiers = new HashSet(SyntaxFacts.EqualityComparer)