Skip to content

Obsolete some protected members of Regex{Runner} #62573

@stephentoub

Description

@stephentoub

Regex and RegexRunner have a relatively large protected surface area in support of the old CompileToAssembly, which is now obsolete. Some of that functionality is used by code generated by the source generator, but some of the surface area is completely defunct, and some was never used (who knows why it was exposed initially).

namespace System.Text.RegularExpressions;

public class Regex
{
+   [Obsolete(...)]
    protected void InitializeReferences();

+   [Obsolete(...)]
    protected bool UseOptionC()

+   [Obsolete(...)]
    protected bool UseOptionR();
}

public abstract class RegexRunner
{
+   [Obsolete(...)]
    protected Match? Scan(Regex regex, string text, int textbeg, int textend, int textstart, int prevlen, bool quick) => Scan(regex, text, textbeg, textend, textstart, prevlen, quick, regex.MatchTimeout);

+   [Obsolete(...)]
    protected internal Match? Scan(Regex regex, string text, int textbeg, int textend, int textstart, int prevlen, bool quick, TimeSpan timeout)

+   [Obsolete(...)]
    protected static bool CharInSet(char ch, string set, string category);
}

I would like to also make that last CharInSet not only obsolete but also throw new NotSupportedException(). This was never used by the implementation, and we've never generated assets that use whatever format it's trying to support.

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Text.RegularExpressionsbreaking-changeIssue or PR that represents a breaking API or functional change over a previous release.needs-breaking-change-doc-createdBreaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions