Regex Code Analyzer?
I'm looking for a Roslyn code analyzer that checks for proper use of Regex - I cannot use the Regex source generators yet, so I want something that checks that Regex with a const pattern uses .Compiled and that any .Compiled is not leaked (must be static readonly). Also, would like some sort of analyzer to check for dangerous dynamic Regex patterns without timeouts and any other Regex best practices.
6 Replies
It doesn't seem to exist. Write your own
With analyzers and source generators, exactly what you want usually wouldn't exist
Unknown User•7d ago
Message Not Public
Sign In & Join Server To View
stuck on .NET Fx for now so cannot use source generators yet
Unknown User•5d ago
Message Not Public
Sign In & Join Server To View
Yeah I think it should be possible to reference an analyzer in netfx 4.7+
but I'm not sure
netfx 4.7.2 - PackageReference - I can use and make code analyzers, I was just mentioning that I don't believe I can use [GeneratedRegex] in netfx - and ultimately, I'm looking for a code analyzer that checks usages of System.Text.RegularExpressions.Regex