-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../core/compatibility/core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: "Breaking change: .NET 7 obsoletions with non-default diagnostic IDs" | ||
titleSuffix: "" | ||
description: Learn about the .NET 7 breaking change in core .NET libraries where some APIs have been marked as obsolete with a custom diagnostic ID. | ||
ms.date: 01/13/2022 | ||
--- | ||
# API obsoletions with non-default diagnostic IDs (.NET 7) | ||
|
||
Some APIs have been marked as obsolete, starting in .NET 7. This breaking change is specific to APIs that have been marked as obsolete *with a custom diagnostic ID*. Suppressing the default obsoletion diagnostic ID, which is [CS0618](../../../../csharp/language-reference/compiler-messages/cs0618.md) for the C# compiler, does not suppress the warnings that the compiler generates when these APIs are used. | ||
|
||
## Change description | ||
|
||
In previous .NET versions, these APIs can be used without any build warning. In .NET 7 and later versions, use of these APIS produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings. | ||
|
||
The following table lists the custom diagnostic IDs and their corresponding warning messages for obsoleted APIs. | ||
|
||
| Diagnostic ID | Description | Severity | | ||
| - | - | | ||
| [SYSLIB0036](../../../../fundamentals/syslib-diagnostics/syslib0036.md) | <xref:System.Text.RegularExpressions.Regex.CompileToAssembly%2A?displayProperty=nameWithType> is obsolete and not supported. Use `RegexGeneratorAttribute` with the regular expression source generator instead. | Warning | | ||
|
||
## Version introduced | ||
|
||
.NET 7 | ||
|
||
## Type of breaking change | ||
|
||
These obsoletions can affect [source compatibility](../../categories.md#source-compatibility). | ||
|
||
## Recommended action | ||
|
||
- Follow the specific guidance provided for the each diagnostic ID using the URL link provided on the warning. | ||
|
||
- Warnings or errors for these obsoletions can't be suppressed using the standard diagnostic ID for obsolete types or members; use the custom `SYSLIBxxxx` diagnostic ID value instead. | ||
|
||
## Affected APIs | ||
|
||
### SYSLIB0036 | ||
|
||
- <xref:System.Text.RegularExpressions.Regex.CompileToAssembly%2A?displayProperty=nameWithType> | ||
|
||
## See also | ||
|
||
- [API obsoletions with non-default diagnostic IDs (.NET 6)](../6.0/obsolete-apis-with-custom-diagnostics.md) | ||
- [API obsoletions with non-default diagnostic IDs (.NET 5)](../5.0/obsolete-apis-with-custom-diagnostics.md) | ||
- [Obsolete features in .NET 5+](../../../../fundamentals/syslib-diagnostics/obsoletions-overview.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: SYSLIB0036 warning - Regex.CompileToAssembly is obsolete | ||
description: Learn about the obsoletion of the Regex.CompileToAssembly method that generates compile-time warning SYSLIB0036. | ||
ms.date: 01/13/2022 | ||
--- | ||
# SYSLIB0036: Regex.CompileToAssembly is obsolete | ||
|
||
The <xref:System.Text.RegularExpressions.Regex.CompileToAssembly%2A?displayProperty=nameWithType> method is marked as obsolete, starting in .NET 7. Using this API in code generates warning `SYSLIB0036` at compile time. | ||
|
||
In .NET 5, .NET 6, and all versions of .NET Core, <xref:System.Text.RegularExpressions.Regex.CompileToAssembly%2A?displayProperty=nameWithType> throws a <xref:System.PlatformNotSupportedException>. In .NET Framework, <xref:System.Text.RegularExpressions.Regex.CompileToAssembly%2A?displayProperty=nameWithType> allows a regular expression instance to be compiled into an assembly. | ||
|
||
## Workaround | ||
|
||
Use the `RegexGeneratorAttribute` feature, which invokes a regular expression source generator. At compile time, the source generator produces an API specific to a regular expression pattern and its options. | ||
|
||
[!INCLUDE [suppress-syslib-warning](includes/suppress-syslib-warning.md)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters