Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.18 KB

RCS1186.md

File metadata and controls

53 lines (38 loc) · 1.18 KB

RCS1186: Use Regex instance instead of static method

Property Value
Id RCS1186
Category Usage
Default Severity Hidden
Enabled by Default
Supports Fade-Out -
Supports Fade-Out Analyzer -

Example

Code with Diagnostic

private void Bar()
{
    bool isMatch = Regex.IsMatch("abc", @"\w"); // RCS1186
}

Code with Fix

private readonly Regex _regex = new Regex(@"\w");

private void Bar()
{
    bool isMatch = _regex.IsMatch("abc");
}

How to Suppress

SuppressMessageAttribute

[assembly: SuppressMessage("Usage", "RCS1186:Use Regex instance instead of static method.", Justification = "<Pending>")]

#pragma

#pragma warning disable RCS1186 // Use Regex instance instead of static method.
#pragma warning restore RCS1186 // Use Regex instance instead of static method.

Ruleset

(Generated with DotMarkdown)