@@ -115,19 +115,6 @@ public void Archive(string originalPath, PathTransformer.ITransformedPath transf
115
115
ArchivePath ( fullInputPath , transformedPath , inputEncoding ) ;
116
116
}
117
117
118
- /// <summary>
119
- /// Archive a file given the file contents.
120
- /// </summary>
121
- /// <param name="inputPath">The path of the file.</param>
122
- /// <param name="contents">The contents of the file.</param>
123
- public void Archive ( PathTransformer . ITransformedPath inputPath , string contents )
124
- {
125
- if ( string . IsNullOrEmpty ( archive ) )
126
- return ;
127
-
128
- ArchiveContents ( inputPath , contents ) ;
129
- }
130
-
131
118
/// <summary>
132
119
/// Try to move a file from sourceFile to destFile.
133
120
/// If successful returns true,
@@ -209,23 +196,21 @@ public void Emit(ITrapEmitter emitter)
209
196
/// <exception cref="PathTooLongException">If the output path in the source archive would
210
197
/// exceed the system path limit of 260 characters.</exception>
211
198
private void ArchivePath ( string fullInputPath , PathTransformer . ITransformedPath transformedPath , Encoding inputEncoding )
212
- {
213
- var contents = File . ReadAllText ( fullInputPath , inputEncoding ) ;
214
- ArchiveContents ( transformedPath , contents ) ;
215
- }
216
-
217
- private void ArchiveContents ( PathTransformer . ITransformedPath transformedPath , string contents )
218
199
{
219
200
var dest = FileUtils . NestPaths ( logger , archive , transformedPath . Value ) ;
220
- var tmpSrcFile = Path . GetTempFileName ( ) ;
221
- File . WriteAllText ( tmpSrcFile , contents , utf8 ) ;
222
201
try
223
202
{
203
+ var contents = File . ReadAllText ( fullInputPath , inputEncoding ) ;
204
+ var tmpSrcFile = Path . GetTempFileName ( ) ;
205
+ File . WriteAllText ( tmpSrcFile , contents , utf8 ) ;
206
+
224
207
FileUtils . MoveOrReplace ( tmpSrcFile , dest ) ;
225
208
}
226
209
catch ( Exception ex )
227
210
{
228
- // If this happened, it was probably because the same file was compiled multiple times.
211
+ // If this happened, it was probably because
212
+ // - the same file was compiled multiple times, or
213
+ // - the file doesn't exist (due to wrong #line directive or because it's an in-memory source generated AST).
229
214
// In any case, this is not a fatal error.
230
215
logger . LogWarning ( "Problem archiving " + dest + ": " + ex ) ;
231
216
}
0 commit comments