diff --git a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs index f7145b65007bb2283336b3876af6c39960d0192d..eb8e8051d06ac0dd13846c1a288912ce4c998871 100644 --- a/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs +++ b/src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs @@ -244,6 +244,12 @@ private bool TryGetTextForPreProcessor(SyntaxToken token, ISyntaxFactsService sy private bool TryGetTextForContextualKeyword(SyntaxToken token, out string text) { + if (token.Text == "nameof") + { + text = Keyword("nameof"); + return true; + } + if (token.IsContextualKeyword()) { switch (token.Kind()) diff --git a/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs b/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs index a4e5f586bc07e34e0e021dcc48bd2ccc6b637955..76766893c189fda4d20279736078457f8617e64f 100644 --- a/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs +++ b/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs @@ -562,5 +562,19 @@ static void Main(string[] args) } }", "System.String"); } + + [WorkItem(36001, "https://github.com/dotnet/roslyn/issues/36001")] + [Fact, Trait(Traits.Feature, Traits.Features.F1Help)] + public async Task TestNameof() + { + await Test_KeywordAsync( +@"class C +{ + void goo() + { + var v = [||]nameof(goo); + } +}", "nameof"); + } } }