Skip to content
Prev Previous commit
Next Next commit
Change analyzer severity to Warning and remove ValueTask support
Co-authored-by: benbp <1020379+benbp@users.noreply.github.com>
  • Loading branch information
Copilot and benbp committed Aug 7, 2025
commit c480f2efdb2a300ba8c3b84f4fbdfa10470aa000
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EnforceToolsReturnTypesAnalyzer : DiagnosticAnalyzer
"Tool methods must return Response types, built-in value types, or string",
"Method '{0}' in Tools namespace must return a class implementing Response, a built-in value type, or string. Current return type: '{1}'.",
"Design",
DiagnosticSeverity.Error,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
Expand Down Expand Up @@ -111,18 +111,6 @@ private static bool IsTaskType(ITypeSymbol type, out ITypeSymbol innerType)
return true;
}
}

// Check for ValueTask<T>
if (namedType.IsGenericType &&
(namedType.ConstructedFrom?.ToDisplayString() == "System.Threading.Tasks.ValueTask<T>" ||
namedType.Name == "ValueTask" && namedType.ContainingNamespace?.ToDisplayString() == "System.Threading.Tasks"))
{
if (namedType.TypeArguments.Length > 0)
{
innerType = namedType.TypeArguments[0];
return true;
}
}
}

return false;
Expand Down
Loading