@@ -37,8 +37,8 @@ public static string ExtractSingleClassName(SyntaxTree syntaxTree)
3737 /// <exception cref="MissingMethodException">Thrown if no matching method is found.</exception>
3838 public static string ExtractMethodNameMatchingDelegate ( Type delegateType , SyntaxTree syntaxTree )
3939 {
40- var delegateInvoke = delegateType . GetMethod ( "Invoke" ) ;
41- var delegateParams = delegateInvoke . GetParameters ( ) ;
40+ var delegateInvoke = delegateType . GetMethod ( Constants . InvokeMethodName ) ;
41+ var delegateParams = delegateInvoke ! . GetParameters ( ) ;
4242 var delegateReturn = delegateInvoke . ReturnType ;
4343 var root = syntaxTree . GetRoot ( ) ;
4444 var methodDecls = root . DescendantNodes ( ) . OfType < MethodDeclarationSyntax > ( ) ;
@@ -56,6 +56,11 @@ public static string ExtractMethodNameMatchingDelegate(Type delegateType, Syntax
5656 for ( int i = 0 ; i < parameters . Count ; i ++ )
5757 {
5858 var paramType = parameters [ i ] . Type ? . ToString ( ) ;
59+ if ( paramType == null )
60+ {
61+ match = false ;
62+ break ;
63+ }
5964 var clrParamType = GetClrTypeName ( paramType ) ;
6065 var delegateParamType = delegateParams [ i ] . ParameterType ;
6166 if ( clrParamType != delegateParamType . Name && clrParamType != delegateParamType . FullName )
@@ -101,7 +106,7 @@ private static string GetClrTypeName(string csharpType)
101106 return csharpType ;
102107
103108 // Handle nullable types (e.g., int?)
104- if ( csharpType . EndsWith ( "?" ) )
109+ if ( csharpType . EndsWith ( '?' ) )
105110 {
106111 var baseType = csharpType . TrimEnd ( '?' ) ;
107112 var clrBase = GetClrTypeName ( baseType ) ;
0 commit comments