@@ -7,13 +7,19 @@ namespace UnityUxmlGenerator;
77internal sealed partial class UxmlGenerator
88{
99 private static CompilationUnitSyntax CompilationUnitWidget (
10+ string ? namespaceIdentifier = null ,
1011 bool addGeneratedCodeLeadingTrivia = true ,
1112 bool normalizeWhitespace = true ,
1213 params MemberDeclarationSyntax [ ] ? members )
1314 {
1415 var compilationUnit = CompilationUnit ( ) ;
1516
16- if ( members is not null )
17+ if ( string . IsNullOrWhiteSpace ( namespaceIdentifier ) == false )
18+ {
19+ compilationUnit =
20+ compilationUnit . AddMembers ( NamespaceWidget ( identifier : namespaceIdentifier ! , members : members ) ) ;
21+ }
22+ else if ( members is not null )
1723 {
1824 compilationUnit = compilationUnit . AddMembers ( members ) ;
1925 }
@@ -90,7 +96,7 @@ private static ConstructorDeclarationSyntax ConstructorWidget(
9096 ParameterSyntax ? parameter = null ,
9197 ParameterSyntax [ ] ? parameters = null ,
9298 bool addGeneratedCodeAttributes = false ,
93- params StatementSyntax [ ] ? body )
99+ params StatementSyntax [ ] ? bodyStatements )
94100 {
95101 var constructorDeclaration = ConstructorDeclaration ( Identifier ( identifier ) ) ;
96102
@@ -104,9 +110,9 @@ private static ConstructorDeclarationSyntax ConstructorWidget(
104110 constructorDeclaration = constructorDeclaration . AddParameterListParameters ( parameters ) ;
105111 }
106112
107- if ( body is not null )
113+ if ( bodyStatements is not null )
108114 {
109- constructorDeclaration = constructorDeclaration . WithBody ( Block ( body ) ) ;
115+ constructorDeclaration = constructorDeclaration . WithBody ( Block ( bodyStatements ) ) ;
110116 }
111117
112118 return BaseWidgetDecoration ( constructorDeclaration , modifier , modifiers , addGeneratedCodeAttributes ) ;
@@ -137,14 +143,14 @@ private static PropertyDeclarationSyntax PropertyWidget(
137143 SyntaxKind ? modifier = null ,
138144 SyntaxKind [ ] ? modifiers = null ,
139145 bool addGeneratedCodeAttributes = false ,
140- params SyntaxKind [ ] ? accessor )
146+ params SyntaxKind [ ] ? accessors )
141147 {
142148 var propertyDeclaration = PropertyDeclaration ( type , Identifier ( identifier ) ) ;
143149
144- if ( accessor is not null )
150+ if ( accessors is not null )
145151 {
146152 propertyDeclaration =
147- propertyDeclaration . AddAccessorListAccessors ( accessor . Select ( AccessorWidget ) . ToArray ( ) ) ;
153+ propertyDeclaration . AddAccessorListAccessors ( accessors . Select ( AccessorWidget ) . ToArray ( ) ) ;
148154 }
149155
150156 return BaseWidgetDecoration ( propertyDeclaration , modifier , modifiers , addGeneratedCodeAttributes ) ;
@@ -158,7 +164,7 @@ private static MethodDeclarationSyntax MethodWidget(
158164 ParameterSyntax ? parameter = null ,
159165 ParameterSyntax [ ] ? parameters = null ,
160166 bool addGeneratedCodeAttributes = false ,
161- params StatementSyntax [ ] ? body )
167+ params StatementSyntax [ ] ? bodyStatements )
162168 {
163169 var methodDeclaration = MethodDeclaration ( type , Identifier ( identifier ) ) ;
164170
@@ -172,9 +178,9 @@ private static MethodDeclarationSyntax MethodWidget(
172178 methodDeclaration = methodDeclaration . AddParameterListParameters ( parameters ) ;
173179 }
174180
175- if ( body is not null )
181+ if ( bodyStatements is not null )
176182 {
177- methodDeclaration = methodDeclaration . WithBody ( Block ( body ) ) ;
183+ methodDeclaration = methodDeclaration . WithBody ( Block ( bodyStatements ) ) ;
178184 }
179185
180186 return BaseWidgetDecoration ( methodDeclaration , modifier , modifiers , addGeneratedCodeAttributes ) ;
0 commit comments