Skip to content

Fix RS1024: Do not report on overloads not comparing symbols#4477

Merged
ryzngard merged 6 commits intodotnet:masterfrom
Evangelink:RS1024-result-lambda
Feb 19, 2021
Merged

Fix RS1024: Do not report on overloads not comparing symbols#4477
ryzngard merged 6 commits intodotnet:masterfrom
Evangelink:RS1024-result-lambda

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Fix #4413

@Evangelink Evangelink requested a review from a team as a code owner December 1, 2020 13:45
Comment on lines +195 to +197
var destinationTypeIndex = method.TypeParameters
.Select((type, index) => type.Name == "TKey" ? index : -1)
.FirstOrDefault(x => x >= 0);
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.

/!\ This is a bit hacky. /!\

I am not sure whether we can safely rely on a generic type parameter name.

As far as I can tell, the non-hacky solution forces us to resolves all overloads, and map them with the index we should look at.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'll let @ryzngard review/approve this change.

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.

Ping @ryzngard

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looking, sorry for delay

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agree this does seem hacky, but maybe no more hacky than depending on ordering. At the end of the day we're at least working on a known set of functions that we don't expect to change drastically, so if it works for the known set maybe it's good enough.

I was looking at the test you wrote without the change, and a surprising piece for me: the type arguments are not in the order I would expect.

Method display is showing ILookup<string, IFieldSymbol> but type arguments are { IFieldSymbol, string }. Going to try and find documentation to see if that's expected.

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.

I can but this will add some complexity to the current solution. Let me know what's your preference.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tagging @ryzngard for last question

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.

Ping @ryzngard

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.

Ping @ryzngard

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks fine for now

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 1, 2020

Codecov Report

Merging #4477 (25e0611) into master (f167914) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #4477   +/-   ##
=======================================
  Coverage   95.67%   95.68%           
=======================================
  Files        1193     1193           
  Lines      271525   271559   +34     
  Branches    16413    16415    +2     
=======================================
+ Hits       259789   259839   +50     
  Misses       9620     9620           
+ Partials     2116     2100   -16     

Evangelink and others added 2 commits December 1, 2020 15:46
…eSymbolsCorrectlyAnalyzer.cs

Co-authored-by: Manish Vasani <mavasani@microsoft.com>
# Conflicts:
#	src/Microsoft.CodeAnalysis.Analyzers/Core/MetaAnalyzers/CompareSymbolsCorrectlyAnalyzer.cs
#	src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/CompareSymbolsCorrectlyTests.cs
# Conflicts:
#	src/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/CompareSymbolsCorrectlyTests.cs
@ryzngard ryzngard merged commit fe97c6c into dotnet:master Feb 19, 2021
@Evangelink Evangelink deleted the RS1024-result-lambda branch February 19, 2021 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive for RS1024 (Compare symbols correctly) when not comparing symbols

5 participants