Skip to content

Commit 592ccdd

Browse files
omajidbuyaa-ngfoidl
authored
Dispose IDisposables in RegexGenerator (#103142)
* Dispose IDisposables in RegexGenerator The StringWriter and IndentedTextWriter are IDisposable classes, so we should dispose them when we are done with them. * Update src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.cs Co-authored-by: Günther Foidl <gue@korporal.at> --------- Co-authored-by: Buyaa Namnan <buyankhishig.namnan@microsoft.com> Co-authored-by: Günther Foidl <gue@korporal.at>
1 parent 566b5c9 commit 592ccdd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
140140
}
141141

142142
// At this point we'll be emitting code. Create a writer to hold it all.
143-
var sw = new StringWriter();
144-
IndentedTextWriter writer = new(sw);
143+
using StringWriter sw = new();
144+
using IndentedTextWriter writer = new(sw);
145145

146146
// Add file headers and required usings.
147147
foreach (string header in s_headers)

0 commit comments

Comments
 (0)