The Regex source generator currently emits this at the beginning of the generated file:
#pragma warning disable CS0162 // Unreachable code
#pragma warning disable CS0164 // Unreferenced label
#pragma warning disable CS0168 // Variable declared but never used
#pragma warning disable CS0219 // Variable assigned but never used
It would be nice (but not required) to avoid the need for these by changing the code generator to not emit the patterns causing these warnings to fire, e.g. variables that are emitted in case they're needed but sometimes aren't, labels emitted out of convenience but sometimes aren't needed, etc. These shouldn't be a performance issue, as they're weeded out by the C# compiler at build time, but these patterns make the code a bit less readable.