未验证 提交 5a099726 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #35470 from sharwell/rs1024-ms-ca-ws

Fix violations of RS1024 in Microsoft.CodeAnalysis.Workspaces
......@@ -72,7 +72,7 @@ internal static partial class DeclarationFinder
var symbolsWithName = symbols.SelectAsArray(s => new SymbolAndProjectId(s, project.Id));
if (startingCompilation != null && startingAssembly != null && compilation.Assembly != startingAssembly)
if (startingCompilation != null && startingAssembly != null && !Equals(compilation.Assembly, startingAssembly))
{
// Return symbols from skeleton assembly in this case so that symbols have
// the same language as startingCompilation.
......
......@@ -571,7 +571,7 @@ public static async Task<IEnumerable<SymbolCallerInfo>> FindCallersAsync(ISymbol
// Resolve forwarded type and verify that the types from different assembly are indeed equivalent.
var forwardedType = referencedAssembly.ResolveForwardedType(fullyQualifiedTypeName);
if (forwardedType == expectedForwardedType)
if (Equals(forwardedType, expectedForwardedType))
{
verifiedKeys.Add(kvp.Key);
verifiedCount++;
......
......@@ -40,7 +40,7 @@ public static SymbolUsageResult Run(IOperation rootOperation, ISymbol owningSymb
BasicBlockAnalysisData AnalyzeLocalFunction(IMethodSymbol localFunction)
{
var localFunctionOperation = rootOperation.Descendants()
.FirstOrDefault(o => (o as ILocalFunctionOperation)?.Symbol == localFunction);
.FirstOrDefault(o => Equals((o as ILocalFunctionOperation)?.Symbol, localFunction));
// Can likely be null for broken code.
if (localFunctionOperation != null)
......
......@@ -59,7 +59,7 @@ public bool IsInitialParameterValueUsed(IParameterSymbol parameter)
{
// 'write' operation is 'null' for the initial write of the parameter,
// which may be from the caller's argument or parameter initializer.
if (kvp.Key.write == null && kvp.Key.symbol == parameter)
if (kvp.Key.write == null && Equals(kvp.Key.symbol, parameter))
{
return kvp.Value;
}
......@@ -76,7 +76,7 @@ public int GetSymbolWriteCount(ISymbol symbol)
int count = 0;
foreach (var kvp in SymbolWritesMap)
{
if (kvp.Key.symbol == symbol)
if (Equals(kvp.Key.symbol, symbol))
{
count++;
}
......
......@@ -544,7 +544,7 @@ private async Task DebugVerifyNoErrorsAsync(ConflictResolution conflictResolutio
if (conflictAnnotation.RenameDeclarationLocationReferences[symbolIndex].IsOverriddenFromMetadata)
{
var overridingSymbol = await SymbolFinder.FindSymbolAtPositionAsync(solution.GetDocument(newLocation.SourceTree), newLocation.SourceSpan.Start, cancellationToken: _cancellationToken).ConfigureAwait(false);
if (overridingSymbol != null && renamedSymbolInNewSolution != overridingSymbol)
if (overridingSymbol != null && !Equals(renamedSymbolInNewSolution, overridingSymbol))
{
if (!overridingSymbol.IsOverride)
{
......
......@@ -58,8 +58,8 @@ public static ImmutableArray<Location> GetMembersWithConflictingSignatures(IProp
{
var conflictingMethod = conflictingSymbol as IMethodSymbol;
var renamedMethod = renamedMember as IMethodSymbol;
if (!(conflictingMethod.PartialDefinitionPart != null && conflictingMethod.PartialDefinitionPart == renamedMethod) &&
!(conflictingMethod.PartialImplementationPart != null && conflictingMethod.PartialImplementationPart == renamedMethod))
if (!(conflictingMethod.PartialDefinitionPart != null && Equals(conflictingMethod.PartialDefinitionPart, renamedMethod)) &&
!(conflictingMethod.PartialImplementationPart != null && Equals(conflictingMethod.PartialImplementationPart, renamedMethod)))
{
builder.AddRange(conflictingSymbol.Locations);
}
......
......@@ -61,12 +61,12 @@ public static ImmutableArray<IMethodSymbol> GetAllMethodSymbolsOfPartialParts(th
{
if (method.PartialDefinitionPart != null)
{
Debug.Assert(method.PartialImplementationPart == null && method.PartialDefinitionPart != method);
Debug.Assert(method.PartialImplementationPart == null && !Equals(method.PartialDefinitionPart, method));
return ImmutableArray.Create(method, method.PartialDefinitionPart);
}
else if (method.PartialImplementationPart != null)
{
Debug.Assert(method.PartialImplementationPart != method);
Debug.Assert(!Equals(method.PartialImplementationPart, method));
return ImmutableArray.Create(method.PartialImplementationPart, method);
}
else
......
......@@ -242,7 +242,7 @@ private static bool IsImplementable(ISymbol m)
(t, m) =>
{
var implementation = classOrStructType.FindImplementationForInterfaceMember(m);
return implementation != null && implementation.ContainingType == classOrStructType;
return implementation != null && Equals(implementation.ContainingType, classOrStructType);
},
GetMembers,
allowReimplementation: true,
......@@ -261,7 +261,7 @@ private static bool IsImplementable(ISymbol m)
(t, m) =>
{
var implementation = classOrStructType.FindImplementationForInterfaceMember(m);
return implementation != null && implementation.ContainingType == classOrStructType;
return implementation != null && Equals(implementation.ContainingType, classOrStructType);
},
interfaceMemberGetter,
allowReimplementation: true,
......
......@@ -177,7 +177,7 @@ public static int CompareTo(this INamespaceSymbol n1, INamespaceSymbol n2)
{
// Assume that any namespace in our own assembly is accessible to us. This saves a
// lot of cpu time checking namespaces.
if (constituent.ContainingAssembly == assembly)
if (Equals(constituent.ContainingAssembly, assembly))
{
return true;
}
......
......@@ -714,7 +714,7 @@ public static bool IsInaccessibleLocal(this ISymbol symbol, int position)
hideModuleNameAttribute = hideModuleNameAttribute ?? compilation.HideModuleNameAttribute();
foreach (var attribute in attributes)
{
if (attribute.AttributeClass == hideModuleNameAttribute)
if (Equals(attribute.AttributeClass, hideModuleNameAttribute))
{
return true;
}
......@@ -734,7 +734,7 @@ public static bool IsInaccessibleLocal(this ISymbol symbol, int position)
foreach (var attribute in attributes)
{
if (attribute.AttributeConstructor == constructor &&
if (Equals(attribute.AttributeConstructor, constructor) &&
attribute.ConstructorArguments.Length == 1 &&
attribute.ConstructorArguments.First().Value is int)
{
......@@ -794,7 +794,7 @@ public static bool IsInaccessibleLocal(this ISymbol symbol, int position)
{
foreach (var constructor in attributeConstructors)
{
if (attribute.AttributeConstructor == constructor)
if (Equals(attribute.AttributeConstructor, constructor))
{
var actualFlags = 0;
......
......@@ -52,7 +52,7 @@ public override ITypeSymbol VisitTypeParameter(ITypeParameterSymbol symbol)
public override ITypeSymbol VisitNamedType(INamedTypeSymbol symbol)
{
var mapped = VisitType(symbol);
if (mapped != symbol)
if (!Equals(mapped, symbol))
{
return mapped;
}
......@@ -75,7 +75,7 @@ public override ITypeSymbol VisitNamedType(INamedTypeSymbol symbol)
: symbol.ContainingType.Accept(this);
// If our containing type changed, then find us again in the new containing type.
if (updatedContainingType != symbol.ContainingType)
if (!Equals(updatedContainingType, symbol.ContainingType))
{
symbol = updatedContainingType.GetTypeMembers(symbol.Name, symbol.Arity).First(m => m.TypeKind == symbol.TypeKind);
}
......@@ -92,7 +92,7 @@ public override ITypeSymbol VisitNamedType(INamedTypeSymbol symbol)
public override ITypeSymbol VisitArrayType(IArrayTypeSymbol symbol)
{
var mapped = VisitType(symbol);
if (mapped != symbol)
if (!Equals(mapped, symbol))
{
return mapped;
}
......@@ -109,7 +109,7 @@ public override ITypeSymbol VisitArrayType(IArrayTypeSymbol symbol)
public override ITypeSymbol VisitPointerType(IPointerTypeSymbol symbol)
{
var mapped = VisitType(symbol);
if (mapped != symbol)
if (!Equals(mapped, symbol))
{
return mapped;
}
......
......@@ -27,7 +27,7 @@ public static IMethodSymbol GetSpecialEditorBrowsableAttributeConstructor(Compil
}
var candidateConstructors = editorBrowsableAttributeType.Constructors
.Where(c => c.Parameters.Length == 1 && c.Parameters[0].Type == editorBrowsableStateType);
.Where(c => c.Parameters.Length == 1 && Equals(c.Parameters[0].Type, editorBrowsableStateType));
// Ensure the constructor adheres to the expected EditorBrowsable pattern
candidateConstructors = candidateConstructors.Where(c => (!c.IsVararg &&
......@@ -93,7 +93,7 @@ public static List<IMethodSymbol> GetSpecialTypeLibVarAttributeConstructors(Comp
var candidateConstructors = typeLibAttributeType.Constructors
.Where(c => c.Parameters.Length == 1 &&
(c.Parameters[0].Type == typeLibFlagsType || c.Parameters[0].Type == shortType));
(Equals(c.Parameters[0].Type, typeLibFlagsType) || Equals(c.Parameters[0].Type, shortType)));
candidateConstructors = candidateConstructors.Where(c => (!c.IsVararg &&
!c.Parameters[0].IsRefOrOut() &&
......
......@@ -894,7 +894,7 @@ private static bool IsEffectivelySealedClass(ITypeSymbol type)
// A private class with no nested or sibling classes is effectively sealed.
if (namedType.DeclaredAccessibility == Accessibility.Private &&
namedType.ContainingType != null &&
!namedType.ContainingType.GetTypeMembers().Any(nestedType => nestedType.TypeKind == TypeKind.Class && namedType != nestedType))
!namedType.ContainingType.GetTypeMembers().Any(nestedType => nestedType.TypeKind == TypeKind.Class && !Equals(namedType, nestedType)))
{
return true;
}
......
......@@ -400,7 +400,7 @@ public ProjectState GetProjectState(IAssemblySymbol assemblySymbol, Cancellation
if (this.TryGetCompilation(state.Id, out var compilation))
{
// if the symbol is the compilation's assembly symbol, we are done
if (compilation.Assembly == assemblySymbol)
if (Equals(compilation.Assembly, assemblySymbol))
{
return state;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册