@@ -9,20 +9,23 @@ internal sealed partial class UxmlGenerator
9
9
{
10
10
private const string AttributeBaseType = "global::System.Attribute" ;
11
11
12
+ private const string AttributeClassTarget = "Class" ;
13
+ private const string AttributePropertyTarget = "Property" ;
14
+
12
15
private const string UxmlElementClassName = "UxmlElementAttribute" ;
13
16
private const string UxmlAttributeClassName = "UxmlAttributeAttribute" ;
14
17
15
18
private static SourceText GenerateUxmlElementAttribute ( )
16
19
{
17
- return GenerateAttributeClass ( UxmlElementClassName ) ;
20
+ return GenerateAttributeClass ( UxmlElementClassName , AttributeClassTarget ) ;
18
21
}
19
22
20
23
private static SourceText GenerateUxmlAttributeAttribute ( )
21
24
{
22
- return GenerateAttributeClass ( UxmlAttributeClassName , GetUxmlAttributeMembers ( ) ) ;
25
+ return GenerateAttributeClass ( UxmlAttributeClassName , AttributePropertyTarget , GetUxmlAttributeMembers ( ) ) ;
23
26
}
24
27
25
- private static SourceText GenerateAttributeClass ( string attributeClassIdentifier ,
28
+ private static SourceText GenerateAttributeClass ( string attributeClassIdentifier , string attributeTarget ,
26
29
IEnumerable < MemberDeclarationSyntax > ? members = null )
27
30
{
28
31
return CompilationUnitWidget (
@@ -31,6 +34,20 @@ private static SourceText GenerateAttributeClass(string attributeClassIdentifier
31
34
identifier : attributeClassIdentifier ,
32
35
modifiers : new [ ] { SyntaxKind . InternalKeyword , SyntaxKind . SealedKeyword } ,
33
36
baseType : SimpleBaseType ( IdentifierName ( AttributeBaseType ) ) ,
37
+ attribute : AttributeWidget (
38
+ identifier : "global::System.AttributeUsage" ,
39
+ arguments : new [ ]
40
+ {
41
+ AttributeArgument ( MemberAccessWidget (
42
+ identifier : "global::System.AttributeTargets" ,
43
+ memberName : attributeTarget ) ) ,
44
+ AttributeArgument ( AssignmentWidget (
45
+ left : IdentifierName ( "AllowMultiple" ) ,
46
+ right : LiteralExpression ( SyntaxKind . FalseLiteralExpression ) ) ) ,
47
+ AttributeArgument ( AssignmentWidget (
48
+ left : IdentifierName ( "Inherited" ) ,
49
+ right : LiteralExpression ( SyntaxKind . FalseLiteralExpression ) ) )
50
+ } ) ,
34
51
members : members ,
35
52
addGeneratedCodeAttributes : true ) ,
36
53
normalizeWhitespace : true )
0 commit comments