Skip to content

Enable RS1024 (Compare symbols correctly) #4799

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

Merged
merged 1 commit into from
Feb 13, 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
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ dotnet_diagnostic.VSTHRD103.severity = none
# VSTHRD200: Use "Async" suffix for async methods
dotnet_diagnostic.VSTHRD200.severity = none

# RS1024: Compare symbols correctly
dotnet_diagnostic.RS1024.severity = none

# RS1025: Configure generated code analysis
dotnet_diagnostic.RS1025.severity = none

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void AnalyzeCore(SemanticModelAnalysisContext context, string attributeN
if (symbol == null)
continue;
var symbolAssembly = symbol.ContainingAssembly;
if (symbolAssembly == myAssembly)
if (Equals(symbolAssembly, myAssembly))
continue;
switch (symbol.DeclaredAccessibility)
{
Expand All @@ -92,12 +92,12 @@ private void AnalyzeCore(SemanticModelAnalysisContext context, string attributeN
// It's the first of seeing the assembly containing symbol. A key-value pair is added into assemblyHasAttrMap to
// indicate if that assembly includes an attribute WantsToBeBestFriends. If an assembly has WantsToBeBestFriends then
// its associated value would be true.
assemblyWantsBestFriends = symbolAssembly.GetAttributes().Any(a => a.AttributeClass == wantsToBeBestFriendsAttributeType);
assemblyWantsBestFriends = symbolAssembly.GetAttributes().Any(a => Equals(a.AttributeClass, wantsToBeBestFriendsAttributeType));
assemblyHasAttrMap[symbolAssembly] = assemblyWantsBestFriends;
}
if (!assemblyWantsBestFriends)
continue;
if (symbol.GetAttributes().Any(a => a.AttributeClass == bestFriendAttributeType))
if (symbol.GetAttributes().Any(a => Equals(a.AttributeClass, bestFriendAttributeType)))
{
// You're not just a friend, you're my best friend!
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void AnalyzeCore(SymbolAnalysisContext context, INamedTypeSymbol attribu
if (context.Symbol.DeclaredAccessibility != Accessibility.Public)
return;

var attribute = context.Symbol.GetAttributes().FirstOrDefault(a => a.AttributeClass == attributeType);
var attribute = context.Symbol.GetAttributes().FirstOrDefault(a => Equals(a.AttributeClass, attributeType));
if (attribute == null)
return;

Expand Down