@@ -91,7 +91,7 @@ public void LogEventLevel(LogEventLevel level)
91
91
NamerFactory . AdditionalInformation = level . ToString ( ) ;
92
92
93
93
// Arrange
94
- var output = new StringWriter ( ) ;
94
+ using var output = new StringWriter ( ) ;
95
95
var logEvent = CreateLogEvent ( level ) ;
96
96
var formatter = new Log4NetTextFormatter ( ) ;
97
97
@@ -106,7 +106,7 @@ public void LogEventLevel(LogEventLevel level)
106
106
public void InvalidLogEventLevelThrowsArgumentOutOfRangeException ( )
107
107
{
108
108
// Arrange
109
- var output = new StringWriter ( ) ;
109
+ using var output = new StringWriter ( ) ;
110
110
var logEvent = CreateLogEvent ( ( LogEventLevel ) ( - 1 ) ) ;
111
111
var formatter = new Log4NetTextFormatter ( ) ;
112
112
@@ -128,7 +128,7 @@ public void CDataMode(CDataMode mode, bool needsEscaping)
128
128
NamerFactory . AdditionalInformation = mode + "." + ( needsEscaping ? "NeedsEscaping" : "DoesntNeedEscaping" ) ;
129
129
130
130
// Arrange
131
- var output = new StringWriter ( ) ;
131
+ using var output = new StringWriter ( ) ;
132
132
var logEvent = CreateLogEvent ( messageTemplate : needsEscaping ? ">> Hello from Serilog <<" : "Hello from Serilog" ) ;
133
133
var formatter = new Log4NetTextFormatter ( options => options . UseCDataMode ( mode ) ) ;
134
134
@@ -149,7 +149,7 @@ public void LineEnding(LineEnding lineEnding)
149
149
NamerFactory . AdditionalInformation = lineEnding . ToString ( ) ;
150
150
151
151
// Arrange
152
- var output = new StringWriter ( ) ;
152
+ using var output = new StringWriter ( ) ;
153
153
var logEvent = CreateLogEvent ( ) ;
154
154
var formatter = new Log4NetTextFormatter ( options => options . UseLineEnding ( lineEnding ) ) ;
155
155
@@ -170,7 +170,7 @@ public void IndentationSettings(Indentation indentation, byte size)
170
170
NamerFactory . AdditionalInformation = indentation + "." + size ;
171
171
172
172
// Arrange
173
- var output = new StringWriter ( ) ;
173
+ using var output = new StringWriter ( ) ;
174
174
var logEvent = CreateLogEvent ( ) ;
175
175
var formatter = new Log4NetTextFormatter ( options => options . UseIndentationSettings ( new IndentationSettings ( indentation , size ) ) ) ;
176
176
@@ -185,7 +185,7 @@ public void IndentationSettings(Indentation indentation, byte size)
185
185
public void NoIndentation ( )
186
186
{
187
187
// Arrange
188
- var output = new StringWriter ( ) ;
188
+ using var output = new StringWriter ( ) ;
189
189
var logEvent = CreateLogEvent ( ) ;
190
190
var formatter = new Log4NetTextFormatter ( options => options . UseNoIndentation ( ) ) ;
191
191
@@ -200,7 +200,7 @@ public void NoIndentation()
200
200
public void NoNamespace ( )
201
201
{
202
202
// Arrange
203
- var output = new StringWriter ( ) ;
203
+ using var output = new StringWriter ( ) ;
204
204
var logEvent = CreateLogEvent ( ) ;
205
205
var formatter = new Log4NetTextFormatter ( options => options . UseLog4NetXmlNamespace ( null ) ) ;
206
206
@@ -215,7 +215,7 @@ public void NoNamespace()
215
215
public void NullProperty ( )
216
216
{
217
217
// Arrange
218
- var output = new StringWriter ( ) ;
218
+ using var output = new StringWriter ( ) ;
219
219
var logEvent = CreateLogEvent ( properties : new LogEventProperty ( "n/a" , new ScalarValue ( null ) ) ) ;
220
220
var formatter = new Log4NetTextFormatter ( ) ;
221
221
@@ -230,7 +230,7 @@ public void NullProperty()
230
230
public void DefaultFormatProvider ( )
231
231
{
232
232
// Arrange
233
- var output = new StringWriter ( ) ;
233
+ using var output = new StringWriter ( ) ;
234
234
var logEvent = CreateLogEvent ( messageTemplate : "π = {π}" , properties : new LogEventProperty ( "π" , new ScalarValue ( 3.14m ) ) ) ;
235
235
var formatter = new Log4NetTextFormatter ( ) ;
236
236
@@ -245,7 +245,7 @@ public void DefaultFormatProvider()
245
245
public void ExplicitFormatProvider ( )
246
246
{
247
247
// Arrange
248
- var output = new StringWriter ( ) ;
248
+ using var output = new StringWriter ( ) ;
249
249
var logEvent = CreateLogEvent ( messageTemplate : "π = {π}" , properties : new LogEventProperty ( "π" , new ScalarValue ( 3.14m ) ) ) ;
250
250
var formatProvider = new NumberFormatInfo { NumberDecimalSeparator = "," } ;
251
251
var formatter = new Log4NetTextFormatter ( options => options . UseFormatProvider ( formatProvider ) ) ;
@@ -261,7 +261,7 @@ public void ExplicitFormatProvider()
261
261
public void TwoProperties ( )
262
262
{
263
263
// Arrange
264
- var output = new StringWriter ( ) ;
264
+ using var output = new StringWriter ( ) ;
265
265
var logEvent = CreateLogEvent ( properties : new [ ] {
266
266
new LogEventProperty ( "one" , new ScalarValue ( 1 ) ) ,
267
267
new LogEventProperty ( "two" , new ScalarValue ( 2 ) ) ,
@@ -279,7 +279,7 @@ public void TwoProperties()
279
279
public void TwoPropertiesOneNull ( )
280
280
{
281
281
// Arrange
282
- var output = new StringWriter ( ) ;
282
+ using var output = new StringWriter ( ) ;
283
283
var logEvent = CreateLogEvent ( properties : new [ ] {
284
284
new LogEventProperty ( "n/a" , new ScalarValue ( null ) ) ,
285
285
new LogEventProperty ( "one" , new ScalarValue ( 1 ) ) ,
@@ -297,7 +297,7 @@ public void TwoPropertiesOneNull()
297
297
public void FilterProperty ( )
298
298
{
299
299
// Arrange
300
- var output = new StringWriter ( ) ;
300
+ using var output = new StringWriter ( ) ;
301
301
var logEvent = CreateLogEvent ( properties : new [ ] {
302
302
new LogEventProperty ( "one" , new ScalarValue ( 1 ) ) ,
303
303
new LogEventProperty ( "two" , new ScalarValue ( 2 ) ) ,
@@ -315,7 +315,7 @@ public void FilterProperty()
315
315
public void FilterPropertyThrowing ( )
316
316
{
317
317
// Arrange
318
- var output = new StringWriter ( ) ;
318
+ using var output = new StringWriter ( ) ;
319
319
var logEvent = CreateLogEvent ( properties : new [ ] {
320
320
new LogEventProperty ( "one" , new ScalarValue ( 1 ) ) ,
321
321
new LogEventProperty ( "two" , new ScalarValue ( 2 ) ) ,
@@ -338,7 +338,7 @@ public void FilterPropertyThrowing()
338
338
public void TwoEvents ( )
339
339
{
340
340
// Arrange
341
- var output = new StringWriter ( ) ;
341
+ using var output = new StringWriter ( ) ;
342
342
var logEvent = CreateLogEvent ( ) ;
343
343
var formatter = new Log4NetTextFormatter ( ) ;
344
344
@@ -354,7 +354,7 @@ public void TwoEvents()
354
354
public void Exception ( )
355
355
{
356
356
// Arrange
357
- var output = new StringWriter ( ) ;
357
+ using var output = new StringWriter ( ) ;
358
358
var logEvent = CreateLogEvent ( exception : new Exception ( "An error occurred" ) . SetStackTrace ( @" at Serilog.Formatting.Log4Net.Tests.Log4NetTextFormatterTest.BasicMessage_WithException() in Log4NetTextFormatterTest.cs:123" ) ) ;
359
359
var formatter = new Log4NetTextFormatter ( ) ;
360
360
@@ -369,7 +369,7 @@ public void Exception()
369
369
public void ExceptionFormatter ( )
370
370
{
371
371
// Arrange
372
- var output = new StringWriter ( ) ;
372
+ using var output = new StringWriter ( ) ;
373
373
var logEvent = CreateLogEvent ( exception : new Exception ( "An error occurred" ) ) ;
374
374
var formatter = new Log4NetTextFormatter ( options => options . UseExceptionFormatter ( e => $ "Type = { e . GetType ( ) . FullName } \n Message = { e . Message } ") ) ;
375
375
@@ -384,7 +384,7 @@ public void ExceptionFormatter()
384
384
public void ExceptionFormatterReturningNull ( )
385
385
{
386
386
// Arrange
387
- var output = new StringWriter ( ) ;
387
+ using var output = new StringWriter ( ) ;
388
388
var logEvent = CreateLogEvent ( exception : new Exception ( "An error occurred" ) ) ;
389
389
var formatter = new Log4NetTextFormatter ( options => options . UseExceptionFormatter ( e => null ! ) ) ;
390
390
@@ -399,7 +399,7 @@ public void ExceptionFormatterReturningNull()
399
399
public void ExceptionFormatterThrowing ( )
400
400
{
401
401
// Arrange
402
- var output = new StringWriter ( ) ;
402
+ using var output = new StringWriter ( ) ;
403
403
var logEvent = CreateLogEvent ( exception : new Exception ( "An error occurred" ) ) ;
404
404
var formatter = new Log4NetTextFormatter ( options => options . UseExceptionFormatter ( e => throw new InvalidOperationException ( "💥 Boom 💥" ) ) ) ;
405
405
@@ -418,7 +418,7 @@ public void ThreadId(int? threadId)
418
418
NamerFactory . AdditionalInformation = threadId ? . ToString ( ) ?? "_null" ;
419
419
420
420
// Arrange
421
- var output = new StringWriter ( ) ;
421
+ using var output = new StringWriter ( ) ;
422
422
var logEvent = CreateLogEvent ( properties : new LogEventProperty ( ThreadIdEnricher . ThreadIdPropertyName , new ScalarValue ( threadId ) ) ) ;
423
423
var formatter = new Log4NetTextFormatter ( ) ;
424
424
@@ -440,7 +440,7 @@ public void DomainAndUserName(string? environmentUserName)
440
440
NamerFactory . AdditionalInformation = environmentUserName == null ? "_null" : environmentUserName . Length == 0 ? "_empty" : environmentUserName . Replace ( @"\" , "_" ) ;
441
441
442
442
// Arrange
443
- var output = new StringWriter ( ) ;
443
+ using var output = new StringWriter ( ) ;
444
444
var logEvent = CreateLogEvent ( properties : new LogEventProperty ( EnvironmentUserNameEnricher . EnvironmentUserNamePropertyName , new ScalarValue ( environmentUserName ) ) ) ;
445
445
var formatter = new Log4NetTextFormatter ( ) ;
446
446
@@ -459,7 +459,7 @@ public void MachineName(string? machineName)
459
459
NamerFactory . AdditionalInformation = machineName ?? "_null" ;
460
460
461
461
// Arrange
462
- var output = new StringWriter ( ) ;
462
+ using var output = new StringWriter ( ) ;
463
463
var logEvent = CreateLogEvent ( properties : new LogEventProperty ( MachineNameEnricher . MachineNamePropertyName , new ScalarValue ( machineName ) ) ) ;
464
464
var formatter = new Log4NetTextFormatter ( ) ;
465
465
@@ -474,7 +474,7 @@ public void MachineName(string? machineName)
474
474
public void SequenceProperty ( )
475
475
{
476
476
// Arrange
477
- var output = new StringWriter ( ) ;
477
+ using var output = new StringWriter ( ) ;
478
478
var values = new LogEventPropertyValue [ ] { new ScalarValue ( 1 ) , new ScalarValue ( "two" ) , CreateDictionary ( ) } ;
479
479
var logEvent = CreateLogEvent ( properties : new LogEventProperty ( "Sequence" , new SequenceValue ( values ) ) ) ;
480
480
var formatter = new Log4NetTextFormatter ( ) ;
@@ -490,7 +490,7 @@ public void SequenceProperty()
490
490
public void DictionaryProperty ( )
491
491
{
492
492
// Arrange
493
- var output = new StringWriter ( ) ;
493
+ using var output = new StringWriter ( ) ;
494
494
var values = new [ ]
495
495
{
496
496
new KeyValuePair < ScalarValue , LogEventPropertyValue > ( new ScalarValue ( 1 ) , new ScalarValue ( "one" ) ) ,
@@ -511,7 +511,7 @@ public void DictionaryProperty()
511
511
public void StructureProperty ( )
512
512
{
513
513
// Arrange
514
- var output = new StringWriter ( ) ;
514
+ using var output = new StringWriter ( ) ;
515
515
var values = new [ ]
516
516
{
517
517
new LogEventProperty ( "1" , new ScalarValue ( "one" ) ) ,
0 commit comments