@@ -119,7 +119,7 @@ public WithoutSemanticRewriter(CSTOJSOptions options)
119119 {
120120 if ( _Options . MakePropertiesEnumerable )
121121 {
122- _enumProp += $ ", set: function (value) {{ this.{ _fieldIdentifier } = value; }} }}";
122+ _enumProp += $ ", set: function (value) {{ this.{ _fieldIdentifier } = value; }} }}";
123123 }
124124 else
125125 {
@@ -137,30 +137,33 @@ public WithoutSemanticRewriter(CSTOJSOptions options)
137137 SyntaxFactory . IdentifierName ( "value" ) ) . NormalizeWhitespace ( ) ) ) )
138138 . WithLeadingTrivia ( _prop . GetLeadingTrivia ( ) )
139139 . WithTrailingTrivia ( _prop . GetTrailingTrivia ( ) ) ;
140-
140+
141141 if ( _static != null )
142142 _setM = _setM . WithoutLeadingTrivia ( ) . WithModifiers ( SyntaxFactory . TokenList ( ( SyntaxToken ) _static ) ) ;
143143
144144 node = node . WithMembers ( node . Members . Insert ( _indexToInsert ++ , _setM ) ) ;
145145 }
146146 }
147147
148- if ( _constructorIndex == - 1 )
148+ if ( _Options . MakePropertiesEnumerable )
149149 {
150- Log . WarningLine ( $ "Constructor is 'null' for: { node . Identifier } . MakePropertiesEnumerable is ignored!") ;
150+ if ( _constructorIndex == - 1 )
151+ {
152+ Log . WarningLine ( $ "Constructor is 'null' for: { node . Identifier } . MakePropertiesEnumerable is ignored!") ;
151153
152- }
153- else
154- {
155- _enumProp += ")" ;
154+ }
155+ else
156+ {
157+ _enumProp += ")" ;
156158
157- ConstructorDeclarationSyntax _constr = ( ConstructorDeclarationSyntax ) node . Members [ _constructorIndex ] ;
159+ ConstructorDeclarationSyntax _constr = ( ConstructorDeclarationSyntax ) node . Members [ _constructorIndex ] ;
158160
159- node = node . ReplaceNode ( _constr . Body ,
160- _constr . Body . WithStatements ( _constr . Body . Statements . Insert ( 0 ,
161- SyntaxFactory . ExpressionStatement (
162- SyntaxFactory . IdentifierName ( _enumProp ) )
163- . WithTrailingTrivia ( SyntaxFactory . CarriageReturnLineFeed ) ) ) . WithLeadingTrivia ( _constr . Body . GetLeadingTrivia ( ) ) . WithTrailingTrivia ( _constr . Body . GetTrailingTrivia ( ) ) ) ;
161+ node = node . ReplaceNode ( _constr . Body ,
162+ _constr . Body . WithStatements ( _constr . Body . Statements . Insert ( 0 ,
163+ SyntaxFactory . ExpressionStatement (
164+ SyntaxFactory . IdentifierName ( _enumProp ) )
165+ . WithTrailingTrivia ( SyntaxFactory . CarriageReturnLineFeed ) ) ) . WithLeadingTrivia ( _constr . Body . GetLeadingTrivia ( ) ) . WithTrailingTrivia ( _constr . Body . GetTrailingTrivia ( ) ) ) ;
166+ }
164167 }
165168 }
166169 else
@@ -216,7 +219,7 @@ public WithoutSemanticRewriter(CSTOJSOptions options)
216219 node = ( ConstructorDeclarationSyntax ) base . VisitConstructorDeclaration ( node ) ! ;
217220
218221 SyntaxToken ? staticModifier = TryGetModifier ( SyntaxKind . StaticKeyword , node . Modifiers ) ;
219-
222+
220223 if ( staticModifier == null )
221224 node = node . ReplaceToken ( node . Identifier , SyntaxFactory . Identifier ( "constructor" ) . WithLeadingTrivia ( node . Identifier . LeadingTrivia ) ) ;
222225 else
@@ -238,10 +241,10 @@ public WithoutSemanticRewriter(CSTOJSOptions options)
238241
239242 if ( node . Body . Statements . Count > 0 )
240243 _super = _super . WithLeadingTrivia ( node . Body . Statements [ 0 ] . GetLeadingTrivia ( ) ) . WithTrailingTrivia ( node . Body . Statements [ 0 ] . GetTrailingTrivia ( ) ) ;
241-
244+
242245 node = node . ReplaceNode ( node . Body , node . Body . WithStatements ( node . Body . Statements . Insert ( 0 , _super ) ) ) ;
243246 }
244-
247+
245248 return node ;
246249 }
247250 public override SyntaxNode ? VisitFieldDeclaration ( FieldDeclarationSyntax node )
0 commit comments