Skip to content

Document GeneratedRegexAttribute property support in .NET 9#51735

Open
Copilot wants to merge 4 commits intomainfrom
copilot/update-generatedregexattribute-docs
Open

Document GeneratedRegexAttribute property support in .NET 9#51735
Copilot wants to merge 4 commits intomainfrom
copilot/update-generatedregexattribute-docs

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

The documentation for GeneratedRegexAttribute only mentioned partial methods, but starting in .NET 9 (preview 6), the attribute can also be applied to partial properties via C# 13's partial property support.

Changes

  • Updated introduction to note property support starting in .NET 9
  • Added code example demonstrating property syntax:
    [GeneratedRegex("abc|def", RegexOptions.IgnoreCase, "en-US")]
    private static partial Regex AbcOrDefGeneratedRegexProperty { get; }
  • Updated Visual Studio navigation tip to reference "method or property declaration"

The property and method approaches are functionally equivalent; properties provide an alternative syntax.

Original prompt

This section details on the original issue you should resolve

<issue_title>Documenation of GeneratedRegexAttribute does not mention it can be applied to properties as well</issue_title>
<issue_description>### Type of issue

Outdated article

Description

The linked article does never mention that the GeneratedRegexAttribute can also be applied to get-only properties. Originally, it could only be applied to methods, but that was changed in .NET 9-preview 6 link to commit. The online documentation of the attribute itself also does not contain the updated remark, that it can be applied to get-only properties as well. It however shows the correct signature with System.AttributeTargets.Property

Page URL

https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-source-generators#when-to-use-it

Content source URL

https://github.com/dotnet/docs/blob/main/docs/standard/base-types/regular-expression-source-generators.md

Document Version Independent Id

76b98e7b-6acc-cb43-da8e-475a8b4ed5a1

Platform Id

4db261b2-abb4-466b-330c-7e6791abd68d

Article author

@adegeo

Metadata

  • ID: 56298202-fa5d-363d-3c52-adbf5256b184
  • PlatformId: 4db261b2-abb4-466b-330c-7e6791abd68d
  • Service: dotnet-fundamentals

Related Issues</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Internal previews

📄 File 🔗 Preview link
docs/standard/base-types/regular-expression-source-generators.md .NET regular expression source generators

…ort in .NET 9

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation for GeneratedRegexAttribute usage Document GeneratedRegexAttribute property support in .NET 9 Feb 13, 2026
Copilot AI requested a review from gewarren February 13, 2026 19:09
@gewarren gewarren marked this pull request as ready for review February 13, 2026 19:26
@gewarren gewarren requested review from a team and adegeo as code owners February 13, 2026 19:26
Copilot AI review requested due to automatic review settings February 13, 2026 19:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the regular expression source generators documentation to reflect that GeneratedRegexAttribute can be applied to partial properties (in addition to partial methods) starting in .NET 9. This feature was introduced in .NET 9 preview 6 and leverages C# 13's partial property support.

Changes:

  • Updated the introduction to note that the attribute can be applied to partial properties starting in .NET 9
  • Added a new code example demonstrating the partial property syntax as an alternative to the partial method approach
  • Updated Visual Studio navigation tip to reference both "method or property declaration"

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@gewarren gewarren enabled auto-merge (squash) February 14, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documenation of GeneratedRegexAttribute does not mention it can be applied to properties as well

2 participants