Skip to content

Update [GeneratedRegex] analyzer/fixer for partial properties #103438

@stephentoub

Description

@stephentoub

The analyzer will currently flag fields like:

private static readonly Regex s_regex = new Regex(...);

and the fixer will propose generating a new method instead. Now that partial properties are a thing and are supported by the generator, the fixer can instead just change the field to be a property (and a user can subsequently rename it if desired), e.g.

[GeneratedRegex(...)]
private static partial Regex s_regex { get; }

For cases where the analyzer flags a property, it's even easier: it can just make the property partial, remove the initialization, and add the attribute.

And for cases where something new still needs to be generated, the fixer could offer the choice of a method or property.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions