Example #1
0
 public static bool IsObjectToString(this IMethodSymbol methodSymbol) =>
 methodSymbol != null &&
 methodSymbol.MethodKind == MethodKind.Ordinary &&
 methodSymbol.Name == nameof(object.ToString) &&
 (methodSymbol.IsOverride || methodSymbol.IsInType(KnownType.System_Object)) &&
 methodSymbol.Parameters.Length == 0 &&
 methodSymbol.ReturnType.Is(KnownType.System_String);
Example #2
0
 public static bool IsObjectEquals(this IMethodSymbol methodSymbol) =>
 methodSymbol != null &&
 methodSymbol.MethodKind == MethodKind.Ordinary &&
 methodSymbol.Name == nameof(object.Equals) &&
 (methodSymbol.IsOverride || methodSymbol.IsInType(KnownType.System_Object)) &&
 methodSymbol.Parameters.Length == 1 &&
 methodSymbol.Parameters[0].Type.Is(KnownType.System_Object) &&
 methodSymbol.ReturnType.Is(KnownType.System_Boolean);
Example #3
0
 public static bool IsObjectGetHashCode(this IMethodSymbol methodSymbol)
 {
     return(methodSymbol != null &&
            (methodSymbol.IsOverride || methodSymbol.IsInType(KnownType.System_Object)) &&
            methodSymbol.MethodKind == MethodKind.Ordinary &&
            methodSymbol.Name == nameof(object.GetHashCode) &&
            methodSymbol.Parameters.Length == 0 &&
            methodSymbol.ReturnType.Is(KnownType.System_Int32));
 }
Example #4
0
        public static bool IsStaticObjectEquals(this IMethodSymbol methodSymbol)
        {
            return(methodSymbol != null &&
                   !methodSymbol.IsOverride &&
                   methodSymbol.IsStatic &&
                   methodSymbol.MethodKind == MethodKind.Ordinary &&
                   methodSymbol.Name == nameof(object.Equals) &&
                   methodSymbol.IsInType(KnownType.System_Object) &&
                   HasCorrectParameters() &&
                   methodSymbol.ReturnType.Is(KnownType.System_Boolean));

            bool HasCorrectParameters() =>
            methodSymbol.Parameters.Length == 2 &&
            methodSymbol.Parameters[0].Type.Is(KnownType.System_Object) &&
            methodSymbol.Parameters[1].Type.Is(KnownType.System_Object);
        }
 private static bool IsOperationAddOnString(IMethodSymbol operation)
 {
     return(operation != null &&
            operation.Name == additionOperatorName &&
            operation.IsInType(KnownType.System_String));
 }
 private static bool IsStringFormatCall(IMethodSymbol stringFormatSymbol)
 {
     return(stringFormatSymbol != null &&
            stringFormatSymbol.Name == "Format" &&
            (stringFormatSymbol.ContainingType == null || stringFormatSymbol.IsInType(KnownType.System_String)));
 }
 private static bool IsMethodOnNonIntegralOrDateTime(IMethodSymbol methodSymbol)
 {
     return(methodSymbol.IsInType(KnownType.NonIntegralNumbers) ||
            methodSymbol.IsInType(KnownType.System_DateTime));
 }
Example #8
0
 public static bool IsConsoleWrite(this IMethodSymbol methodSymbol)
 {
     return(methodSymbol != null &&
            methodSymbol.IsInType(KnownType.System_Console) &&
            methodSymbol.Name == nameof(Console.Write));
 }
 private static bool IsMethodOnNonIntegralOrDateTime(IMethodSymbol methodSymbol)
 {
     return methodSymbol.IsInType(KnownType.NonIntegralNumbers) ||
         methodSymbol.IsInType(KnownType.System_DateTime);
 }
 private static bool IsOperationAddOnString(IMethodSymbol operation)
 {
     return operation != null &&
         operation.Name == additionOperatorName &&
         operation.IsInType(KnownType.System_String);
 }
 private static bool IsStringFormatCall(IMethodSymbol stringFormatSymbol)
 {
     return stringFormatSymbol != null &&
         stringFormatSymbol.Name == "Format" &&
         (stringFormatSymbol.ContainingType == null || stringFormatSymbol.IsInType(KnownType.System_String));
 }