@@ -55,7 +55,7 @@ public static FileData[] Translate(FileData[] files, MetadataReference[]? refere
5555 . AddSyntaxTrees ( trees ) ;
5656
5757
58- Dictionary < string , List < string > > _exportedClasses = new ( ) ;
58+ Dictionary < string , List < string > > exportedClasses = new ( ) ;
5959
6060 //Enable modules if, more than 2 files.
6161 if ( files . Length >= 2 )
@@ -73,7 +73,7 @@ public static FileData[] Translate(FileData[] files, MetadataReference[]? refere
7373 {
7474 SemanticModel _model = compilation . GetSemanticModel ( trees [ i ] ) ;
7575
76- ExportClassesWalker _exportClassesWalker = new ( _model , ref _exportedClasses ) ;
76+ ExportClassesWalker _exportClassesWalker = new ( _model , ref exportedClasses ) ;
7777 SyntaxNode _root = trees [ i ] . GetRoot ( ) ;
7878 _exportClassesWalker . Visit ( _root ) ;
7979 }
@@ -104,16 +104,16 @@ public static FileData[] Translate(FileData[] files, MetadataReference[]? refere
104104
105105 SyntaxNode _root = trees [ i ] . GetRoot ( ) ;
106106
107- WithSemanticRewriter _withSemanticRewriter = new ( _model , files [ i ] . OptionsForFile , _exportedClasses ) ;
107+ WithSemanticWalker _withSemanticWalker = new ( _model , files [ i ] . OptionsForFile , exportedClasses ) ;
108108 WithoutSemanticRewriter _withoutSemanticRewriter = new ( files [ i ] . OptionsForFile ) ;
109109
110110 StringBuilderWalker _stringBuilderWalker = new ( ) ;
111111
112- _root = _withSemanticRewriter . Visit ( _root ) ;
112+ _withSemanticWalker . Visit ( _root ) ;
113113
114- _root = _root . ReplaceNodes ( _withSemanticRewriter . ReplaceNodes . Keys , ( o , r ) =>
114+ _root = _root . ReplaceNodes ( _withSemanticWalker . ReplaceNodes . Keys , ( o , r ) =>
115115 {
116- return _withSemanticRewriter . ReplaceNodes [ o ] ;
116+ return _withSemanticWalker . ReplaceNodes [ o ] ;
117117 } ) ;
118118
119119 if ( files [ i ] . OptionsForFile . Debug )
@@ -139,18 +139,23 @@ public static FileData[] Translate(FileData[] files, MetadataReference[]? refere
139139 //Import modules
140140 if ( files [ i ] . OptionsForFile . EnableModules >= 2 )
141141 {
142- Dictionary < string , List < string > > . KeyCollection _keys = _withSemanticRewriter . ImportClasses . Keys ;
142+ Dictionary < string , List < string > > . KeyCollection _keys = _withSemanticWalker . ImportClasses . Keys ;
143143
144144 foreach ( string _filename in _keys )
145145 {
146- _stringBuilderWalker . JSSB . AppendLine ( ) ;
146+ if ( _stringBuilderWalker . JSSB . Length != 0 )
147+ {
148+ if ( _stringBuilderWalker . JSSB [ _stringBuilderWalker . JSSB . Length - 1 ] != '\n ' )
149+ _stringBuilderWalker . JSSB . AppendLine ( ) ;
150+ }
151+
147152 _stringBuilderWalker . JSSB . Append ( "import { " ) ;
148- for ( int j = 0 ; j < _withSemanticRewriter . ImportClasses [ _filename ] . Count ; j ++ )
153+ for ( int j = 0 ; j < _withSemanticWalker . ImportClasses [ _filename ] . Count ; j ++ )
149154 {
150- if ( j == _withSemanticRewriter . ImportClasses [ _filename ] . Count - 1 )
151- _stringBuilderWalker . JSSB . Append ( $ "{ _withSemanticRewriter . ImportClasses [ _filename ] [ j ] } ") ;
155+ if ( j == _withSemanticWalker . ImportClasses [ _filename ] . Count - 1 )
156+ _stringBuilderWalker . JSSB . Append ( $ "{ _withSemanticWalker . ImportClasses [ _filename ] [ j ] } ") ;
152157 else
153- _stringBuilderWalker . JSSB . Append ( $ "{ _withSemanticRewriter . ImportClasses [ _filename ] [ j ] } , ") ;
158+ _stringBuilderWalker . JSSB . Append ( $ "{ _withSemanticWalker . ImportClasses [ _filename ] [ j ] } , ") ;
154159 }
155160 _stringBuilderWalker . JSSB . AppendLine ( $ " }} from './{ _filename } ';") ;
156161 }
@@ -161,9 +166,11 @@ public static FileData[] Translate(FileData[] files, MetadataReference[]? refere
161166 //Export modules
162167 if ( files [ i ] . OptionsForFile . EnableModules >= 2 )
163168 {
164- if ( _exportedClasses . TryGetValue ( files [ i ] . FileName , out List < string > ? _value ) )
169+ if ( exportedClasses . TryGetValue ( files [ i ] . FileName , out List < string > ? _value ) )
165170 {
166- _stringBuilderWalker . JSSB . AppendLine ( ) ;
171+ if ( _stringBuilderWalker . JSSB [ _stringBuilderWalker . JSSB . Length - 1 ] != '\n ' )
172+ _stringBuilderWalker . JSSB . AppendLine ( ) ;
173+
167174 _stringBuilderWalker . JSSB . Append ( "export { " ) ;
168175 for ( int j = 0 ; j < _value . Count ; j ++ )
169176 {
@@ -172,7 +179,7 @@ public static FileData[] Translate(FileData[] files, MetadataReference[]? refere
172179 else
173180 _stringBuilderWalker . JSSB . Append ( $ "{ _value [ j ] } , ") ;
174181 }
175- _stringBuilderWalker . JSSB . AppendLine ( " };" ) ;
182+ _stringBuilderWalker . JSSB . Append ( " };" ) ;
176183 }
177184 }
178185
@@ -254,7 +261,7 @@ private static MetadataReference[] GetReferences(CSTOJSOptions options)
254261
255262 Log . InfoLine ( $ "assemblyPath: '{ assemblyPath } '") ;
256263 Log . InfoLine ( $ "objectAssemblyPath: '{ objectAssemblyPath } '") ;
257- Log . InfoLine ( $ "binPath : '{ customPath } '") ;
264+ Log . InfoLine ( $ "customPath : '{ customPath } '") ;
258265
259266 foreach ( MetadataReference metadata in assemblyMetadata )
260267 {
0 commit comments