Skip to content

Commit cacb702

Browse files
authored
Simplify pragma suppressions in generated regex code (#118258)
Every generated regex output contained multiple pragma suppressions for warnings we know to be possible. We can simplify this by just suppressing all warnings in the generated code. If there is a stray warning (e.g. because of a custom analyzer), there's nothing the developer can do about it, and it can break their build if they have warnings-as-errors.
1 parent df9a908 commit cacb702

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ public partial class RegexGenerator : IIncrementalGenerator
3131
[
3232
"// <auto-generated/>",
3333
"#nullable enable",
34+
#if DEBUG
3435
"#pragma warning disable CS0162 // Unreachable code",
3536
"#pragma warning disable CS0164 // Unreferenced label",
3637
"#pragma warning disable CS0219 // Variable assigned but never used",
38+
#else
39+
"#pragma warning disable",
40+
#endif
3741
];
3842

3943
internal record struct CompilationData(bool AllowUnsafe, bool CheckOverflow, LanguageVersion LanguageVersion);

0 commit comments

Comments
 (0)