Skip to content

Commit a7d874c

Browse files
authored
Merge pull request #2760 from jnm2/fix_isymbol_equality_comparisons
Fixed ISymbol equality comparisons
2 parents a81a66a + 586f7d5 commit a7d874c

7 files changed

Lines changed: 10 additions & 10 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/SolutionReader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private string GetStatus(INamedTypeSymbol classSymbol, SyntaxNode root, Semantic
262262

263263
// We use the fact that the only parameter that returns a boolean is the one we are interested in
264264
var enabledByDefaultParameter = from argument in initializer.ArgumentList.Arguments
265-
where model.GetTypeInfo(argument.Expression).Type == this.booleanType
265+
where Equals(model.GetTypeInfo(argument.Expression).Type, this.booleanType)
266266
select argument.Expression;
267267
var parameter = enabledByDefaultParameter.FirstOrDefault();
268268
string parameterString = parameter.ToString();
@@ -296,7 +296,7 @@ private IEnumerable<DiagnosticDescriptor> GetDescriptor(INamedTypeSymbol classSy
296296

297297
var noCodeFixAttribute = classSymbol
298298
.GetAttributes()
299-
.SingleOrDefault(x => x.AttributeClass == this.noCodeFixAttributeTypeSymbol);
299+
.SingleOrDefault(x => Equals(x.AttributeClass, this.noCodeFixAttributeTypeSymbol));
300300

301301
bool hasCodeFix = noCodeFixAttribute == null;
302302
if (!hasCodeFix)
@@ -356,7 +356,7 @@ private bool InheritsFrom(INamedTypeSymbol declaration, INamedTypeSymbol possibl
356356
{
357357
while (declaration != null)
358358
{
359-
if (declaration == possibleBaseType)
359+
if (declaration.Equals(possibleBaseType))
360360
{
361361
return true;
362362
}

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/StandardTextDiagnosticBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private static bool SeeTagIsCorrect(SyntaxNodeAnalysisContext context, XmlEmptyE
167167
}
168168

169169
INamedTypeSymbol expectedSymbol = semanticModel.GetDeclaredSymbol(constructorDeclarationSyntax.Parent, context.CancellationToken) as INamedTypeSymbol;
170-
return actualSymbol.OriginalDefinition == expectedSymbol;
170+
return Equals(actualSymbol.OriginalDefinition, expectedSymbol);
171171
}
172172

173173
private static bool SeeTagIsCorrect(SyntaxNodeAnalysisContext context, XElement classReferencePart, BaseMethodDeclarationSyntax constructorDeclarationSyntax)
@@ -193,7 +193,7 @@ private static bool SeeTagIsCorrect(SyntaxNodeAnalysisContext context, XElement
193193
}
194194

195195
INamedTypeSymbol expectedSymbol = semanticModel.GetDeclaredSymbol(constructorDeclarationSyntax.Parent, context.CancellationToken) as INamedTypeSymbol;
196-
return actualSymbol.OriginalDefinition == expectedSymbol;
196+
return Equals(actualSymbol.OriginalDefinition, expectedSymbol);
197197
}
198198

199199
private static bool TextPartsMatch(string firstText, string secondText, XmlTextSyntax firstTextPart, XmlTextSyntax secondTextPart)

StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1404CodeAnalysisSuppressionMustHaveJustification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void HandleAttributeNode(SyntaxNodeAnalysisContext context)
118118
this.suppressMessageAttribute = context.SemanticModel.Compilation.GetTypeByMetadataName(typeof(SuppressMessageAttribute).FullName);
119119
}
120120

121-
if (symbol.ContainingType == this.suppressMessageAttribute)
121+
if (Equals(symbol.ContainingType, this.suppressMessageAttribute))
122122
{
123123
foreach (var attributeArgument in attribute.ArgumentList.Arguments)
124124
{

StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SystemDiagnosticsDebugDiagnosticBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected internal static void HandleInvocationExpression(SyntaxNodeAnalysisCont
3434
{
3535
var debugType = context.SemanticModel.Compilation.GetTypeByMetadataName(typeof(Debug).FullName);
3636

37-
if (symbolInfo.ContainingType == debugType
37+
if (Equals(symbolInfo.ContainingType, debugType)
3838
&& symbolInfo.Name == methodName)
3939
{
4040
if ((invocationExpressionSyntax.ArgumentList?.Arguments.Count ?? 0) <= parameterIndex)

StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1313ParameterNamesMustBeginWithLowerCaseLetter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private static bool NameMatchesAbstraction(ParameterSyntax syntax, SemanticModel
146146
{
147147
foreach (var member in implementedInterface.GetMembers(methodSymbol.Name).OfType<IMethodSymbol>())
148148
{
149-
if (containingType.FindImplementationForInterfaceMember(member) == methodSymbol)
149+
if (methodSymbol.Equals(containingType.FindImplementationForInterfaceMember(member)))
150150
{
151151
return member.Parameters[index].Name == syntax.Identifier.ValueText;
152152
}

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private static void HandleBaseExpression(SyntaxNodeAnalysisContext context)
112112
}
113113

114114
var speculativeSymbol = context.SemanticModel.GetSpeculativeSymbolInfo(parent.SpanStart, speculativeExpression, SpeculativeBindingOption.BindAsExpression);
115-
if (speculativeSymbol.Symbol != targetSymbol.Symbol)
115+
if (!targetSymbol.Symbol.Equals(speculativeSymbol.Symbol))
116116
{
117117
return;
118118
}

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1130UseLambdaSyntax.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private static bool HandleMethodInvocation(SemanticModel semanticModel, Anonymou
117117
var invocationExpression = originalInvocationExpression.ReplaceNode(anonymousMethod, lambdaExpression);
118118
SymbolInfo newSymbolInfo = semanticModel.GetSpeculativeSymbolInfo(location.SourceSpan.Start, invocationExpression, SpeculativeBindingOption.BindAsExpression);
119119

120-
if (originalSymbolInfo.Symbol != newSymbolInfo.Symbol)
120+
if (!originalSymbolInfo.Symbol.Equals(newSymbolInfo.Symbol))
121121
{
122122
return false;
123123
}

0 commit comments

Comments
 (0)