本文整理汇总了C#中IMethodSymbol.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodSymbol.Equals方法的具体用法?C# IMethodSymbol.Equals怎么用?C# IMethodSymbol.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodSymbol
的用法示例。
在下文中一共展示了IMethodSymbol.Equals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public static void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
{
Debug.Assert(symbol.Equals(symbol.ConstructedFrom));
visitor.WriteSymbolKey(symbol.ReducedFrom);
visitor.WriteSymbolKey(symbol.ReceiverType);
}
示例2: Create
public static void Create(IMethodSymbol symbol, SymbolKeyWriter visitor)
{
Debug.Assert(symbol.Equals(symbol.ConstructedFrom));
visitor.WriteString(symbol.MetadataName);
visitor.WriteSymbolKey(symbol.ContainingSymbol);
visitor.WriteInteger(symbol.Arity);
visitor.WriteBoolean(symbol.PartialDefinitionPart != null);
visitor.WriteRefKindArray(symbol.Parameters);
// Mark that we're writing out the signature of a method. This way if we hit a
// method type parameter in our parameter-list or return type, we won't recurse
// into it, but will instead only write out the type parameter ordinal. This
// happens with cases like Foo<T>(T t);
Debug.Assert(!visitor.WritingSignature);
visitor.WritingSignature = true;
visitor.WriteParameterTypesArray(symbol.OriginalDefinition.Parameters);
if (symbol.MethodKind == MethodKind.Conversion)
{
visitor.WriteSymbolKey(symbol.ReturnType);
}
else
{
visitor.WriteSymbolKey(null);
}
// Done writing the signature. Go back to normal mode.
Debug.Assert(visitor.WritingSignature);
visitor.WritingSignature = false;
}
示例3: HasVisibleAlternate
private static bool HasVisibleAlternate(INamedTypeSymbol namedType, IMethodSymbol interfaceMethod, INamedTypeSymbol iDisposableTypeSymbol)
{
foreach (INamedTypeSymbol type in namedType.GetBaseTypesAndThis())
{
foreach (IMethodSymbol method in type.GetMembers(interfaceMethod.Name).OfType<IMethodSymbol>())
{
if (method.GetResultantVisibility() == SymbolVisibility.Public)
{
return true;
}
}
}
// This rule does not report a violation for an explicit implementation of IDisposable.Dispose when an externally visible Close() or System.IDisposable.Dispose(Boolean) method is provided.
return interfaceMethod.Equals("Dispose") &&
interfaceMethod.ContainingType.Equals(iDisposableTypeSymbol) &&
namedType.GetBaseTypesAndThis().Any(t =>
t.GetMembers("Close").OfType<IMethodSymbol>().Any(m =>
m.GetResultantVisibility() == SymbolVisibility.Public));
}
示例4: IsPrivateAndUsedAsMethodGroup
private static bool IsPrivateAndUsedAsMethodGroup(MethodDeclarationSyntax method, IMethodSymbol methodSymbol, SemanticModel semanticModel)
{
if (methodSymbol.DeclaredAccessibility != Accessibility.Private) return false;
var parentType = method.Parent;
var allTokens = parentType.DescendantTokens();
var tokensThatMatch = from t in allTokens
let text = t.Text
where text == method.Identifier.Text
select t;
foreach (var token in tokensThatMatch)
{
var nodeSymbol = semanticModel.GetSymbolInfo(token.Parent).Symbol;
if (methodSymbol.Equals(nodeSymbol)) return true;
}
return false;
}
示例5: IsMethodCandidate
private static bool IsMethodCandidate(IMethodSymbol methodSymbol)
{
if (methodSymbol.IsAbstract ||
methodSymbol.IsVirtual ||
methodSymbol.IsOverride)
{
return false;
}
return !methodSymbol.ContainingType
.AllInterfaces
.SelectMany(@interface => @interface.GetMembers().OfType<IMethodSymbol>())
.Any(method => methodSymbol.Equals(methodSymbol.ContainingType.FindImplementationForInterfaceMember(method)));
}
示例6: MethodMightImplementDispose
private static bool MethodMightImplementDispose(IMethodSymbol declaredMethodSymbol)
{
var containingType = declaredMethodSymbol.ContainingType;
if (containingType.BaseType != null && containingType.BaseType.Kind == SymbolKind.ErrorType)
{
return true;
}
var interfaces = containingType.AllInterfaces;
foreach (var @interface in interfaces)
{
if (@interface.Kind == SymbolKind.ErrorType)
{
return true;
}
var interfaceMethods = @interface.GetMembers().OfType<IMethodSymbol>();
foreach (var interfaceMethod in interfaceMethods)
{
if (declaredMethodSymbol.Equals(containingType.FindImplementationForInterfaceMember(interfaceMethod)))
{
return true;
}
}
}
return false;
}
示例7: MethodIsDisposeImplementation
private static bool MethodIsDisposeImplementation(IMethodSymbol methodSymbol, IMethodSymbol disposeMethod)
{
return methodSymbol.Equals(methodSymbol.ContainingType.FindImplementationForInterfaceMember(disposeMethod));
}
示例8: IsIEqualityComparerGetHashCodeInterfaceImplementation
private bool IsIEqualityComparerGetHashCodeInterfaceImplementation(IMethodSymbol method, IMethodSymbol iEqualityComparerGetHashCodeInterfaceMethod)
{
if (iEqualityComparerGetHashCodeInterfaceMethod == null)
{
return false;
}
INamedTypeSymbol iEqualityComparerInterfaceType = iEqualityComparerGetHashCodeInterfaceMethod.ContainingType;
foreach (INamedTypeSymbol interfaceType in method.ContainingType.AllInterfaces.Where(
ifaceType => iEqualityComparerInterfaceType.Equals(ifaceType.ConstructedFrom)))
{
foreach (var unboundGenericInterfaceMethod in
interfaceType.GetMembers(iEqualityComparerGetHashCodeInterfaceMethod.Name).OfType<IMethodSymbol>())
{
var implementingMethod = method.ContainingType.FindImplementationForInterfaceMember(unboundGenericInterfaceMethod) as IMethodSymbol;
if (method.Equals(implementingMethod))
{
return true;
}
}
}
return false;
}
示例9: IsMethodUsedAsEventHandlerFunctionOrActionInExpression
private static bool IsMethodUsedAsEventHandlerFunctionOrActionInExpression(IMethodSymbol methodSymbol, ExpressionSyntax expression, SemanticModel semanticModel)
{
return !expression.IsKind(SyntaxKind.InvocationExpression) &&
IsStandaloneExpression(expression) &&
methodSymbol.Equals(semanticModel.GetSymbolInfo(expression).Symbol?.OriginalDefinition);
}
示例10: CheckOverloadsContainUriParameters
private bool CheckOverloadsContainUriParameters(SemanticModel model, IMethodSymbol method, SyntaxNode node, CancellationToken cancellationToken)
{
INamedTypeSymbol uriType = _uri;
foreach (IMethodSymbol overload in model.GetMemberGroup(node, cancellationToken).OfType<IMethodSymbol>())
{
cancellationToken.ThrowIfCancellationRequested();
if (method.Equals(overload))
{
continue;
}
if (overload.Parameters.Any(p => p.Type?.Equals(uriType) == true))
{
return true;
}
}
return false;
}
示例11: IsInterfaceMethodImplementation
private static bool IsInterfaceMethodImplementation(IMethodSymbol method, IMethodSymbol interfaceMethod)
{
return interfaceMethod != null && method.Equals(method.ContainingType.FindImplementationForInterfaceMember(interfaceMethod));
}