@@ -14,6 +14,7 @@ public sealed class ContractTypes
14
14
private HashSet < INamedTypeSymbol > OperationType { get ; }
15
15
16
16
private HashSet < INamedTypeSymbol > AuthorizeWhenAttribute { get ; }
17
+ private HashSet < INamedTypeSymbol > GenericAuthorizeWhenAttribute { get ; }
17
18
private HashSet < INamedTypeSymbol > AuthorizeWhenHasAnyOfAttribute { get ; }
18
19
private HashSet < INamedTypeSymbol > QueryCacheAttribute { get ; }
19
20
@@ -31,6 +32,7 @@ public ContractTypes(IReadOnlyCollection<CSharpCompilation> compilations)
31
32
OperationType = GetUnboundTypeSymbols ( compilations , typeof ( IOperation < > ) ) ;
32
33
33
34
AuthorizeWhenAttribute = GetTypeSymbols < AuthorizeWhenAttribute > ( compilations ) ;
35
+ GenericAuthorizeWhenAttribute = GetUnboundTypeSymbols ( compilations , typeof ( AuthorizeWhenAttribute < > ) ) ;
34
36
AuthorizeWhenHasAnyOfAttribute = GetTypeSymbols < AuthorizeWhenHasAnyOfAttribute > ( compilations ) ;
35
37
QueryCacheAttribute = GetTypeSymbols < QueryCacheAttribute > ( compilations ) ;
36
38
ExcludeFromContractsGenerationAttribute = GetTypeSymbols < ExcludeFromContractsGenerationAttribute > ( compilations ) ;
@@ -150,7 +152,7 @@ public bool IsOperationType(ITypeSymbol i) =>
150
152
i is INamedTypeSymbol ns && ns . IsGenericType && OperationType . Contains ( ns . ConstructUnboundGenericType ( ) ) ;
151
153
152
154
public bool IsAuthorizeWhenType ( ITypeSymbol i ) =>
153
- AuthorizeWhenAttribute . Contains ( i ) ;
155
+ AuthorizeWhenAttribute . Contains ( i ) || ( i is INamedTypeSymbol ns && ns . IsGenericType && GenericAuthorizeWhenAttribute . Contains ( ns . ConstructUnboundGenericType ( ) ) ) ;
154
156
155
157
public bool IsAuthorizeWhenHasAnyOfType ( ITypeSymbol i ) =>
156
158
AuthorizeWhenHasAnyOfAttribute . Contains ( i ) ;
0 commit comments