File tree Expand file tree Collapse file tree
src/MethodBoundaryAspect.Fody Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ public NamedInstructionBlockChain CreateMethodExecutionArgsInstance(
144144 var methodBaseVariable = _creator . CreateVariable ( methodBaseTypeRef ) ;
145145 InstructionBlock callGetCurrentMethodBlock ;
146146 var variablePersistable = new VariablePersistable ( methodBaseVariable ) ;
147- if ( methodInfoCompileTimeWeaver ? . IsEnabled != true )
147+ if ( methodInfoCompileTimeWeaver ? . IsEnabled != true || ! methodInfoCompileTimeWeaver . CanWeave ( method ) )
148148 {
149149 // fallback: slow GetCurrentMethod
150150 var methodBaseGetCurrentMethod = _referenceFinder . GetMethodReference ( methodBaseTypeRef ,
Original file line number Diff line number Diff line change @@ -77,6 +77,28 @@ public void Finish()
7777 if ( _fieldsCache . Any ( ) )
7878 CreateStaticCtor ( ) ;
7979 }
80+
81+ public bool CanWeave ( MethodDefinition method )
82+ {
83+ // no support for open generic types
84+ if ( IsOpenType ( method ) )
85+ return false ;
86+
87+ var parentType = method . DeclaringType ;
88+ while ( parentType != null )
89+ {
90+ if ( IsOpenType ( parentType ) )
91+ return false ;
92+ parentType = parentType . DeclaringType ;
93+ }
94+
95+ return true ;
96+ }
97+
98+ private static bool IsOpenType ( IGenericParameterProvider method )
99+ {
100+ return method . GenericParameters . Any ( x => x . IsGenericParameter ) ;
101+ }
80102
81103 private string CreateIdentifier ( MemberReference method )
82104 {
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public ModuleWeaver()
4040 InitLogging ( ) ;
4141 }
4242
43- public bool DisableCompileTimeMethodInfos { get ; set ; } = true ;
43+ public bool DisableCompileTimeMethodInfos { get ; set ; }
4444
4545 public int TotalWeavedTypes { get ; private set ; }
4646 public int TotalWeavedMethods { get ; private set ; }
You can’t perform that action at this time.
0 commit comments