1
- #nullable enable annotations
1
+ #nullable enable annotations
2
2
//------------------------------------------------------------------------------
3
3
// <auto-generated>
4
4
// This code was generated by a tool.
@@ -129,7 +129,7 @@ private ValidatableTypeInfo CreateMetricProvider()
129
129
containingType : typeof ( global ::Microsoft . Diagnostics . Monitoring . WebApi . MetricProvider ) ,
130
130
propertyType : typeof ( string ) ,
131
131
name : "ProviderName" ,
132
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
132
+ displayName : "ProviderName "
133
133
) ,
134
134
]
135
135
) ;
@@ -143,13 +143,13 @@ private ValidatableTypeInfo CreateMetricsOptions()
143
143
containingType : typeof ( global ::Microsoft . Diagnostics . Monitoring . WebApi . MetricsOptions ) ,
144
144
propertyType : typeof ( int ? ) ,
145
145
name : "MetricCount" ,
146
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
146
+ displayName : "MetricCount "
147
147
) ,
148
148
new GeneratedValidatablePropertyInfo (
149
149
containingType : typeof ( global ::Microsoft . Diagnostics . Monitoring . WebApi . MetricsOptions ) ,
150
150
propertyType : typeof ( global ::System . Collections . Generic . List < global ::Microsoft . Diagnostics . Monitoring . WebApi . MetricProvider > ) ,
151
151
name : "Providers" ,
152
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
152
+ displayName : "Providers "
153
153
) ,
154
154
]
155
155
) ;
@@ -163,13 +163,13 @@ private ValidatableTypeInfo CreateMonitorApiKeyOptions()
163
163
containingType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . MonitorApiKeyOptions ) ,
164
164
propertyType : typeof ( string ) ,
165
165
name : "Subject" ,
166
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
166
+ displayName : "Subject "
167
167
) ,
168
168
new GeneratedValidatablePropertyInfo (
169
169
containingType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . MonitorApiKeyOptions ) ,
170
170
propertyType : typeof ( string ) ,
171
171
name : "PublicKey" ,
172
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
172
+ displayName : "PublicKey "
173
173
) ,
174
174
]
175
175
) ;
@@ -183,25 +183,25 @@ private ValidatableTypeInfo CreateAzureAdOptions()
183
183
containingType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . AzureAdOptions ) ,
184
184
propertyType : typeof ( string ) ,
185
185
name : "TenantId" ,
186
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
186
+ displayName : "TenantId "
187
187
) ,
188
188
new GeneratedValidatablePropertyInfo (
189
189
containingType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . AzureAdOptions ) ,
190
190
propertyType : typeof ( string ) ,
191
191
name : "ClientId" ,
192
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
192
+ displayName : "ClientId "
193
193
) ,
194
194
new GeneratedValidatablePropertyInfo (
195
195
containingType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . AzureAdOptions ) ,
196
196
propertyType : typeof ( global ::System . Uri ) ,
197
197
name : "AppIdUri" ,
198
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
198
+ displayName : "AppIdUri "
199
199
) ,
200
200
new GeneratedValidatablePropertyInfo (
201
201
containingType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . AzureAdOptions ) ,
202
202
propertyType : typeof ( string ) ,
203
203
name : "RequiredRole" ,
204
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
204
+ displayName : "RequiredRole "
205
205
) ,
206
206
]
207
207
) ;
@@ -215,13 +215,13 @@ private ValidatableTypeInfo CreateAuthenticationOptions()
215
215
containingType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . AuthenticationOptions ) ,
216
216
propertyType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . MonitorApiKeyOptions ) ,
217
217
name : "MonitorApiKey" ,
218
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
218
+ displayName : "MonitorApiKey "
219
219
) ,
220
220
new GeneratedValidatablePropertyInfo (
221
221
containingType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . AuthenticationOptions ) ,
222
222
propertyType : typeof ( global ::Microsoft . Diagnostics . Tools . Monitor . AzureAdOptions ) ,
223
223
name : "AzureAd" ,
224
- displayName : "Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings "
224
+ displayName : "AzureAd "
225
225
) ,
226
226
]
227
227
) ;
@@ -260,8 +260,8 @@ static class MyExtensions
260
260
[ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.AspNetCore.Http.ValidationsGenerator, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" , "10.0.0.0" ) ]
261
261
file static class GeneratedServiceCollectionExtensions
262
262
{
263
- // [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(1, "M2kOaR09/X9mJ22GvhUC4+4FAABTdGFydHVwLmNz ")]
264
- public static global ::Microsoft . Extensions . DependencyInjection . IServiceCollection AddValidation ( this global ::Microsoft . Extensions . DependencyInjection . IServiceCollection services , global ::System . Action < ValidationOptions > ? configureOptions = null )
263
+ // [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(1, "tgKaeQ8w+KgICFY1OfbdmEk4AABWYWxpZGF0YWJsZUluZm9SZXNvbHZlci5jcw== ")]
264
+ public static global ::Microsoft . Extensions . DependencyInjection . IServiceCollection AddValidation ( this global ::Microsoft . Extensions . DependencyInjection . IServiceCollection services , global ::System . Action < global :: Microsoft . AspNetCore . Http . Validation . ValidationOptions > ? configureOptions = null )
265
265
{
266
266
// Use non-extension method to avoid infinite recursion.
267
267
return global ::Microsoft . Extensions . DependencyInjection . ValidationServiceCollectionExtensions . AddValidation ( services , options =>
@@ -288,13 +288,39 @@ private sealed record CacheKey([property: global::System.Diagnostics.CodeAnalysi
288
288
var key = new CacheKey ( containingType , propertyName ) ;
289
289
return _cache . GetOrAdd ( key , static k =>
290
290
{
291
+ var results = new global ::System . Collections . Generic . List < global ::System . ComponentModel . DataAnnotations . ValidationAttribute > ( ) ;
292
+
293
+ // Get attributes from the property
291
294
var property = k . ContainingType . GetProperty ( k . PropertyName ) ;
292
- if ( property = = null )
295
+ if ( property ! = null )
293
296
{
294
- return [ ] ;
297
+ var propertyAttributes = global ::System . Reflection . CustomAttributeExtensions
298
+ . GetCustomAttributes < global ::System . ComponentModel . DataAnnotations . ValidationAttribute > ( property , inherit : true ) ;
299
+
300
+ results . AddRange ( propertyAttributes ) ;
301
+ }
302
+
303
+ // Check constructors for parameters that match the property name
304
+ // to handle record scenarios
305
+ foreach ( var constructor in k . ContainingType . GetConstructors ( ) )
306
+ {
307
+ // Look for parameter with matching name (case insensitive)
308
+ var parameter = global ::System . Linq . Enumerable . FirstOrDefault (
309
+ constructor . GetParameters ( ) ,
310
+ p => string . Equals ( p . Name , k . PropertyName , global ::System . StringComparison . OrdinalIgnoreCase ) ) ;
311
+
312
+ if ( parameter != null )
313
+ {
314
+ var paramAttributes = global ::System . Reflection . CustomAttributeExtensions
315
+ . GetCustomAttributes < global ::System . ComponentModel . DataAnnotations . ValidationAttribute > ( parameter , inherit : true ) ;
316
+
317
+ results . AddRange ( paramAttributes ) ;
318
+
319
+ break ;
320
+ }
295
321
}
296
322
297
- return [ .. global :: System . Reflection . CustomAttributeExtensions . GetCustomAttributes < global :: System . ComponentModel . DataAnnotations . ValidationAttribute > ( property , inherit : true ) ] ;
323
+ return results . ToArray ( ) ;
298
324
} ) ;
299
325
}
300
326
}
0 commit comments