diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs index 207cf2d2cab45858232fcd6361dea15e3e0b5c22..01c546fc5278f8e6baab5dd4ec7cfebbeea6b9e6 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs @@ -27972,6 +27972,8 @@ enum T4 { B } + + delegate void T5(); } class Test1 : I1.T1 @@ -27983,6 +27985,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } public void M1() @@ -28000,7 +28003,7 @@ private void ValidateNestedTypes_01(string source1, Accessibility expected = Acc parseOptions: TestOptions.Regular, targetFramework: targetFramework); - for (int i = 1; i <= 4; i++) + for (int i = 1; i <= 5; i++) { Assert.Equal(expected, compilation1.GetMember("I1.T" + i).DeclaredAccessibility); } @@ -28009,7 +28012,8 @@ private void ValidateNestedTypes_01(string source1, Accessibility expected = Acc @"M1 I1+T2 I1+T3 -B", +B +I1+T5", verify: verify); } @@ -28100,6 +28104,8 @@ public enum T4 { B } + + public delegate void T5(); } class Test1 : I1.T1 @@ -28111,6 +28117,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } public void M1() @@ -28144,6 +28151,8 @@ protected enum T4 { B } + + protected delegate void T5(); } "; var source1 = @@ -28157,6 +28166,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } class Test2 : I1.T1 @@ -28175,7 +28185,7 @@ public void M1() parseOptions: TestOptions.Regular, targetFramework: TargetFramework.DesktopLatestExtended); - for (int i = 1; i <= 4; i++) + for (int i = 1; i <= 5; i++) { Assert.Equal(Accessibility.Protected, compilation1.GetMember("I1.T" + i).DeclaredAccessibility); } @@ -28192,7 +28202,10 @@ public void M1() Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T3").WithLocation(12, 22), // (15,20): error CS8707: Target runtime doesn't support 'protected', 'protected internal', or 'private protected' accessibility for a member of an interface. // protected enum T4 - Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T4").WithLocation(15, 20) + Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T4").WithLocation(15, 20), + // (20,29): error CS8707: Target runtime doesn't support 'protected', 'protected internal', or 'private protected' accessibility for a member of an interface. + // protected delegate void T5(); + Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T5").WithLocation(20, 29) ); var source2 = @@ -28206,6 +28219,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } class Test2 : I1.T1 @@ -28238,9 +28252,15 @@ public void M1() // (10,37): error CS0122: 'I1.T4' is inaccessible due to its protection level // System.Console.WriteLine(I1.T4.B); Diagnostic(ErrorCode.ERR_BadAccess, "T4").WithArguments("I1.T4").WithLocation(10, 37), - // (13,22): error CS0122: 'I1.T1' is inaccessible due to its protection level + // (11,41): error CS0122: 'I1.T5' is inaccessible due to its protection level + // System.Console.WriteLine(new I1.T5(a.M1)); + Diagnostic(ErrorCode.ERR_BadAccess, "T5").WithArguments("I1.T5").WithLocation(11, 41), + // (11,46): error CS0122: 'I1.T1.M1()' is inaccessible due to its protection level + // System.Console.WriteLine(new I1.T5(a.M1)); + Diagnostic(ErrorCode.ERR_BadAccess, "M1").WithArguments("I1.T1.M1()").WithLocation(11, 46), + // (14,22): error CS0122: 'I1.T1' is inaccessible due to its protection level // class Test2 : I1.T1 - Diagnostic(ErrorCode.ERR_BadAccess, "T1").WithArguments("I1.T1").WithLocation(13, 22) + Diagnostic(ErrorCode.ERR_BadAccess, "T1").WithArguments("I1.T1").WithLocation(14, 22) }; compilation2.VerifyDiagnostics(expected); @@ -28263,7 +28283,8 @@ public void M1() @"M1 I1+T2 I1+T3 -B", +B +I1+T5", verify: VerifyOnMonoOrCoreClr); var compilation5 = CreateCompilation(source2, options: TestOptions.DebugExe, @@ -28297,6 +28318,8 @@ protected internal enum T4 { B } + + protected internal delegate void T5(); } "; var source1 = @@ -28310,6 +28333,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } class Test2 : I1.T1 @@ -28333,6 +28357,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } class Test2 : I1.T1 @@ -28351,7 +28376,7 @@ public void M1() parseOptions: TestOptions.Regular, targetFramework: TargetFramework.DesktopLatestExtended); - for (int i = 1; i <= 4; i++) + for (int i = 1; i <= 5; i++) { Assert.Equal(Accessibility.ProtectedOrInternal, compilation1.GetMember("I1.T" + i).DeclaredAccessibility); } @@ -28368,7 +28393,10 @@ public void M1() Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T3").WithLocation(12, 31), // (15,29): error CS8707: Target runtime doesn't support 'protected', 'protected internal', or 'private protected' accessibility for a member of an interface. // protected internal enum T4 - Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T4").WithLocation(15, 29) + Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T4").WithLocation(15, 29), + // (20,38): error CS8707: Target runtime doesn't support 'protected', 'protected internal', or 'private protected' accessibility for a member of an interface. + // protected internal delegate void T5(); + Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T5").WithLocation(20, 38) ); @@ -28390,7 +28418,8 @@ public void M1() @"M1 I1+T2 I1+T3 -B", +B +I1+T5", verify: VerifyOnMonoOrCoreClr); var compilation5 = CreateCompilation(source2, options: TestOptions.DebugExe, @@ -28414,9 +28443,15 @@ public void M1() // (10,37): error CS0122: 'I1.T4' is inaccessible due to its protection level // System.Console.WriteLine(I1.T4.B); Diagnostic(ErrorCode.ERR_BadAccess, "T4").WithArguments("I1.T4").WithLocation(10, 37), - // (13,22): error CS0122: 'I1.T1' is inaccessible due to its protection level + // (11,41): error CS0122: 'I1.T5' is inaccessible due to its protection level + // System.Console.WriteLine(new I1.T5(a.M1)); + Diagnostic(ErrorCode.ERR_BadAccess, "T5").WithArguments("I1.T5").WithLocation(11, 41), + // (11,46): error CS0122: 'I1.T1.M1()' is inaccessible due to its protection level + // System.Console.WriteLine(new I1.T5(a.M1)); + Diagnostic(ErrorCode.ERR_BadAccess, "M1").WithArguments("I1.T1.M1()").WithLocation(11, 46), + // (14,22): error CS0122: 'I1.T1' is inaccessible due to its protection level // class Test2 : I1.T1 - Diagnostic(ErrorCode.ERR_BadAccess, "T1").WithArguments("I1.T1").WithLocation(13, 22) + Diagnostic(ErrorCode.ERR_BadAccess, "T1").WithArguments("I1.T1").WithLocation(14, 22) ); } } @@ -28443,6 +28478,8 @@ internal enum T4 { B } + + internal delegate void T5(); } "; var source2 = @@ -28456,6 +28493,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } public void M1() @@ -28489,7 +28527,13 @@ public void M1() Diagnostic(ErrorCode.ERR_BadAccess, "T3").WithArguments("I1.T3").WithLocation(9, 41), // (10,37): error CS0122: 'I1.T4' is inaccessible due to its protection level // System.Console.WriteLine(I1.T4.B); - Diagnostic(ErrorCode.ERR_BadAccess, "T4").WithArguments("I1.T4").WithLocation(10, 37) + Diagnostic(ErrorCode.ERR_BadAccess, "T4").WithArguments("I1.T4").WithLocation(10, 37), + // (11,41): error CS0122: 'I1.T5' is inaccessible due to its protection level + // System.Console.WriteLine(new I1.T5(a.M1)); + Diagnostic(ErrorCode.ERR_BadAccess, "T5").WithArguments("I1.T5").WithLocation(11, 41), + // (11,46): error CS0122: 'I1.T1.M1()' is inaccessible due to its protection level + // System.Console.WriteLine(new I1.T5(a.M1)); + Diagnostic(ErrorCode.ERR_BadAccess, "M1").WithArguments("I1.T1.M1()").WithLocation(11, 46) }; compilation2.VerifyDiagnostics(expected); @@ -28521,6 +28565,8 @@ private enum T4 B } + private delegate void T5(); + class Test1 : I1.T1 { static void Main() @@ -28530,6 +28576,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } public void M1() @@ -28631,6 +28678,8 @@ private protected enum T4 { B } + + private protected delegate void T5(); } "; var source1 = @@ -28644,6 +28693,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } class Test2 : I1.T1 @@ -28667,6 +28717,7 @@ static void Main() System.Console.WriteLine(new I1.T2()); System.Console.WriteLine(new I1.T3()); System.Console.WriteLine(I1.T4.B); + System.Console.WriteLine(new I1.T5(a.M1)); } class Test2 : I1.T1 @@ -28684,7 +28735,7 @@ public void M1() parseOptions: TestOptions.Regular, targetFramework: TargetFramework.DesktopLatestExtended); - for (int i = 1; i <= 4; i++) + for (int i = 1; i <= 5; i++) { Assert.Equal(Accessibility.ProtectedAndInternal, compilation1.GetMember("I1.T" + i).DeclaredAccessibility); } @@ -28701,7 +28752,10 @@ public void M1() Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T3").WithLocation(12, 30), // (15,28): error CS8707: Target runtime doesn't support 'protected', 'protected internal', or 'private protected' accessibility for a member of an interface. // private protected enum T4 - Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T4").WithLocation(15, 28) + Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T4").WithLocation(15, 28), + // (20,37): error CS8707: Target runtime doesn't support 'protected', 'protected internal', or 'private protected' accessibility for a member of an interface. + // private protected delegate void T5(); + Diagnostic(ErrorCode.ERR_RuntimeDoesNotSupportProtectedAccessForInterfaceMember, "T5").WithLocation(20, 37) ); var compilation2 = CreateCompilation(source2 + source0, options: TestOptions.DebugExe, @@ -28724,9 +28778,15 @@ public void M1() // (10,37): error CS0122: 'I1.T4' is inaccessible due to its protection level // System.Console.WriteLine(I1.T4.B); Diagnostic(ErrorCode.ERR_BadAccess, "T4").WithArguments("I1.T4").WithLocation(10, 37), - // (13,22): error CS0122: 'I1.T1' is inaccessible due to its protection level + // (11,41): error CS0122: 'I1.T5' is inaccessible due to its protection level + // System.Console.WriteLine(new I1.T5(a.M1)); + Diagnostic(ErrorCode.ERR_BadAccess, "T5").WithArguments("I1.T5").WithLocation(11, 41), + // (11,46): error CS0122: 'I1.T1.M1()' is inaccessible due to its protection level + // System.Console.WriteLine(new I1.T5(a.M1)); + Diagnostic(ErrorCode.ERR_BadAccess, "M1").WithArguments("I1.T1.M1()").WithLocation(11, 46), + // (14,22): error CS0122: 'I1.T1' is inaccessible due to its protection level // class Test2 : I1.T1 - Diagnostic(ErrorCode.ERR_BadAccess, "T1").WithArguments("I1.T1").WithLocation(13, 22) + Diagnostic(ErrorCode.ERR_BadAccess, "T1").WithArguments("I1.T1").WithLocation(14, 22) }; compilation2.VerifyDiagnostics(expected); diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/AbstractKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/AbstractKeywordRecommenderTests.cs index 31fc5a0831cf99940c5797ad48e36e6953968612..100dd63480f773f0f95322adb654610d4394d044 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/AbstractKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/AbstractKeywordRecommenderTests.cs @@ -178,9 +178,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/AsyncKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/AsyncKeywordRecommenderTests.cs index 6ab71ab0e2c23a1f7651c34e48f70d3337112546..8da196be4ffd0520c55c3aeaeeba91933257fd91 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/AsyncKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/AsyncKeywordRecommenderTests.cs @@ -36,6 +36,15 @@ public async Task TestMethodDeclaration3() }"); } + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] + public async Task TestInsideInterface() + { + await VerifyKeywordAsync(@"interface C +{ + $$ +}"); + } + [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestMethodDeclarationInGlobalStatement1() { diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ClassKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ClassKeywordRecommenderTests.cs index c315f005730dfecb6cd346d9afa806471103982b..c4ec710a884dac1863a8f75e0de8f9c39abf9158 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ClassKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ClassKeywordRecommenderTests.cs @@ -178,9 +178,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ConstKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ConstKeywordRecommenderTests.cs index a6385a1d78b67f0a263104ea5bb3c75bc37b455c..79934a9ab397963ec530a333d18adb5f53be77da 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ConstKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ConstKeywordRecommenderTests.cs @@ -191,9 +191,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/DelegateKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/DelegateKeywordRecommenderTests.cs index 161bfbb7c9026c4d73ed95644202e9f777ea99f3..9fdc3df67e69ae5c8d2c4d9019ace6c8573fc503 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/DelegateKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/DelegateKeywordRecommenderTests.cs @@ -178,9 +178,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/EnumKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/EnumKeywordRecommenderTests.cs index 96e537f8a9f5e0d0a8f2a63072cd625e2b1acd10..f118b91b3cd3420ac8c5ecea35a53ad063eb0a99 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/EnumKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/EnumKeywordRecommenderTests.cs @@ -185,9 +185,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ExternKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ExternKeywordRecommenderTests.cs index 9683dbb07995a1a4a1a18b9d85ab53acc5e7786d..83362626bf193bf41021da3679ffca59616b5411 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ExternKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ExternKeywordRecommenderTests.cs @@ -167,9 +167,9 @@ public async Task TestInStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInInterface() + public async Task TestInInterface() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/InterfaceKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/InterfaceKeywordRecommenderTests.cs index 752506829fca89962006b0943178a571764090a0..3cd679878b3f0320aa2c647fd585f4dfef7c73eb 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/InterfaceKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/InterfaceKeywordRecommenderTests.cs @@ -178,9 +178,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/InternalKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/InternalKeywordRecommenderTests.cs index abacfc365610ceb10c25d7d47126d6edc0c88465..c089ef7b1c9126176fa4f7029fe9926b9c8c9c0c 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/InternalKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/InternalKeywordRecommenderTests.cs @@ -178,9 +178,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/PartialKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/PartialKeywordRecommenderTests.cs index 6ddbcaa6161310c8ff24ae3e91d05285a9a21607..c9152b8fa639fc4f3173c2bee16390739fde6b83 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/PartialKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/PartialKeywordRecommenderTests.cs @@ -196,9 +196,9 @@ public async Task TestInsidePartialStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/PrivateKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/PrivateKeywordRecommenderTests.cs index c06f9728d12b63d199e15521f10f5903c6929431..b5e404c3e51040e9271b69b4edb7a480e7465997 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/PrivateKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/PrivateKeywordRecommenderTests.cs @@ -189,9 +189,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ProtectedKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ProtectedKeywordRecommenderTests.cs index 85beb332798450d9e74b4cf2587ef42250cfba26..5e3442722318d5605b71ea229bef89dea025df82 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ProtectedKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ProtectedKeywordRecommenderTests.cs @@ -160,9 +160,9 @@ public async Task TestNotInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/PublicKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/PublicKeywordRecommenderTests.cs index badebb101fe7c359add6d0579c9a9bf3c2fc0b9f..4b2a40e49ab2b5610afab2c2c4f27b603a930554 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/PublicKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/PublicKeywordRecommenderTests.cs @@ -181,7 +181,7 @@ public async Task TestInsideStruct() [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] public async Task TestInsideInterface() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs index a0f694315f44e8c19af7c0c5329aa9c11bebaa46..e752018d3588f86ede987b5b6e5cc8c46739ada7 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ReadOnlyKeywordRecommenderTests.cs @@ -191,9 +191,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/SealedKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/SealedKeywordRecommenderTests.cs index 804dc01499ff4b691f060643933489a6cd350b6a..12f798daa07878fee0102021d91f474f4778123b 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/SealedKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/SealedKeywordRecommenderTests.cs @@ -178,9 +178,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/StaticKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/StaticKeywordRecommenderTests.cs index 44081357324aacdef1e421276ffc418b262002bb..09db0bb58ffd209a1bae430d5741cf22e617eb0b 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/StaticKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/StaticKeywordRecommenderTests.cs @@ -180,9 +180,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/StructKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/StructKeywordRecommenderTests.cs index 6bc55158a93c2c174333a9f96ebb2564cc515a51..d70acb638ff3ded671af86eb2fd6bf215a710c6c 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/StructKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/StructKeywordRecommenderTests.cs @@ -234,9 +234,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/TypeKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/TypeKeywordRecommenderTests.cs index dbe7806aa440d2b429a6125f3c93b37c94974490..be78194b3d4a394f3fea2b909111f9fd9d0e2c07 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/TypeKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/TypeKeywordRecommenderTests.cs @@ -163,9 +163,9 @@ public async Task TestNotInMethodTypeParameters() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInInterface() + public async Task TestInInterface() { - await VerifyAbsenceAsync( + await VerifyKeywordAsync( @"interface I { [$$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/VirtualKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/VirtualKeywordRecommenderTests.cs index 6a6c80da720c4577b629440221012de08e107565..094d43b9d8d25cce24449c3a753fed5b70d73a5d 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/VirtualKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/VirtualKeywordRecommenderTests.cs @@ -160,9 +160,9 @@ public async Task TestNotInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/VolatileKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/VolatileKeywordRecommenderTests.cs index f25ba8a5dd353a7c2416288cf8e91e2c6653dcf0..cb3e71d15d40bf4c959856d679ec55a25890109c 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/VolatileKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/VolatileKeywordRecommenderTests.cs @@ -191,9 +191,9 @@ public async Task TestInsideStruct() } [Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)] - public async Task TestNotInsideInterface() + public async Task TestInsideInterface() { - await VerifyAbsenceAsync(@"interface I { + await VerifyKeywordAsync(@"interface I { $$"); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractKeywordRecommender.cs index e25266d01862b30a4821021a79058625b09e42ae..95e68a8301db2b4689c82369a6fcb0bbf870c6ef 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AbstractKeywordRecommender.cs @@ -41,12 +41,12 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context context.IsGlobalStatementContext || context.IsMemberDeclarationContext( validModifiers: s_validMemberModifiers, - validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) || context.IsTypeDeclarationContext( validModifiers: s_validTypeModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AsyncKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AsyncKeywordRecommender.cs index 07631942b44880de003f58b40f8a9d60b359e38b..6361425eac275e6723a4dbe2f9e049e53d3d200c 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AsyncKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/AsyncKeywordRecommender.cs @@ -36,7 +36,7 @@ private static bool InMemberDeclarationContext(int position, CSharpSyntaxContext || context.SyntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: SyntaxKindSet.AllMemberModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: true, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ClassKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ClassKeywordRecommender.cs index c88df979b2a7c9c2e37a29e8015d26b4486459c2..07a73219b6dbf243b8530c1f3c4923a16ba08960 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ClassKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ClassKeywordRecommender.cs @@ -34,7 +34,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context context.IsGlobalStatementContext || context.IsTypeDeclarationContext( validModifiers: s_validModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: true, cancellationToken: cancellationToken) || syntaxTree.IsTypeParameterConstraintStartContext(position, context.LeftToken, cancellationToken); diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ConstKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ConstKeywordRecommender.cs index eb27a093dbd72397cca3e7e1d1f9ffd7f2489679..25109fc200192fd03f5e5913553f6d2721b8d8c2 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ConstKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ConstKeywordRecommender.cs @@ -44,7 +44,7 @@ private bool IsMemberDeclarationContext(CSharpSyntaxContext context, Cancellatio context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, s_validGlobalModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: s_validModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs index f0e7ffe0b4548acddc8ead569473f0acf27cd942..dadb292b01e3e466f08a3e0ae8c33d018b24448a 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/DelegateKeywordRecommender.cs @@ -32,7 +32,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context IsAfterAsyncKeywordInExpressionContext(context, cancellationToken) || context.IsTypeDeclarationContext( validModifiers: s_validModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/EnumKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/EnumKeywordRecommender.cs index 7ec27bbf380d5b41eb6d7df0926f70528fc67d95..0349a238dbf2b69fcb8f4ef3c3be76c475c7d2cd 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/EnumKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/EnumKeywordRecommender.cs @@ -28,7 +28,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context context.IsGlobalStatementContext || context.IsTypeDeclarationContext( validModifiers: s_validModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ExternKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ExternKeywordRecommender.cs index c246c1287285d2f30d4becaa5d8659c5daa819dd..e5663b526806640b0db911aa89521e883a9f0ab7 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ExternKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ExternKeywordRecommender.cs @@ -47,7 +47,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context syntaxTree.IsGlobalMemberDeclarationContext(position, s_validGlobalModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: s_validModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/InterfaceKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/InterfaceKeywordRecommender.cs index a4490a32f0d8698c51c101d6032fb12255c0e5ea..abc51dd8c9ad5aaf07476e61e254f305edcae120 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/InterfaceKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/InterfaceKeywordRecommender.cs @@ -29,7 +29,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context context.IsGlobalStatementContext || context.IsTypeDeclarationContext( validModifiers: s_validModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: true, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/InternalKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/InternalKeywordRecommender.cs index e3a697e34e59d674b45169aa4b42da84dd25a81e..90b14e3b636bc3bc4306d21caee0d8248acdfbc4 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/InternalKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/InternalKeywordRecommender.cs @@ -37,7 +37,7 @@ private static bool IsValidContextForAccessor(CSharpSyntaxContext context) private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken) { if (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || - context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { return CheckPreviousAccessibilityModifiers(context); } @@ -47,7 +47,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) { - if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { return CheckPreviousAccessibilityModifiers(context); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PartialKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PartialKeywordRecommender.cs index 2baa1043965134bdeb45ad12bc682f0dc1018f45..ca8d3652b3b77ac5083a6e8449408fd596cae894 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PartialKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PartialKeywordRecommender.cs @@ -34,7 +34,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context private bool IsMemberDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken) { - if (context.IsMemberDeclarationContext(validModifiers: s_validMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + if (context.IsMemberDeclarationContext(validModifiers: s_validMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { var token = context.LeftToken; var decl = token.GetAncestor(); @@ -55,7 +55,7 @@ private bool IsTypeDeclarationContext(CSharpSyntaxContext context, CancellationT { return context.IsTypeDeclarationContext( validModifiers: SyntaxKindSet.AllTypeModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PrivateKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PrivateKeywordRecommender.cs index 55b9238ed72aceb18ed36d7ef0a2ca77c65984e6..01cd3dec5da2d8b358a9b733d8d14d5947a73782 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PrivateKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PrivateKeywordRecommender.cs @@ -37,7 +37,7 @@ private static bool IsValidContextForAccessor(CSharpSyntaxContext context) private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken) { if (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || - context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { var modifiers = context.PrecedingModifiers; @@ -58,7 +58,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) { - if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { // private things can't be in namespaces. var typeDecl = context.ContainingTypeDeclaration; diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ProtectedKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ProtectedKeywordRecommender.cs index b94e048dfe0fc7483aab879659bb4e95cabe7988..4ca721c67880f9becaeb7b5c3784148da73d067c 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ProtectedKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ProtectedKeywordRecommender.cs @@ -35,7 +35,7 @@ private static bool IsValidContextForAccessor(CSharpSyntaxContext context) private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken) { - if (context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + if (context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { return CheckPreviousAccessibilityModifiers(context); } @@ -45,7 +45,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) { - if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { // protected things can't be in namespaces. var typeDecl = context.ContainingTypeDeclaration; diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PublicKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PublicKeywordRecommender.cs index fca4417dbb96c10571c0a225a0d9e1449a32f601..90255bd11027d0bf1dd3867c8fca962a399b538b 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PublicKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/PublicKeywordRecommender.cs @@ -26,7 +26,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell if (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: SyntaxKindSet.AllMemberModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { @@ -38,7 +38,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) { - if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { return CheckPreviousAccessibilityModifiers(context); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs index 53d5ce247bb71e99005e9862dc0f2b990d38d0ae..a8b86a243a68b06d5dc8f43f53a70b158418918c 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs @@ -34,7 +34,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: s_validMemberModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } @@ -46,7 +46,7 @@ private static bool IsRefReadOnlyContext(CSharpSyntaxContext context) private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) { return context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: true, cancellationToken); + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: true, cancellationToken); } } } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs index fdb6517b2bcc791a36d1fd4d216442a41e14c19a..0a82c079529837b1f4b031dc78ca159be7090809 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/RefKeywordRecommender.cs @@ -167,7 +167,7 @@ private static bool IsValidRefExpressionContext(SyntaxTree syntaxTree, int posit private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) { return context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: true, cancellationToken); + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: true, cancellationToken); } } } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/SealedKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/SealedKeywordRecommender.cs index 31560c433d35707ee0d0929dce0593c7a3aef0fc..44118cd5a6fa8acfc038c344a31901c9f8fedd8b 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/SealedKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/SealedKeywordRecommender.cs @@ -41,12 +41,12 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context context.IsGlobalStatementContext || context.IsMemberDeclarationContext( validModifiers: s_validMemberModifiers, - validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) || context.IsTypeDeclarationContext( validModifiers: s_validTypeModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StaticKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StaticKeywordRecommender.cs index 6ca82c848a5237fd920b51eacdd5649cf418c087..40c5da210c0edb8e55a3a60c1b37ee15a0196337 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StaticKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StaticKeywordRecommender.cs @@ -66,7 +66,7 @@ private static bool IsValidContextForMember(CSharpSyntaxContext context, Cancell context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, s_validGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: s_validMemberModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } @@ -75,7 +75,7 @@ private static bool IsValidContextForType(CSharpSyntaxContext context, Cancellat { return context.IsTypeDeclarationContext( validModifiers: s_validTypeModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs index 7cc8ce7305975b9d1a2f7ee4386b493a4fd4d766..9f004eefdbcb8aa318965640c5b760210e911c84 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/StructKeywordRecommender.cs @@ -32,7 +32,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context context.IsGlobalStatementContext || context.IsTypeDeclarationContext( validModifiers: s_validModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: true, cancellationToken: cancellationToken) || syntaxTree.IsTypeParameterConstraintStartContext(position, context.LeftToken, cancellationToken); diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UnsafeKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UnsafeKeywordRecommender.cs index b72400ea6df0e40f1eebde7fff8658596a46d35e..0f3506085e597f4b70f211fb6cc30a407a03365b 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UnsafeKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/UnsafeKeywordRecommender.cs @@ -61,7 +61,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context return context.IsStatementContext || context.IsGlobalStatementContext || - context.IsTypeDeclarationContext(validModifiers: s_validTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) || + context.IsTypeDeclarationContext(validModifiers: s_validTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) || syntaxTree.IsGlobalMemberDeclarationContext(position, s_validGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: s_validMemberModifiers, diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/VirtualKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/VirtualKeywordRecommender.cs index d6dde435d1b8bb53e2fb0dc3dfd8f18519dfa4b1..b4ac8650288b711da28d1a3b69e984277afeebdc 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/VirtualKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/VirtualKeywordRecommender.cs @@ -28,7 +28,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context { return context.IsMemberDeclarationContext( validModifiers: s_validMemberModifiers, - validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/VolatileKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/VolatileKeywordRecommender.cs index 58463e3b474bada0be1c20e43922ea209a24221e..bedad47f92b8e7360e65d5953bbae1b63484a7fe 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/VolatileKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/VolatileKeywordRecommender.cs @@ -31,7 +31,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext( validModifiers: s_validMemberModifiers, - validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, + validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); } diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs index 7d301e922173bd940331908274cacb2315876ae9..924b769f80f0f7566ac2db53fffcca5f7d1ce561 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/CSharpSyntaxContext.cs @@ -275,7 +275,7 @@ public bool IsTypeAttributeContext(CancellationToken cancellationToken) if (token.Kind() == SyntaxKind.OpenBracketToken && token.Parent.Kind() == SyntaxKind.AttributeList && this.SyntaxTree.IsTypeDeclarationContext( - token.SpanStart, contextOpt: null, validModifiers: null, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) + token.SpanStart, contextOpt: null, validModifiers: null, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken)) { return true; } diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs index 2e62455fb7841cf2da0363dba69e17aac01d31c9..d916631e43afd706780f12911c541b99cd63e5dc 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -407,7 +407,7 @@ public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int positi if (token.IsKind(SyntaxKind.OpenBraceToken)) { - if (token.Parent.IsKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration)) + if (token.Parent.IsKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration)) { return true; } @@ -511,8 +511,8 @@ public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int positi bool canBePartial, CancellationToken cancellationToken) { - // We only allow nested types inside a class or struct, not inside a - // an interface or enum. + // We only allow nested types inside a class, struct, or interface, not inside a + // an enum. var typeDecl = contextOpt != null ? contextOpt.ContainingTypeDeclaration : syntaxTree.GetContainingTypeDeclaration(position, cancellationToken); diff --git a/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs b/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs index 133ff2d9ecb0776efc3574cd01bf1b88af796c31..3984b2e2339633c73f7759d5b51624c01a045687 100644 --- a/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs +++ b/src/Workspaces/CSharp/Portable/Utilities/SyntaxKindSet.cs @@ -75,15 +75,16 @@ internal class SyntaxKindSet SyntaxKind.StructDeclaration, }; - public static readonly ISet ClassStructTypeDeclarations = new HashSet(SyntaxFacts.EqualityComparer) + public static readonly ISet ClassInterfaceTypeDeclarations = new HashSet(SyntaxFacts.EqualityComparer) { + SyntaxKind.InterfaceDeclaration, SyntaxKind.ClassDeclaration, - SyntaxKind.StructDeclaration, }; - public static readonly ISet ClassOnlyTypeDeclarations = new HashSet(SyntaxFacts.EqualityComparer) + public static readonly ISet ClassStructTypeDeclarations = new HashSet(SyntaxFacts.EqualityComparer) { SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, }; public static readonly ISet StructOnlyTypeDeclarations = new HashSet(SyntaxFacts.EqualityComparer)