-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Text.RegularExpressionsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
Partial properties are destined for support in C# 13. When that happens, we should utilize them in the regex generator (we wanted this experience from the get-go).
This will entail:
- Updating
GeneratedRegexAttributeto target properties:
-[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
+[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public sealed class GeneratedRegexAttribute : Attribute- Updating the generator to support instance and static get-only properties, e.g. if a user writes:
[GeneratedRegex("...")]
private partial Regex MyProp1 { get; }
[GeneratedRegex("...")]
public static partial Regex MyProp2 { get; }the generator emits:
private partial global::System.Text.RegularExpressions.Regex MyProp1 => global::System.Text.RegularExpressions.Generated.MyProp1_0.Instance;
public static partial global::System.Text.RegularExpressions.Regex MyProp2 => global::System.Text.RegularExpressions.Generated.MyProp2_0.Instance;We will only support get-only auto props. Others will result in an error diagnostic.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Text.RegularExpressionsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged