From caa0460497a18bb9674266f903f3a6d8d8a69ddd Mon Sep 17 00:00:00 2001 From: Jon Senchyna Date: Thu, 15 Oct 2020 23:03:04 -0400 Subject: [PATCH 1/3] Add `using static` tests --- .../CSharp/Test/F1Help/F1HelpTests.cs | 91 ++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs b/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs index 1417d06ae0f64..9e7d5abfee2f1 100644 --- a/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs +++ b/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs @@ -1075,6 +1075,95 @@ await Test_KeywordAsync( delegate T MyDelegate() where T : str[||]uct; }", "structconstraint"); } + + [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] + [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] + public async Task TestUsingStaticOnUsingKeyword() + { + await Test_KeywordAsync( +@"us[||]ing static namespace.Class; + +static class C +{ + static int Field; + + static void Method() {} +}", "using-static"); + } + + [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] + [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] + public async Task TestNormalUsing() + { + await Test_KeywordAsync( +@"us[||]ing namespace.Class; + +static class C +{ + static int Field; + + static void Method() {} +}", "using"); + } + + [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] + [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] + public async Task TestUsingStaticOnStaticKeyword() + { + await Test_KeywordAsync( +@"using sta[||]tic namespace.Class; + +static class C +{ + static int Field; + + static void Method() {} +}", "using-static"); + } + + [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] + [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] + public async Task TestStaticClass() + { + await Test_KeywordAsync( +@"using static namespace.Class; + +sta[||]tic class C +{ + static int Field; + + static void Method() {} +}", "static"); + } + + [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] + [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] + public async Task TestStaticField() + { + await Test_KeywordAsync( +@"using static namespace.Class; + +static class C +{ + sta[||]tic int Field; + + static void Method() {} +}", "static"); + } + + [WorkItem(48392, "https://github.com/dotnet/roslyn/issues/48392")] + [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] + public async Task TestStaticMethod() + { + await Test_KeywordAsync( +@"using static namespace.Class; + +static class C +{ + static int Field; + + sta[||]tic void Method() {} +}", "static"); + } } } - From b12e01fbb22aaeef958a6cb3fe5a17823b11baa9 Mon Sep 17 00:00:00 2001 From: Jon Senchyna Date: Thu, 15 Oct 2020 23:04:42 -0400 Subject: [PATCH 2/3] Add logic for detecting `using static` --- .../CSharp/Impl/LanguageService/CSharpHelpContextService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs index d1b079a8ca594..275d9f809cfb0 100644 --- a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs +++ b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs @@ -324,6 +324,11 @@ private static bool TryGetTextForCombinationKeyword(SyntaxToken token, ISyntaxFa case SyntaxKind.InternalKeyword when ModifiersContains(token, syntaxFacts, SyntaxKind.ProtectedKeyword): text = "protectedinternal_CSharpKeyword"; return true; + + case SyntaxKind.UsingKeyword when token.GetNextToken().IsKind(SyntaxKind.StaticKeyword): + case SyntaxKind.StaticKeyword when token.GetPreviousToken().IsKind(SyntaxKind.UsingKeyword): + text = "usingstatic_CSharpKeyword"; + return true; } text = null; From 856214ea7add137b63b64e4aff99c8519da14466 Mon Sep 17 00:00:00 2001 From: Jon Senchyna Date: Fri, 16 Oct 2020 06:56:33 -0400 Subject: [PATCH 3/3] Add missing keyword change --- .../CSharp/Impl/LanguageService/CSharpHelpContextService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs index 275d9f809cfb0..01ab583ef3fe7 100644 --- a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs +++ b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs @@ -327,7 +327,7 @@ private static bool TryGetTextForCombinationKeyword(SyntaxToken token, ISyntaxFa case SyntaxKind.UsingKeyword when token.GetNextToken().IsKind(SyntaxKind.StaticKeyword): case SyntaxKind.StaticKeyword when token.GetPreviousToken().IsKind(SyntaxKind.UsingKeyword): - text = "usingstatic_CSharpKeyword"; + text = "using-static_CSharpKeyword"; return true; }