2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
4
using System . Diagnostics ;
5
+ using System . Diagnostics . CodeAnalysis ;
5
6
using System . Reflection . Context . Custom ;
6
7
using System . Reflection . Context . Projection ;
7
8
@@ -45,7 +46,8 @@ public Assembly ProjectAssemblyIfNeeded(Assembly value)
45
46
return value ;
46
47
}
47
48
48
- public override TypeInfo ProjectType ( Type value )
49
+ [ return : NotNullIfNotNull ( "value" ) ]
50
+ public override TypeInfo ? ProjectType ( Type ? value )
49
51
{
50
52
if ( value == null )
51
53
return null ;
@@ -55,7 +57,8 @@ public override TypeInfo ProjectType(Type value)
55
57
return new CustomType ( value , ReflectionContext ) ;
56
58
}
57
59
58
- public override Assembly ProjectAssembly ( Assembly value )
60
+ [ return : NotNullIfNotNull ( "value" ) ]
61
+ public override Assembly ? ProjectAssembly ( Assembly ? value )
59
62
{
60
63
if ( value == null )
61
64
return null ;
@@ -65,7 +68,8 @@ public override Assembly ProjectAssembly(Assembly value)
65
68
return new CustomAssembly ( value , ReflectionContext ) ;
66
69
}
67
70
68
- public override Module ProjectModule ( Module value )
71
+ [ return : NotNullIfNotNull ( "value" ) ]
72
+ public override Module ? ProjectModule ( Module ? value )
69
73
{
70
74
if ( value == null )
71
75
return null ;
@@ -75,7 +79,8 @@ public override Module ProjectModule(Module value)
75
79
return new CustomModule ( value , ReflectionContext ) ;
76
80
}
77
81
78
- public override FieldInfo ProjectField ( FieldInfo value )
82
+ [ return : NotNullIfNotNull ( "value" ) ]
83
+ public override FieldInfo ? ProjectField ( FieldInfo ? value )
79
84
{
80
85
if ( value == null )
81
86
return null ;
@@ -85,7 +90,8 @@ public override FieldInfo ProjectField(FieldInfo value)
85
90
return new CustomFieldInfo ( value , ReflectionContext ) ;
86
91
}
87
92
88
- public override EventInfo ProjectEvent ( EventInfo value )
93
+ [ return : NotNullIfNotNull ( "value" ) ]
94
+ public override EventInfo ? ProjectEvent ( EventInfo ? value )
89
95
{
90
96
if ( value == null )
91
97
return null ;
@@ -95,7 +101,8 @@ public override EventInfo ProjectEvent(EventInfo value)
95
101
return new CustomEventInfo ( value , ReflectionContext ) ;
96
102
}
97
103
98
- public override ConstructorInfo ProjectConstructor ( ConstructorInfo value )
104
+ [ return : NotNullIfNotNull ( "value" ) ]
105
+ public override ConstructorInfo ? ProjectConstructor ( ConstructorInfo ? value )
99
106
{
100
107
if ( value == null )
101
108
return null ;
@@ -105,7 +112,8 @@ public override ConstructorInfo ProjectConstructor(ConstructorInfo value)
105
112
return new CustomConstructorInfo ( value , ReflectionContext ) ;
106
113
}
107
114
108
- public override MethodInfo ProjectMethod ( MethodInfo value )
115
+ [ return : NotNullIfNotNull ( "value" ) ]
116
+ public override MethodInfo ? ProjectMethod ( MethodInfo ? value )
109
117
{
110
118
if ( value == null )
111
119
return null ;
@@ -115,23 +123,25 @@ public override MethodInfo ProjectMethod(MethodInfo value)
115
123
return new CustomMethodInfo ( value , ReflectionContext ) ;
116
124
}
117
125
118
- public override MethodBase ProjectMethodBase ( MethodBase value )
126
+ [ return : NotNullIfNotNull ( "value" ) ]
127
+ public override MethodBase ? ProjectMethodBase ( MethodBase ? value )
119
128
{
120
129
if ( value == null )
121
130
return null ;
122
131
123
- MethodInfo method = value as MethodInfo ;
132
+ MethodInfo ? method = value as MethodInfo ;
124
133
if ( method != null )
125
134
return ProjectMethod ( method ) ;
126
135
127
- ConstructorInfo constructor = value as ConstructorInfo ;
136
+ ConstructorInfo ? constructor = value as ConstructorInfo ;
128
137
if ( constructor != null )
129
138
return ProjectConstructor ( constructor ) ;
130
139
131
140
throw new InvalidOperationException ( SR . Format ( SR . InvalidOperation_InvalidMethodType , value . GetType ( ) ) ) ;
132
141
}
133
142
134
- public override PropertyInfo ProjectProperty ( PropertyInfo value )
143
+ [ return : NotNullIfNotNull ( "value" ) ]
144
+ public override PropertyInfo ? ProjectProperty ( PropertyInfo ? value )
135
145
{
136
146
if ( value == null )
137
147
return null ;
@@ -141,7 +151,8 @@ public override PropertyInfo ProjectProperty(PropertyInfo value)
141
151
return new CustomPropertyInfo ( value , ReflectionContext ) ;
142
152
}
143
153
144
- public override ParameterInfo ProjectParameter ( ParameterInfo value )
154
+ [ return : NotNullIfNotNull ( "value" ) ]
155
+ public override ParameterInfo ? ProjectParameter ( ParameterInfo ? value )
145
156
{
146
157
if ( value == null )
147
158
return null ;
@@ -151,7 +162,8 @@ public override ParameterInfo ProjectParameter(ParameterInfo value)
151
162
return new CustomParameterInfo ( value , ReflectionContext ) ;
152
163
}
153
164
154
- public override MethodBody ProjectMethodBody ( MethodBody value )
165
+ [ return : NotNullIfNotNull ( "value" ) ]
166
+ public override MethodBody ? ProjectMethodBody ( MethodBody ? value )
155
167
{
156
168
if ( value == null )
157
169
return null ;
@@ -161,7 +173,8 @@ public override MethodBody ProjectMethodBody(MethodBody value)
161
173
return new ProjectingMethodBody ( value , this ) ;
162
174
}
163
175
164
- public override LocalVariableInfo ProjectLocalVariable ( LocalVariableInfo value )
176
+ [ return : NotNullIfNotNull ( "value" ) ]
177
+ public override LocalVariableInfo ? ProjectLocalVariable ( LocalVariableInfo ? value )
165
178
{
166
179
if ( value == null )
167
180
return null ;
@@ -171,7 +184,8 @@ public override LocalVariableInfo ProjectLocalVariable(LocalVariableInfo value)
171
184
return new ProjectingLocalVariableInfo ( value , this ) ;
172
185
}
173
186
174
- public override ExceptionHandlingClause ProjectExceptionHandlingClause ( ExceptionHandlingClause value )
187
+ [ return : NotNullIfNotNull ( "value" ) ]
188
+ public override ExceptionHandlingClause ? ProjectExceptionHandlingClause ( ExceptionHandlingClause ? value )
175
189
{
176
190
if ( value == null )
177
191
return null ;
@@ -181,7 +195,8 @@ public override ExceptionHandlingClause ProjectExceptionHandlingClause(Exception
181
195
return new ProjectingExceptionHandlingClause ( value , this ) ;
182
196
}
183
197
184
- public override CustomAttributeData ProjectCustomAttributeData ( CustomAttributeData value )
198
+ [ return : NotNullIfNotNull ( "value" ) ]
199
+ public override CustomAttributeData ? ProjectCustomAttributeData ( CustomAttributeData ? value )
185
200
{
186
201
if ( value == null )
187
202
return null ;
@@ -191,7 +206,8 @@ public override CustomAttributeData ProjectCustomAttributeData(CustomAttributeDa
191
206
return new ProjectingCustomAttributeData ( value , this ) ;
192
207
}
193
208
194
- public override ManifestResourceInfo ProjectManifestResource ( ManifestResourceInfo value )
209
+ [ return : NotNullIfNotNull ( "value" ) ]
210
+ public override ManifestResourceInfo ? ProjectManifestResource ( ManifestResourceInfo ? value )
195
211
{
196
212
if ( value == null )
197
213
return null ;
@@ -201,12 +217,13 @@ public override ManifestResourceInfo ProjectManifestResource(ManifestResourceInf
201
217
return new ProjectingManifestResourceInfo ( value , this ) ;
202
218
}
203
219
204
- public override MemberInfo ProjectMember ( MemberInfo value )
220
+ [ return : NotNullIfNotNull ( "value" ) ]
221
+ public override MemberInfo ? ProjectMember ( MemberInfo ? value )
205
222
{
206
223
if ( value == null )
207
224
return null ;
208
225
209
- MemberInfo output = null ;
226
+ MemberInfo ? output ;
210
227
switch ( value . MemberType )
211
228
{
212
229
case MemberTypes . TypeInfo :
@@ -243,7 +260,7 @@ public override MemberInfo ProjectMember(MemberInfo value)
243
260
244
261
public override CustomAttributeTypedArgument ProjectTypedArgument ( CustomAttributeTypedArgument value )
245
262
{
246
- Type argumentType = ProjectType ( value . ArgumentType ) ;
263
+ Type ? argumentType = ProjectType ( value . ArgumentType ) ;
247
264
248
265
return new CustomAttributeTypedArgument ( argumentType , value . Value ) ;
249
266
}
0 commit comments