diff --git a/InterfaceStubGenerator.Shared/InterfaceStubGenerator.cs b/InterfaceStubGenerator.Shared/InterfaceStubGenerator.cs
index ddb4bf6af..535a1d6a9 100644
--- a/InterfaceStubGenerator.Shared/InterfaceStubGenerator.cs
+++ b/InterfaceStubGenerator.Shared/InterfaceStubGenerator.cs
@@ -24,7 +24,6 @@ public class InterfaceStubGenerator : ISourceGenerator
#endif
{
private const string TypeParameterVariableName = "_typeParameters";
- private const string GenericTypeVariableName = "_genericTypes";
#pragma warning disable RS2008 // Enable analyzer release tracking
static readonly DiagnosticDescriptor InvalidRefitMember = new(
@@ -388,8 +387,7 @@ partial class {ns}{classDeclaration}
/// Contains the unique member names in the interface scope.
void ProcessRefitMethod(StringBuilder source, IMethodSymbol methodSymbol, bool isTopLevel, HashSet memberNames)
{
- var (typeParameterName, nullInit, genericTypeName) =
- WriteMethodStaticFields(source, methodSymbol, memberNames);
+ var parameterTypesExpression = GenerateTypeParameterExpression(source, methodSymbol, memberNames);
var returnType = methodSymbol.ReturnType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
var (isAsync, @return, configureAwait) = methodSymbol.ReturnType.MetadataName switch
@@ -408,35 +406,22 @@ void ProcessRefitMethod(StringBuilder source, IMethodSymbol methodSymbol, bool i
argList.Add($"@{param.MetadataName}");
}
+ // List of generic arguments
+ var genericList = new List();
+ foreach (var typeParam in methodSymbol.TypeParameters)
+ {
+ genericList.Add($"typeof({typeParam.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)})");
+ }
+
var argumentsArrayString = argList.Count == 0
? "global::System.Array.Empty