当前位置: 首页>>代码示例>>C#>>正文


C# IMethodSymbol.Equals方法代码示例

本文整理汇总了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);
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:SymbolKey.MethodSymbolKey.cs

示例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;
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:32,代码来源:SymbolKey.MethodSymbolKey.cs

示例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));
        }
开发者ID:Anniepoh,项目名称:roslyn-analyzers,代码行数:20,代码来源:InterfaceMethodsShouldBeCallableByChildTypes.cs

示例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;
 }
开发者ID:mrhmouse,项目名称:code-cracker,代码行数:16,代码来源:UnusedParametersAnalyzer.cs

示例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)));
        }
开发者ID:andwi,项目名称:sonarlint-vs,代码行数:14,代码来源:MethodParameterUnused.cs

示例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;
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:28,代码来源:DisposeNotImplementingDispose.cs

示例7: MethodIsDisposeImplementation

 private static bool MethodIsDisposeImplementation(IMethodSymbol methodSymbol, IMethodSymbol disposeMethod)
 {
     return methodSymbol.Equals(methodSymbol.ContainingType.FindImplementationForInterfaceMember(disposeMethod));
 }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:4,代码来源:DisposeNotImplementingDispose.cs

示例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;
        }
开发者ID:bkoelman,项目名称:roslyn-analyzers,代码行数:25,代码来源:IdentifiersShouldNotContainTypeNames.cs

示例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);
 }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:6,代码来源:MethodParameterUnused.cs

示例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;
            }
开发者ID:vweijsters,项目名称:roslyn-analyzers,代码行数:20,代码来源:PassSystemUriObjectsInsteadOfStrings.cs

示例11: IsInterfaceMethodImplementation

 private static bool IsInterfaceMethodImplementation(IMethodSymbol method, IMethodSymbol interfaceMethod)
 {
     return interfaceMethod != null && method.Equals(method.ContainingType.FindImplementationForInterfaceMember(interfaceMethod));
 }
开发者ID:hanin,项目名称:roslyn-analyzers,代码行数:4,代码来源:IMethodSymbolExtensions.cs


注:本文中的IMethodSymbol.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。