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 'Compare symbols correctly' false positive with custom comparers #5807

Merged
merged 6 commits into from
Jan 31, 2022

Conversation

Youssef1313
Copy link
Member

Fixes #5715

@Youssef1313
Copy link
Member Author

@Evangelink In case you want to review

@codecov
Copy link

codecov bot commented Jan 23, 2022

Codecov Report

Merging #5807 (a70ef8e) into main (f471d33) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff            @@
##             main    #5807    +/-   ##
========================================
  Coverage   95.58%   95.58%            
========================================
  Files        1284     1284            
  Lines      296834   296980   +146     
  Branches    18101    18105     +4     
========================================
+ Hits       283725   283868   +143     
- Misses      10670    10674     +4     
+ Partials     2439     2438     -1     

@@ -1248,9 +1248,156 @@ public int GetHashCode(object o1, object o2)
}.RunAsync();
}

[Fact]
Copy link
Member

Choose a reason for hiding this comment

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

Could you add the various vbnet parts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will fix, probably in few days :(

Feel free to re-ping me if I forgot.

{
public void M(IEnumerable<ITypeSymbol> symbols)
{
_ = symbols.ToDictionary(s => s, s => s.ToDisplayString(), SymbolNameComparer.Instance);
Copy link
Member

Choose a reason for hiding this comment

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

I would move this line (and the method arg) to the 1st test. We could even consider copying all the methods declared in the test CollectionMethodsKnownToRequireComparer_DiagnosticAsync.

@@ -1248,9 +1248,156 @@ public int GetHashCode(object o1, object o2)
}.RunAsync();
}

[Fact]
public async Task RS1024_CustomComparer()
Copy link
Member

Choose a reason for hiding this comment

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

I don't know when this was done but it seems that all tests were renamed to follow the Async suffix pattern, could you please update your tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

That looks weird. We shouldn't follow Async suffix for tests.

Copy link
Member

Choose a reason for hiding this comment

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

I agree, don't know why it was done.

{
public void M(IEnumerable<ITypeSymbol> symbols)
{
_ = symbols.ToDictionary(s => s, s => s.ToDisplayString(), SymbolNameComparer.Instance);
Copy link
Member

Choose a reason for hiding this comment

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

Same remark about moving this to test 2 this time.

@mavasani
Copy link
Member

@Youssef1313 @Evangelink - do we need any more iterations on this PR?

@Evangelink
Copy link
Member

@mavasani I think that's ok.

@mavasani mavasani merged commit 3405da8 into dotnet:main Jan 31, 2022
@github-actions github-actions bot added this to the vNext milestone Jan 31, 2022
@Youssef1313 Youssef1313 deleted the compare-symbols-correctly-fp branch January 31, 2022 09:28
@jmarolf jmarolf modified the milestones: vNext, .NET 7.x Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive for RS1024 when using ToDictionary(...)
4 participants