@@ -130,7 +130,7 @@ private static UxmlAttributeInfo GetAttributeInfo(GeneratorExecutionContext cont
130
130
131
131
var info = new UxmlAttributeInfo
132
132
{
133
- TypeIdentifier = GetPropertyTypeIdentifier ( context , property , out var typeSyntax ) ,
133
+ TypeIdentifier = GetPropertyTypeIdentifier ( context , property , out var typeSyntax , out var typeNamespace ) ,
134
134
PrivateFieldName = propertyName . ToPrivateFieldName ( ) ,
135
135
AttributeUxmlName = propertyName . ToDashCase ( )
136
136
} ;
@@ -168,31 +168,33 @@ private static UxmlAttributeInfo GetAttributeInfo(GeneratorExecutionContext cont
168
168
return info ;
169
169
}
170
170
171
- info . DefaultValueAssignmentExpression = IdentifierName ( uxmlAttributeDefaultValue ) ;
171
+ info . DefaultValueAssignmentExpression = IdentifierName ( $ "global:: { typeNamespace } . { uxmlAttributeDefaultValue } " ) ;
172
172
return info ;
173
173
}
174
174
175
175
private static string GetPropertyTypeIdentifier ( GeneratorExecutionContext context ,
176
- BasePropertyDeclarationSyntax property , out TypeSyntax ? typeSyntax )
176
+ BasePropertyDeclarationSyntax property , out TypeSyntax ? typeSyntax , out string ? typeNamespace )
177
177
{
178
178
switch ( property . Type )
179
179
{
180
180
case PredefinedTypeSyntax predefinedType :
181
181
{
182
- var propertyTypeIdentifier = predefinedType . Keyword . Text . FirstCharToUpper ( ) ;
183
-
184
182
typeSyntax = predefinedType ;
183
+ typeNamespace = default ;
184
+
185
+ var propertyTypeIdentifier = predefinedType . Keyword . Text . FirstCharToUpper ( ) ;
185
186
186
187
return $ "Uxml{ propertyTypeIdentifier } AttributeDescription";
187
188
}
188
189
189
190
case IdentifierNameSyntax customTypeSyntax :
190
191
{
192
+ typeSyntax = customTypeSyntax ;
193
+ typeNamespace = customTypeSyntax . GetTypeNamespace ( context ) ;
194
+
191
195
var type = customTypeSyntax . Identifier . Text ;
192
- var typeNamespace = customTypeSyntax . GetTypeNamespace ( context ) ;
193
196
var propertyTypeText = $ "global::{ typeNamespace } .{ type } ";
194
197
195
- typeSyntax = customTypeSyntax ;
196
198
197
199
return propertyTypeText == UnityColorTypeFullName
198
200
? UxmlColorAttributeDescription
@@ -201,6 +203,7 @@ private static string GetPropertyTypeIdentifier(GeneratorExecutionContext contex
201
203
202
204
default :
203
205
typeSyntax = default ;
206
+ typeNamespace = default ;
204
207
return property . Type . GetText ( ) . ToString ( ) . Trim ( ) ;
205
208
}
206
209
}
0 commit comments