Skip to content

[Breaking change]: Regex.CompileToAssembly is marked as Obsolete with diagnostic id SYSLIB0036 #26352

@jeffhandley

Description

@jeffhandley

Description

The Regex.CompileToAssembly API has been marked as Obsolete. References to this API will now produce diagnostic ID SYSLIB0036. See dotnet/runtime#59734 for the change.

Version

Other (please put exact version in description textbox)

Previous behavior

Version: .NET 7 Preview 1

In all versions of .NET Core as well as .NET 5 and .NET 6, this API would threw PlatformNotSupportedException. In .NET Framework, this API allowed a regular expression instance to be compiled into an assembly.

New behavior

References to this API will result in a build warning; the diagnostic ID reported is SYSLIB0036.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.

Reason for change

This functionality will not be carried forward into .NET. Instead, .NET 7 is introducing a Regular Expression Source Generator that can be invoked using the RegexGeneratorAttribute feature.

Recommended action

Use the RegexGeneratorAttribute feature, which invokes a regular expression source generator, allowing for compile-time production of an API specific to a regular expression pattern and its options.

Feature area

Core .NET libraries

Affected APIs

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 7Work items for the .NET 7 releasebreaking-changeIndicates a .NET Core breaking changesource incompatibleSource code may encounter a breaking change in behavior when targeting the new version.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions