Example #1
0
 private static bool IsSumOnInteger(IMethodSymbol methodSymbol)
 {
     return(methodSymbol != null &&
            methodSymbol.Name == "Sum" &&
            methodSymbol.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T) &&
            IsReturnTypeCandidate(methodSymbol));
 }
        private static bool MethodExistsOnIEnumerable(IMethodSymbol methodSymbol, SemanticModel semanticModel)
        {
            if (methodSymbol.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T))
            {
                return(true);
            }

            var enumerableType = semanticModel.Compilation.GetTypeByMetadataName("System.Linq.Enumerable");

            if (enumerableType == null)
            {
                return(false);
            }

            var members = enumerableType.GetMembers(methodSymbol.Name).OfType <IMethodSymbol>();

            return(members.Any(member => ParametersMatch(methodSymbol.OriginalDefinition, member)));
        }
 private static bool IsToCollectionCall(IMethodSymbol methodSymbol)
 {
     return(MethodNamesToCollection.Contains(methodSymbol.Name) &&
            (methodSymbol.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T) ||
             methodSymbol.ContainingType.ConstructedFrom.Is(KnownType.System_Collections_Generic_List_T)));
 }
 private static bool IsToCollectionCall(IMethodSymbol methodSymbol)
 {
     return MethodNamesToCollection.Contains(methodSymbol.Name) &&
         (methodSymbol.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T) ||
         methodSymbol.ContainingType.ConstructedFrom.Is(KnownType.System_Collections_Generic_List_T));
 }
        private static bool MethodExistsOnIEnumerable(IMethodSymbol methodSymbol, SemanticModel semanticModel)
        {
            if (methodSymbol.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T))
            {
                return true;
            }

            var enumerableType = semanticModel.Compilation.GetTypeByMetadataName("System.Linq.Enumerable");
            if (enumerableType == null)
            {
                return false;
            }

            var members = enumerableType.GetMembers(methodSymbol.Name).OfType<IMethodSymbol>();
            return members.Any(member => ParametersMatch(methodSymbol.OriginalDefinition, member));
        }
 private static bool IsLinqMethod(IMethodSymbol methodSymbol)
 {
     return methodSymbol.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T) ||
         methodSymbol.IsExtensionOn(KnownType.System_Collections_IEnumerable);
 }
 private static bool IsSumOnInteger(IMethodSymbol methodSymbol)
 {
     return methodSymbol != null &&
         methodSymbol.Name == "Sum" &&
         methodSymbol.IsExtensionOn(KnownType.System_Collections_Generic_IEnumerable_T) &&
         IsReturnTypeCandidate(methodSymbol);
 }