Fix FAR for less than operator and add tests for all operators#52656
Fix FAR for less than operator and add tests for all operators#52656CyrusNajmabadi merged 5 commits intodotnet:mainfrom
Conversation
|
|
||
| var syntaxFacts = document.GetLanguageService<ISyntaxFactsService>(); | ||
| if (syntaxFacts.IsOperator(token) || syntaxFacts.IsPredefinedOperator(token) || SyntaxFacts.IsAssignmentExpressionOperatorToken(token.Kind())) | ||
| if (syntaxFacts.IsOperator(token) || SyntaxFacts.IsAssignmentExpressionOperatorToken(token.Kind())) |
There was a problem hiding this comment.
"IsPredefinedOperator" only checks the token kind regardless its context. This caused < of type argument list (e.g, in List<int>) to be classified as less than.
The check of "IsOperator" should handle everything with respect to the token context. I also think IsAssignmentExpressionOperatorToken should be removed, but will leave that for now because a test will fail, and F1 isn't the main change intended with this PR.
There was a problem hiding this comment.
I wouldn't touch this function at all in this pr. It seems to be fixing two unrelated issues.
There was a problem hiding this comment.
@CyrusNajmabadi I had to touch it to fix test failure:
roslyn/src/VisualStudio/CSharp/Test/F1Help/F1HelpTests.cs
Lines 442 to 453 in 85aa538
There was a problem hiding this comment.
the change feels dangerous. i'm ont sure what unintended consequences tehre would be by removing this case here. Instead of removing htis, could we instead have the C# f1 helper check if this a < in a generic name and not in a regular expression?
There was a problem hiding this comment.
That way I'll have to special case multiple things:
- TypeArgumentListSyntax (This one is enough to make tests pass - but below will still have bugs)
- TypeParameterListSyntax
- FunctionPointerParameterListSyntax
- XmlElementStartTagSyntax
- OperatorMemberCref
- XmlEmptyElementSyntax
This doesn't look neat IMO.
Either way, F1 help service isn't accurate and has bugs.
Does adding more tests to cover all operators that are in the deleted checks make the change more comfortable?
There was a problem hiding this comment.
or just say that < is only an operator here if it's parent is a binaryexpression
src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs
Outdated
Show resolved
Hide resolved
…Service.cs Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
Head branch was pushed to by a user without write access
src/VisualStudio/CSharp/Impl/LanguageService/CSharpHelpContextService.cs
Outdated
Show resolved
Hide resolved
|
@CyrusNajmabadi This should be ready to merge. |
|
Thanks! |
Fixes #52654
Closes #39177 (this was already partially working (the
>part) - and this PR fixed the<)