[Breaking change]: Regex.CompileToAssembly is marked as Obsolete with diagnostic id SYSLIB0036 #26352
Closed
1 of 2 tasks
Labels
breaking-change
Indicates a .NET Core breaking change
🏁 Release: .NET 7
Work items for the .NET 7 release
doc-idea
Indicates issues that are suggestions for new topics [org][type][category]
Pri1
High priority, do before Pri2 and Pri3
source incompatible
Source code may encounter a breaking change in behavior when targeting the new version.
Description
The
Regex.CompileToAssembly
API has been marked as Obsolete. References to this API will now produce diagnostic IDSYSLIB0036
. 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
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
The text was updated successfully, but these errors were encountered: