Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update F1 keywords to detect using static combination #48660

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "using-static_CSharpKeyword";
return true;
}

text = null;
Expand Down
91 changes: 90 additions & 1 deletion src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,95 @@ await Test_KeywordAsync(
delegate T MyDelegate<T>() 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");
}
}
}