@@ -102,7 +102,7 @@ public static bool TryGetStateMachineType (MethodDefinition method, [NotNullWhen
102102 /// up and find the nearest containing user type. Returns the nearest user type,
103103 /// or null if none was found.
104104 /// </summary>
105- TypeDefinition ? PopulateCacheForType ( TypeDefinition type )
105+ TypeDefinition ? GetCompilerGeneratedStateForType ( TypeDefinition type )
106106 {
107107 // Look in the declaring type if this is a compiler-generated type (state machine or display class).
108108 // State machines can be emitted into display classes, so we may also need to go one more level up.
@@ -183,7 +183,7 @@ lambdaOrLocalFunction.DeclaringType is var generatedType &&
183183 }
184184 // Already warned above if multiple methods map to the same type
185185 // Fill in null for argument providers now, the real providers will be filled in later
186- _ = _generatedTypeToTypeArgumentInfo . TryAdd ( stateMachineType , new TypeArgumentInfo ( method , null ) ) ;
186+ _generatedTypeToTypeArgumentInfo [ stateMachineType ] = new TypeArgumentInfo ( method , null ) ;
187187 }
188188 }
189189
@@ -292,6 +292,7 @@ void MapGeneratedTypeTypeParameters (TypeDefinition generatedType)
292292 if ( typeRef is null ) {
293293 return ;
294294 }
295+
295296 for ( int i = 0 ; i < typeRef . GenericArguments . Count ; i ++ ) {
296297 var typeArg = typeRef . GenericArguments [ i ] ;
297298 // Start with the existing parameters, in case we can't find the mapped one
@@ -321,6 +322,7 @@ void MapGeneratedTypeTypeParameters (TypeDefinition generatedType)
321322
322323 typeArgs [ i ] = userAttrs ;
323324 }
325+
324326 _generatedTypeToTypeArgumentInfo [ generatedType ] = typeInfo with { OriginalAttributes = typeArgs } ;
325327 }
326328 }
@@ -356,7 +358,7 @@ public bool TryGetCompilerGeneratedCalleesForUserMethod (MethodDefinition method
356358 if ( IsNestedFunctionOrStateMachineMember ( method ) )
357359 return false ;
358360
359- var typeToCache = PopulateCacheForType ( method . DeclaringType ) ;
361+ var typeToCache = GetCompilerGeneratedStateForType ( method . DeclaringType ) ;
360362 if ( typeToCache is null )
361363 return false ;
362364
@@ -371,7 +373,7 @@ public bool TryGetCompilerGeneratedCalleesForUserMethod (MethodDefinition method
371373 {
372374 Debug . Assert ( CompilerGeneratedNames . IsGeneratedType ( generatedType . Name ) ) ;
373375
374- var typeToCache = PopulateCacheForType ( generatedType ) ;
376+ var typeToCache = GetCompilerGeneratedStateForType ( generatedType ) ;
375377 if ( typeToCache is null )
376378 return null ;
377379
@@ -407,7 +409,7 @@ public bool TryGetOwningMethodForCompilerGeneratedMember (IMemberDefinition sour
407409 // sourceType is a state machine type, or the type containing a lambda or local function.
408410 // Search all methods to find the one which points to the type as its
409411 // state machine implementation.
410- var typeToCache = PopulateCacheForType ( sourceType ) ;
412+ var typeToCache = GetCompilerGeneratedStateForType ( sourceType ) ;
411413 if ( typeToCache is null )
412414 return false ;
413415
0 commit comments