@@ -58,39 +58,32 @@ internal void MarkTypeForDynamicallyAccessedMembers (in MessageOrigin origin, Ty
58
58
59
59
// Resolve a (potentially assembly qualified) type name based on the current context (taken from DiagnosticContext) and mark the type for reflection.
60
60
// This method will probe the current context assembly and if that fails CoreLib for the specified type. Emulates behavior of Type.GetType.
61
- internal bool TryResolveTypeNameAndMark ( string typeName , in DiagnosticContext diagnosticContext , bool needsAssemblyName , [ NotNullWhen ( true ) ] out TypeDefinition ? type )
61
+ internal bool TryResolveTypeNameAndMark ( string typeName , in DiagnosticContext diagnosticContext , bool needsAssemblyName , [ NotNullWhen ( true ) ] out TypeReference ? type )
62
62
{
63
- if ( ! _context . TypeNameResolver . TryResolveTypeName ( typeName , diagnosticContext , out TypeReference ? typeRef , out var typeResolutionRecords , needsAssemblyName )
64
- || typeRef . ResolveToTypeDefinition ( _context ) is not TypeDefinition foundType ) {
63
+ if ( ! _context . TypeNameResolver . TryResolveTypeName ( typeName , diagnosticContext , out type , out var typeResolutionRecords , needsAssemblyName ) ) {
65
64
type = default ;
66
65
return false ;
67
66
}
68
67
69
- MarkResolvedType ( diagnosticContext , typeRef , foundType , typeResolutionRecords ) ;
70
-
71
- type = foundType ;
68
+ MarkType ( diagnosticContext , type , typeResolutionRecords ) ;
72
69
return true ;
73
70
}
74
71
75
72
// Resolve a type from the specified assembly and mark it for reflection.
76
- internal bool TryResolveTypeNameAndMark ( AssemblyDefinition assembly , string typeName , in DiagnosticContext diagnosticContext , [ NotNullWhen ( true ) ] out TypeDefinition ? type )
73
+ internal bool TryResolveTypeNameAndMark ( AssemblyDefinition assembly , string typeName , in DiagnosticContext diagnosticContext , [ NotNullWhen ( true ) ] out TypeReference ? type )
77
74
{
78
- if ( ! _context . TypeNameResolver . TryResolveTypeName ( assembly , typeName , out TypeReference ? typeRef , out var typeResolutionRecords )
79
- || typeRef . ResolveToTypeDefinition ( _context ) is not TypeDefinition foundType ) {
75
+ if ( ! _context . TypeNameResolver . TryResolveTypeName ( assembly , typeName , out type , out var typeResolutionRecords ) ) {
80
76
type = default ;
81
77
return false ;
82
78
}
83
79
84
- MarkResolvedType ( diagnosticContext , typeRef , foundType , typeResolutionRecords ) ;
85
-
86
- type = foundType ;
80
+ MarkType ( diagnosticContext , type , typeResolutionRecords ) ;
87
81
return true ;
88
82
}
89
83
90
- void MarkResolvedType (
84
+ void MarkType (
91
85
in DiagnosticContext diagnosticContext ,
92
86
TypeReference typeReference ,
93
- TypeDefinition typeDefinition ,
94
87
List < TypeNameResolver . TypeResolutionRecord > typeResolutionRecords )
95
88
{
96
89
if ( _enabled ) {
@@ -100,9 +93,9 @@ void MarkResolvedType (
100
93
// This is necessary because if the app's code contains the input string as literal (which is pretty much always the case)
101
94
// that string has to work at runtime, and if it relies on type forwarders we need to preserve those as well.
102
95
var origin = diagnosticContext . Origin ;
103
- _markStep . MarkTypeVisibleToReflection ( typeReference , typeDefinition , new DependencyInfo ( DependencyKind . AccessedViaReflection , origin . Provider ) , origin ) ;
96
+ _markStep . MarkTypeVisibleToReflection ( typeReference , new DependencyInfo ( DependencyKind . AccessedViaReflection , origin . Provider ) , origin ) ;
104
97
foreach ( var typeResolutionRecord in typeResolutionRecords ) {
105
- _context . MarkingHelpers . MarkMatchingExportedType ( typeResolutionRecord . ResolvedType , typeResolutionRecord . ReferringAssembly , new DependencyInfo ( DependencyKind . DynamicallyAccessedMember , typeDefinition ) , origin ) ;
98
+ _context . MarkingHelpers . MarkMatchingExportedType ( typeResolutionRecord . ResolvedType , typeResolutionRecord . ReferringAssembly , new DependencyInfo ( DependencyKind . DynamicallyAccessedMember , typeReference ) , origin ) ;
106
99
}
107
100
}
108
101
}
@@ -115,7 +108,7 @@ internal void MarkType (in MessageOrigin origin, TypeReference typeRef, Dependen
115
108
if ( typeRef . ResolveToTypeDefinition ( _context ) is not TypeDefinition type )
116
109
return ;
117
110
118
- _markStep . MarkTypeVisibleToReflection ( type , type , new DependencyInfo ( dependencyKind , origin . Provider ) , origin ) ;
111
+ _markStep . MarkTypeVisibleToReflection ( type , new DependencyInfo ( dependencyKind , origin . Provider ) , origin ) ;
119
112
}
120
113
121
114
internal void MarkMethod ( in MessageOrigin origin , MethodDefinition method , DependencyKind dependencyKind = DependencyKind . AccessedViaReflection )
0 commit comments