@@ -25,12 +25,12 @@ internal ImmutableArray<ValidatableType> TransformValidatableTypeWithAttribute(G
2525 var wellKnownTypes = WellKnownTypes . GetOrCreate ( context . SemanticModel . Compilation ) ;
2626 if ( TryExtractValidatableType ( ( ITypeSymbol ) context . TargetSymbol , wellKnownTypes , ref validatableTypes , ref visitedTypes ) )
2727 {
28- return [ ..validatableTypes ] ;
28+ return [ .. validatableTypes ] ;
2929 }
3030 return [ ] ;
3131 }
3232
33- internal static bool ShouldTransformSymbolWithValidatableTypeAttribute ( SyntaxNode syntaxNode , CancellationToken _ )
33+ internal static bool ShouldTransformSymbolWithEmbeddedValidatableTypeAttribute ( SyntaxNode syntaxNode , CancellationToken _ )
3434 {
3535 // Only process class and record declarations
3636 if ( syntaxNode is not ( ClassDeclarationSyntax or RecordDeclarationSyntax ) )
@@ -54,7 +54,10 @@ internal static bool ShouldTransformSymbolWithValidatableTypeAttribute(SyntaxNod
5454 return false ;
5555 }
5656
57- internal ImmutableArray < ValidatableType > TransformValidatableTypeWithValidatableTypeAttribute ( GeneratorSyntaxContext context , CancellationToken cancellationToken )
57+ internal ImmutableArray < ValidatableType > TransformValidatableTypeWithEmbeddedValidatableTypeAttribute (
58+ GeneratorSyntaxContext context ,
59+ GeneratorSettings settings ,
60+ CancellationToken cancellationToken )
5861 {
5962 if ( context . Node is not ( ClassDeclarationSyntax or RecordDeclarationSyntax ) )
6063 {
@@ -67,8 +70,9 @@ internal ImmutableArray<ValidatableType> TransformValidatableTypeWithValidatable
6770 return [ ] ;
6871 }
6972
70- // Check if the type has a ValidatableTypeAttribute (framework or auto-generated)
71- if ( ! HasValidatableTypeAttribute ( typeSymbol ) )
73+ var validatableTypeAttributeName = $ "{ settings . RootNamespace } .ValidatableTypeAttribute";
74+ // Check if the type has a ValidatableTypeAttribute (auto-generated)
75+ if ( ! HasValidatableTypeAttribute ( typeSymbol , validatableTypeAttributeName ) )
7276 {
7377 return [ ] ;
7478 }
@@ -79,7 +83,7 @@ internal ImmutableArray<ValidatableType> TransformValidatableTypeWithValidatable
7983
8084 if ( TryExtractValidatableType ( typeSymbol , wellKnownTypes , ref validatableTypes , ref visitedTypes ) )
8185 {
82- return [ ..validatableTypes ] ;
86+ return [ .. validatableTypes ] ;
8387 }
8488 return [ ] ;
8589 }
@@ -92,7 +96,7 @@ private static bool IsValidatableTypeAttribute(AttributeSyntax attribute)
9296 name . EndsWith ( ".ValidatableTypeAttribute" , StringComparison . Ordinal ) ;
9397 }
9498
95- private static bool HasValidatableTypeAttribute ( ITypeSymbol typeSymbol )
99+ private static bool HasValidatableTypeAttribute ( ITypeSymbol typeSymbol , string validatableTypeAttributeName )
96100 {
97101 foreach ( var attr in typeSymbol . GetAttributes ( ) )
98102 {
@@ -103,16 +107,15 @@ private static bool HasValidatableTypeAttribute(ITypeSymbol typeSymbol)
103107 }
104108
105109 var name = attributeClass . Name ;
106- var fullName = attributeClass . ToDisplayString ( ) ;
107-
108- // Check for framework attribute
109- if ( fullName == "Microsoft.Extensions.Validation.ValidatableTypeAttribute" )
110+ var namespaceName = attributeClass . ContainingNamespace . ToDisplayString ( ) ;
111+ var fullName = $ "{ namespaceName } .{ name } ";
112+ if ( ! string . Equals ( fullName , validatableTypeAttributeName , StringComparison . Ordinal ) )
110113 {
111- return true ;
114+ continue ;
112115 }
113116
114117 // Check for auto-generated attribute (any namespace)
115- if ( name == "ValidatableTypeAttribute" )
118+ if ( name == validatableTypeAttributeName )
116119 {
117120 // Additional check: ensure it's marked with [Embedded] to confirm it's auto-generated
118121 foreach ( var embeddedAttr in attributeClass . GetAttributes ( ) )
0 commit comments