Skip to content

Commit 03746e3

Browse files
Merge pull request #506 from tannergooding/main
Ensure that we don't try to create a test stream if test output isn't…
2 parents 5a549a4 + 2585c5f commit 03746e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@ public void Close()
239239
var outputPath = _config.OutputLocation;
240240
stream = _outputStreamFactory(outputPath);
241241

242-
var testOutputPath = _config.TestOutputLocation;
243-
testStream = _outputStreamFactory(testOutputPath);
244-
245242
leaveStreamOpen = true;
246243

247244
var usingDirectives = new SortedSet<string>(StringComparer.Ordinal);
@@ -333,6 +330,9 @@ public void Close()
333330

334331
if (testHasAnyContents)
335332
{
333+
var testOutputPath = _config.TestOutputLocation;
334+
testStream = _outputStreamFactory(testOutputPath);
335+
336336
using var sw = new StreamWriter(testStream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen);
337337
sw.NewLine = "\n";
338338

@@ -358,7 +358,7 @@ public void Close()
358358
}
359359
else
360360
{
361-
testStream = null;
361+
Debug.Assert(testStream is null);
362362
}
363363
}
364364

0 commit comments

Comments
 (0)