@@ -130,7 +130,7 @@ private static UxmlAttributeInfo GetAttributeInfo(GeneratorExecutionContext cont
130130
131131 var info = new UxmlAttributeInfo
132132 {
133- TypeIdentifier = GetPropertyTypeIdentifier ( context , property , out var typeSyntax ) ,
133+ TypeIdentifier = GetPropertyTypeIdentifier ( context , property , out var typeSyntax , out var typeNamespace ) ,
134134 PrivateFieldName = propertyName . ToPrivateFieldName ( ) ,
135135 AttributeUxmlName = propertyName . ToDashCase ( )
136136 } ;
@@ -168,31 +168,33 @@ private static UxmlAttributeInfo GetAttributeInfo(GeneratorExecutionContext cont
168168 return info ;
169169 }
170170
171- info . DefaultValueAssignmentExpression = IdentifierName ( uxmlAttributeDefaultValue ) ;
171+ info . DefaultValueAssignmentExpression = IdentifierName ( $ "global:: { typeNamespace } . { uxmlAttributeDefaultValue } " ) ;
172172 return info ;
173173 }
174174
175175 private static string GetPropertyTypeIdentifier ( GeneratorExecutionContext context ,
176- BasePropertyDeclarationSyntax property , out TypeSyntax ? typeSyntax )
176+ BasePropertyDeclarationSyntax property , out TypeSyntax ? typeSyntax , out string ? typeNamespace )
177177 {
178178 switch ( property . Type )
179179 {
180180 case PredefinedTypeSyntax predefinedType :
181181 {
182- var propertyTypeIdentifier = predefinedType . Keyword . Text . FirstCharToUpper ( ) ;
183-
184182 typeSyntax = predefinedType ;
183+ typeNamespace = default ;
184+
185+ var propertyTypeIdentifier = predefinedType . Keyword . Text . FirstCharToUpper ( ) ;
185186
186187 return $ "Uxml{ propertyTypeIdentifier } AttributeDescription";
187188 }
188189
189190 case IdentifierNameSyntax customTypeSyntax :
190191 {
192+ typeSyntax = customTypeSyntax ;
193+ typeNamespace = customTypeSyntax . GetTypeNamespace ( context ) ;
194+
191195 var type = customTypeSyntax . Identifier . Text ;
192- var typeNamespace = customTypeSyntax . GetTypeNamespace ( context ) ;
193196 var propertyTypeText = $ "global::{ typeNamespace } .{ type } ";
194197
195- typeSyntax = customTypeSyntax ;
196198
197199 return propertyTypeText == UnityColorTypeFullName
198200 ? UxmlColorAttributeDescription
@@ -201,6 +203,7 @@ private static string GetPropertyTypeIdentifier(GeneratorExecutionContext contex
201203
202204 default :
203205 typeSyntax = default ;
206+ typeNamespace = default ;
204207 return property . Type . GetText ( ) . ToString ( ) . Trim ( ) ;
205208 }
206209 }
0 commit comments