1+ //HintName: ValidatableInfoResolver.g.cs
2+ #nullable enable annotations
3+ //------------------------------------------------------------------------------
4+ // <auto-generated>
5+ // This code was generated by a tool.
6+ //
7+ // Changes to this file may cause incorrect behavior and will be lost if
8+ // the code is regenerated.
9+ // </auto-generated>
10+ //------------------------------------------------------------------------------
11+ #nullable enable
12+
13+ namespace System . Runtime . CompilerServices
14+ {
15+ [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.AspNetCore.Http.ValidationsGenerator, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60" , "42.42.42.42" ) ]
16+ [ AttributeUsage ( AttributeTargets . Method , AllowMultiple = true ) ]
17+ file sealed class InterceptsLocationAttribute : System . Attribute
18+ {
19+ public InterceptsLocationAttribute ( int version , string data )
20+ {
21+ }
22+ }
23+ }
24+
25+ namespace Microsoft . AspNetCore . Http . Validation . Generated
26+ {
27+ [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.AspNetCore.Http.ValidationsGenerator, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60" , "42.42.42.42" ) ]
28+ file sealed class GeneratedValidatablePropertyInfo : global ::Microsoft . AspNetCore . Http . Validation . ValidatablePropertyInfo
29+ {
30+ public GeneratedValidatablePropertyInfo (
31+ global ::System . Type containingType ,
32+ global ::System . Type propertyType ,
33+ string name ,
34+ string displayName ) : base ( containingType , propertyType , name , displayName )
35+ {
36+ ContainingType = containingType ;
37+ Name = name ;
38+ }
39+
40+ internal global ::System . Type ContainingType { get ; }
41+ internal string Name { get ; }
42+
43+ protected override global ::System . ComponentModel . DataAnnotations . ValidationAttribute [ ] GetValidationAttributes ( )
44+ => ValidationAttributeCache . GetValidationAttributes ( ContainingType , Name ) ;
45+ }
46+
47+ [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.AspNetCore.Http.ValidationsGenerator, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60" , "42.42.42.42" ) ]
48+ file sealed class GeneratedValidatableTypeInfo : global ::Microsoft . AspNetCore . Http . Validation . ValidatableTypeInfo
49+ {
50+ public GeneratedValidatableTypeInfo (
51+ global ::System . Type type ,
52+ ValidatablePropertyInfo [ ] members ) : base ( type , members ) { }
53+ }
54+
55+ [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.AspNetCore.Http.ValidationsGenerator, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60" , "42.42.42.42" ) ]
56+ file class GeneratedValidatableInfoResolver : global ::Microsoft . AspNetCore . Http . Validation . IValidatableInfoResolver
57+ {
58+ public bool TryGetValidatableTypeInfo ( global ::System . Type type , [ global ::System . Diagnostics . CodeAnalysis . NotNullWhen ( true ) ] out global ::Microsoft . AspNetCore . Http . Validation . IValidatableInfo ? validatableInfo )
59+ {
60+ validatableInfo = null ;
61+ if ( type == typeof ( global ::ComplexType ) )
62+ {
63+ validatableInfo = CreateComplexType ( ) ;
64+ return true ;
65+ }
66+
67+ return false ;
68+ }
69+
70+ // No-ops, rely on runtime code for ParameterInfo-based resolution
71+ public bool TryGetValidatableParameterInfo ( global ::System . Reflection . ParameterInfo parameterInfo , [ global ::System . Diagnostics . CodeAnalysis . NotNullWhen ( true ) ] out global ::Microsoft . AspNetCore . Http . Validation . IValidatableInfo ? validatableInfo )
72+ {
73+ validatableInfo = null ;
74+ return false ;
75+ }
76+
77+ private ValidatableTypeInfo CreateComplexType ( )
78+ {
79+ return new GeneratedValidatableTypeInfo (
80+ type : typeof ( global ::ComplexType ) ,
81+ members : [
82+ new GeneratedValidatablePropertyInfo (
83+ containingType : typeof ( global ::ComplexType ) ,
84+ propertyType : typeof ( int ) ,
85+ name : "IntegerWithRange" ,
86+ displayName : "IntegerWithRange"
87+ ) ,
88+ ]
89+ ) ;
90+ }
91+
92+ }
93+
94+ [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.AspNetCore.Http.ValidationsGenerator, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60" , "42.42.42.42" ) ]
95+ file static class GeneratedServiceCollectionExtensions
96+ {
97+ [ InterceptsLocation ]
98+ public static global ::Microsoft . Extensions . DependencyInjection . IServiceCollection AddValidation ( this global ::Microsoft . Extensions . DependencyInjection . IServiceCollection services , global ::System . Action < ValidationOptions > ? configureOptions = null )
99+ {
100+ // Use non-extension method to avoid infinite recursion.
101+ return global ::Microsoft . Extensions . DependencyInjection . ValidationServiceCollectionExtensions . AddValidation ( services , options =>
102+ {
103+ options . Resolvers . Insert ( 0 , new GeneratedValidatableInfoResolver ( ) ) ;
104+ if ( configureOptions is not null )
105+ {
106+ configureOptions ( options ) ;
107+ }
108+ } ) ;
109+ }
110+ }
111+
112+ [ global ::System . CodeDom . Compiler . GeneratedCodeAttribute ( "Microsoft.AspNetCore.Http.ValidationsGenerator, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60" , "42.42.42.42" ) ]
113+ file static class ValidationAttributeCache
114+ {
115+ private sealed record CacheKey ( global ::System . Type ContainingType , string PropertyName ) ;
116+ private static readonly global ::System . Collections . Concurrent . ConcurrentDictionary < CacheKey , global ::System . ComponentModel . DataAnnotations . ValidationAttribute [ ] > _cache = new ( ) ;
117+
118+ public static global ::System . ComponentModel . DataAnnotations . ValidationAttribute [ ] GetValidationAttributes (
119+ global ::System . Type containingType ,
120+ string propertyName )
121+ {
122+ var key = new CacheKey ( containingType , propertyName ) ;
123+ return _cache . GetOrAdd ( key , static k =>
124+ {
125+ var property = k . ContainingType . GetProperty ( k . PropertyName ) ;
126+ if ( property == null )
127+ {
128+ return [ ] ;
129+ }
130+
131+ return [ .. global ::System . Reflection . CustomAttributeExtensions . GetCustomAttributes < global ::System . ComponentModel . DataAnnotations . ValidationAttribute > ( property , inherit : true ) ] ;
132+ } ) ;
133+ }
134+ }
135+ }
0 commit comments