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

Fix F1 keywords clashing for !_CSharpKeyword #47516

Merged
6 commits merged into from
Sep 11, 2020
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 @@ -206,6 +206,13 @@ private bool TryGetTextForSymbol(SyntaxToken token, SemanticModel semanticModel,

private static bool TryGetTextForOperator(SyntaxToken token, Document document, out string text)
{
if (token.IsKind(SyntaxKind.ExclamationToken) &&
token.Parent.IsKind(SyntaxKind.SuppressNullableWarningExpression))
{
text = Keyword("nullForgiving");
return true;
}
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved

var syntaxFacts = document.GetLanguageService<ISyntaxFactsService>();
if (syntaxFacts.IsOperator(token) || syntaxFacts.IsPredefinedOperator(token) || SyntaxFacts.IsAssignmentExpressionOperatorToken(token.Kind()))
{
Expand Down
29 changes: 29 additions & 0 deletions src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,5 +746,34 @@ void goo()
}
}", "nameof");
}

[WorkItem(46988, "https://github.com/dotnet/roslyn/issues/46988")]
[Fact, Trait(Traits.Feature, Traits.Features.F1Help)]
public async Task TestNullForgiving()
{
await Test_KeywordAsync(
@"#nullable enable
class C
{
int goo(string? x)
{
return x[||]!.GetHashCode();
}
}", "nullForgiving");
}

[WorkItem(46988, "https://github.com/dotnet/roslyn/issues/46988")]
[Fact, Trait(Traits.Feature, Traits.Features.F1Help)]
public async Task TestLogicalNot()
{
await Test_KeywordAsync(
@"class C
{
bool goo(bool x)
{
return [||]!x;
}
}", "!");
}
}
}