Skip to content

SYSLIB1045 Use GeneratedRegexAttribute replaces verbatim string with regular string #78113

Description

@MaceWindu

Description

It is quite common to use verbatim strings to declare regex as it could contain a lot of escape sequences and with regular strings it looks like back-slach circus.

Currently SYSLIB1045 refactoring replaces verbatim strings with regular strings.

Reproduction Steps

privatestaticreadonlyRegex_regex=new(@"[`~!@#\$%\^&*\(\)_\+\-={}\|\[\]\\:"";'<>\?,\./№ ]+");

Expected behavior

[GeneratedRegex(@"[`~!@#\$%\^&*\(\)_\+\-={}\|\[\]\\:"";'<>\?,\./№ ]+")]privatestaticpartialRegexMyRegex();

Actual behavior

[GeneratedRegex("[`~!@#\\$%\\^&*\\(\\)_\\+\\-={}\\|\\[\\]\\\\:\";'<>\\?,\\./№ ]+")]privatestaticpartialRegexMyRegex();

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions