private static void ReportIfExpectedResultTypeCannotBeAssignedToReturnType( ref SyntaxNodeAnalysisContext context, AttributeArgumentSyntax expectedResultNamedArgument, ITypeSymbol typeSymbol) { if (typeSymbol.IsTypeParameterAndDeclaredOnMethod()) { return; } if (!expectedResultNamedArgument.CanAssignTo(typeSymbol, context.SemanticModel)) { context.ReportDiagnostic(Diagnostic.Create(expectedResultTypeMismatch, expectedResultNamedArgument.GetLocation(), typeSymbol.MetadataName)); } }