Skip to content

Fix F1 keyword for interpolated and verbatim strings#46987

Merged
CyrusNajmabadi merged 12 commits intodotnet:masterfrom
Youssef1313:patch-9
Aug 27, 2020
Merged

Fix F1 keyword for interpolated and verbatim strings#46987
CyrusNajmabadi merged 12 commits intodotnet:masterfrom
Youssef1313:patch-9

Conversation

@Youssef1313
Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 commented Aug 20, 2020

Fixes #46986

$_CSharpKeyword: This article is what have this f1 keyword.

@_CSharpKeyword: This article is what have this f1 keyword.

I removed the following part:

            if (token.IsKind(SyntaxKind.PlusEqualsToken))
            {
                text = "+=_CSharpKeyword";
                return true;
            }

            if (token.IsKind(SyntaxKind.MinusEqualsToken))
            {
                text = "-=_CSharpKeyword";
                return true;
            }

These if conditions are impossible to be met because of the check SyntaxFacts.IsAssignmentExpressionOperatorToken before them. SyntaxFacts.IsAssignmentExpressionOperatorToken will already return true for MinusEqualsToken and PlusEqualsTokene.

It even seem that SyntaxFacts.IsAssignmentExpressionOperatorToken is also redundant, this check is already done in IsOperator. (This was incorrect, I'll revert it)

Comment on lines +189 to +201
if (token.IsKind(SyntaxKind.InterpolatedStringStartToken) ||
token.IsKind(SyntaxKind.InterpolatedStringEndToken) ||
token.IsKind(SyntaxKind.InterpolatedStringTextToken))
{
text = "$_CSharpKeyword";
return true;
}

if (token.IsKind(SyntaxKind.StringLiteralToken) && token.ValueText[0] == '@')
{
text = "@_CSharpKeyword";
return true;
}
Copy link
Copy Markdown
Member Author

@Youssef1313 Youssef1313 Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the dotnet/docs doesn't have any @$_CSharpKeyword F1 keyword. I opened a PR (dotnet/docs#20197) to add this in docs. Are you okay with this new F1 keyword and adding the following here?

        if (token.IsKind(SyntaxKind.InterpolatedVerbatimStringStartToken))
        {
            text = "@$_CSharpKeyword";
            return true;
        }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidwengier Should I add the combination?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like that would regress the experience from a help page (albeit for string, which isn't great) to a generic 404 page, so I'd say leave it until after the doc page is created.

Copy link
Copy Markdown
Member Author

@Youssef1313 Youssef1313 Aug 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidwengier I've a PR there
dotnet/docs#20197, so if you agree for the combination@$, we can wait for this PR until the docs one is merged.

@Youssef1313 Youssef1313 marked this pull request as ready for review August 20, 2020 08:19
@Youssef1313 Youssef1313 requested a review from a team as a code owner August 20, 2020 08:19
@Youssef1313
Copy link
Copy Markdown
Member Author

        [WorkItem(867572, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/867572")]
        [Fact, Trait(Traits.Feature, Traits.Features.F1Help)]
        public async Task TestSubscription()
        {
            await TestAsync(
@"class CCC
{
    event System.Action e;
    void M()
    {
        e +[||]= () => {
        };
    }
}", "CCC.e.add");
        }

This test failed unintentionally with my changes. But actually the new behavior is what makes sense. The result should be +=_CSharpKeyword instead of CCC.e.add.

token.IsKind(SyntaxKind.InterpolatedStringTextToken))
{
text = "::_CSharpKeyword";
text = "$_CSharpKeyword";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you provide the links these now go to.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and is that where $_CSharpKeyword does redirect to? Can you give me the links these produce directly, so i can validate they end up landing on an appropriate page? Thanks!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That link takes me to https://docs.microsoft.com/en-us/.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, adding @davidwengier as he touched this area before (dotnet/docs#19700 (comment))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually redirects to "/Areas/Epx/Content/500.aspx?aspxerrorpath=/query/dev16.query" first, which in turn redirected to the home docs.
So, it's an internal server error.

Copy link
Copy Markdown
Member

@davidwengier davidwengier Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query service seems to be pretty flaky at the moment, not sure what the deal is with that. The link above (msdn.microsoft.com/query/dev16.query?appId=Dev16IDEF1&l=EN-US&k=k($_CSharpKeyword);k(DevLang-csharp)&rd=true) worked for me, and looks how I would expect.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this link still doesn't seem to work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CyrusNajmabadi Currently it's working with me. The service was down yesterday but is working now, maybe there is some caching issues?

@jinujoseph jinujoseph added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Aug 20, 2020
Copy link
Copy Markdown
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signing off as far as the help links go, I don't see any issues introduced here. The => issue I mentioned looks like it is pre-existing so no reason to block this PR, but it would be nice to fix if you're in the mood :)

token.IsKind(SyntaxKind.InterpolatedStringTextToken))
{
text = "::_CSharpKeyword";
text = "$_CSharpKeyword";
Copy link
Copy Markdown
Member

@davidwengier davidwengier Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query service seems to be pretty flaky at the moment, not sure what the deal is with that. The link above (msdn.microsoft.com/query/dev16.query?appId=Dev16IDEF1&l=EN-US&k=k($_CSharpKeyword);k(DevLang-csharp)&rd=true) worked for me, and looks how I would expect.

@Youssef1313
Copy link
Copy Markdown
Member Author

This is ready for review again after applying suggestions from @davidwengier.

@Youssef1313 Youssef1313 reopened this Aug 21, 2020
@Youssef1313 Youssef1313 marked this pull request as draft August 21, 2020 15:34
@Youssef1313 Youssef1313 marked this pull request as ready for review August 21, 2020 15:34
@Youssef1313 Youssef1313 marked this pull request as draft August 22, 2020 14:24
@Youssef1313 Youssef1313 marked this pull request as ready for review August 22, 2020 14:24
@Youssef1313
Copy link
Copy Markdown
Member Author

Pinging @davidwengier
Could you approve the docs PR?
Then, this should be ready to go.

@davidwengier
Copy link
Copy Markdown
Member

I think its really up to the docs team to approve that PR, if they're happy with where that keyword goes, or if they think it should go to one of the specific operator pages, or indeed a new page.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

The link still isn't working for me :-/

@Youssef1313
Copy link
Copy Markdown
Member Author

@CyrusNajmabadi What if you press F1 anything inside Visual Studio? (await keyword for example) Does it work?

@Youssef1313
Copy link
Copy Markdown
Member Author

@davidwengier The PR that adds @$_CSharpKeyword is now merged.

Copy link
Copy Markdown
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Youssef1313
Copy link
Copy Markdown
Member Author

@davidwengier Anything left to merge this?

@davidwengier
Copy link
Copy Markdown
Member

@CyrusNajmabadi are you okay with this?

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Yup. Thanks!

@CyrusNajmabadi CyrusNajmabadi merged commit f3ea6a2 into dotnet:master Aug 27, 2020
@ghost ghost added this to the Next milestone Aug 27, 2020
@Youssef1313 Youssef1313 deleted the patch-9 branch August 28, 2020 06:23
@allisonchou allisonchou modified the milestones: Next, 16.8.P3 Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F1 Help service doesn't detect interpolated or verbatim string tokens

5 participants