Skip to content

Commit

Permalink
Add SYSLIB0036 (#27845)
Browse files Browse the repository at this point in the history
gewarren authored Jan 14, 2022
1 parent b0d319f commit e9b7f30
Showing 8 changed files with 79 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/core/compatibility/7.0.md
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ If you're migrating an app to .NET 7, the breaking changes listed here might aff

| Title | Binary compatible | Source compatible | Introduced |
| - | - | - | - |
| [API obsoletions with non-default diagnostic IDs](core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md) | ✔️ || Preview 1 |
| [Validate CompressionLevel for BrotliStream](core-libraries/7.0/compressionlevel-validation.md) || ✔️ | Preview 1 |

## Serialization
Original file line number Diff line number Diff line change
@@ -284,4 +284,5 @@ Classes and members that depend on code access security types:
## 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 7)](../7.0/obsolete-apis-with-custom-diagnostics.md)
- [Obsolete features in .NET 5+](../../../../fundamentals/syslib-diagnostics/obsoletions-overview.md)
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ The following table lists the custom diagnostic IDs and their corresponding warn
| Diagnostic ID | Description | Severity |
| - | - |
| [SYSLIB0013](../../../../fundamentals/syslib-diagnostics/syslib0013.md) | <xref:System.Uri.EscapeUriString(System.String)?displayProperty=nameWithType> can corrupt the Uri string in some cases. Consider using <xref:System.Uri.EscapeDataString(System.String)?displayProperty=nameWithType> for query string components instead. | Warning |
| [SYSLIB0014](../../../../fundamentals/syslib-diagnostics/syslib0014.md) | <xref:System.Net.WebRequest>, <xref:System.Net.HttpWebRequest>, <xref:System.Net.ServicePoint>, and <xref:System.Net.WebClient> are obsolete. Use <xref:System.Net.Http.HttpClient> instead. | Error |
| [SYSLIB0014](../../../../fundamentals/syslib-diagnostics/syslib0014.md) | <xref:System.Net.WebRequest>, <xref:System.Net.HttpWebRequest>, <xref:System.Net.ServicePoint>, and <xref:System.Net.WebClient> are obsolete. Use <xref:System.Net.Http.HttpClient> instead. | Warning |
| [SYSLIB0015](../../../../fundamentals/syslib-diagnostics/syslib0015.md) | <xref:System.Runtime.CompilerServices.DisablePrivateReflectionAttribute> has no effect in .NET 6+. | Warning |
| [SYSLIB0016](../../../../fundamentals/syslib-diagnostics/syslib0016.md) | Use the <xref:System.Drawing.Graphics.GetContextInfo%2A?displayProperty=nameWithType> overloads that accept arguments for better performance and fewer allocations. | Warning |
| [SYSLIB0017](../../../../fundamentals/syslib-diagnostics/syslib0017.md) | Strong-name signing is not supported and throws <xref:System.PlatformNotSupportedException>. | Warning |
@@ -35,10 +35,10 @@ The following table lists the custom diagnostic IDs and their corresponding warn
| [SYSLIB0029](../../../../fundamentals/syslib-diagnostics/syslib0029.md) | `ProduceLegacyHmacValues` is obsolete. Producing legacy HMAC values is no longer supported. | Warning |
| [SYSLIB0030](../../../../fundamentals/syslib-diagnostics/syslib0030.md) | `HMACSHA1` always uses the algorithm implementation provided by the platform. Use a constructor without the `useManagedSha1` parameter. | Warning |
| [SYSLIB0031](../../../../fundamentals/syslib-diagnostics/syslib0031.md) | <xref:System.Security.Cryptography.CryptoConfig.EncodeOID(System.String)?displayProperty=nameWithType> is obsolete. Use the ASN.1 functionality provided in <xref:System.Formats.Asn1?displayProperty=fullName>. | Warning |
| [SYSLIB0032](../../../../fundamentals/syslib-diagnostics/syslib0032.md) | Recovery from corrupted process state exceptions is not supported; <xref:System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptionsAttribute> is ignored. |
| [SYSLIB0033](../../../../fundamentals/syslib-diagnostics/syslib0033.md) | <xref:System.Security.Cryptography.Rfc2898DeriveBytes.CryptDeriveKey(System.String,System.String,System.Int32,System.Byte[])?displayProperty=nameWithType> is obsolete and is not supported. Use <xref:System.Security.Cryptography.PasswordDeriveBytes.CryptDeriveKey(System.String,System.String,System.Int32,System.Byte[])?displayProperty=nameWithType> instead. |
| [SYSLIB0034](../../../../fundamentals/syslib-diagnostics/syslib0034.md) | <xref:System.Security.Cryptography.Pkcs.CmsSigner.%23ctor(System.Security.Cryptography.CspParameters)> is obsolete. Use an alternative constructor instead. |
| [SYSLIB0035](../../../../fundamentals/syslib-diagnostics/syslib0035.md) | <xref:System.Security.Cryptography.Pkcs.SignerInfo.ComputeCounterSignature?displayProperty=nameWithType> is obsolete. Use the overload that accepts a <xref:System.Security.Cryptography.Pkcs.CmsSigner> instead. |
| [SYSLIB0032](../../../../fundamentals/syslib-diagnostics/syslib0032.md) | Recovery from corrupted process state exceptions is not supported; <xref:System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptionsAttribute> is ignored. | Warning |
| [SYSLIB0033](../../../../fundamentals/syslib-diagnostics/syslib0033.md) | <xref:System.Security.Cryptography.Rfc2898DeriveBytes.CryptDeriveKey(System.String,System.String,System.Int32,System.Byte[])?displayProperty=nameWithType> is obsolete and is not supported. Use <xref:System.Security.Cryptography.PasswordDeriveBytes.CryptDeriveKey(System.String,System.String,System.Int32,System.Byte[])?displayProperty=nameWithType> instead. | Warning |
| [SYSLIB0034](../../../../fundamentals/syslib-diagnostics/syslib0034.md) | <xref:System.Security.Cryptography.Pkcs.CmsSigner.%23ctor(System.Security.Cryptography.CspParameters)> is obsolete. Use an alternative constructor instead. | Warning |
| [SYSLIB0035](../../../../fundamentals/syslib-diagnostics/syslib0035.md) | <xref:System.Security.Cryptography.Pkcs.SignerInfo.ComputeCounterSignature?displayProperty=nameWithType> is obsolete. Use the overload that accepts a <xref:System.Security.Cryptography.Pkcs.CmsSigner> instead. | Warning |

## Version introduced

@@ -173,5 +173,6 @@ The following table lists the custom diagnostic IDs and their corresponding warn

## See also

- [API obsoletions with non-default diagnostic IDs (.NET 7)](../7.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)
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)
4 changes: 4 additions & 0 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@ items:
href: 7.0.md
- name: Core .NET libraries
items:
- name: API obsoletions with non-default diagnostic IDs
href: core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md
- name: Validate CompressionLevel for BrotliStream
href: core-libraries/7.0/compressionlevel-validation.md
- name: Serialization
@@ -641,6 +643,8 @@ items:
items:
- name: .NET 7
items:
- name: API obsoletions with non-default diagnostic IDs
href: core-libraries/7.0/obsolete-apis-with-custom-diagnostics.md
- name: Validate CompressionLevel for BrotliStream
href: core-libraries/7.0/compressionlevel-validation.md
- name: .NET 6
6 changes: 4 additions & 2 deletions docs/fundamentals/syslib-diagnostics/obsoletions-overview.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
title: Obsolete features in .NET 5+
titleSuffix: ""
description: Learn about APIs that are marked as obsolete in .NET 5 and later versions that produce SYSLIB compiler warnings.
ms.date: 09/07/2021
ms.date: 01/13/2022
---

# Obsolete features in .NET 5+
@@ -34,7 +34,7 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
| [SYSLIB0011][0011] | Warning | <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter> serialization is obsolete and should not be used. |
| [SYSLIB0012][0012] | Warning | <xref:System.Reflection.Assembly.CodeBase?displayProperty=nameWithType> and <xref:System.Reflection.Assembly.EscapedCodeBase?displayProperty=nameWithType> are only included for .NET Framework compatibility. Use <xref:System.Reflection.Assembly.Location?displayProperty=nameWithType> instead. |
| [SYSLIB0013][0013] | Warning | <xref:System.Uri.EscapeUriString(System.String)?displayProperty=nameWithType> can corrupt the Uri string in some cases. Consider using <xref:System.Uri.EscapeDataString(System.String)?displayProperty=nameWithType> for query string components instead. |
| [SYSLIB0014][0014] | Error | <xref:System.Net.WebRequest>, <xref:System.Net.HttpWebRequest>, <xref:System.Net.ServicePoint>, and <xref:System.Net.WebClient> are obsolete. Use <xref:System.Net.Http.HttpClient> instead. |
| [SYSLIB0014][0014] | Warning | <xref:System.Net.WebRequest>, <xref:System.Net.HttpWebRequest>, <xref:System.Net.ServicePoint>, and <xref:System.Net.WebClient> are obsolete. Use <xref:System.Net.Http.HttpClient> instead. |
| [SYSLIB0015][0015] | Warning | <xref:System.Runtime.CompilerServices.DisablePrivateReflectionAttribute> has no effect in .NET 6+. |
| [SYSLIB0016][0016] | Warning | Use the <xref:System.Drawing.Graphics.GetContextInfo%2A?displayProperty=nameWithType> overloads that accept arguments for better performance and fewer allocations. |
| [SYSLIB0017][0017] | Warning | Strong-name signing is not supported and throws <xref:System.PlatformNotSupportedException>. |
@@ -56,6 +56,7 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
| [SYSLIB0033][0033] | Warning | <xref:System.Security.Cryptography.Rfc2898DeriveBytes.CryptDeriveKey(System.String,System.String,System.Int32,System.Byte[])?displayProperty=nameWithType> is obsolete and is not supported. Use <xref:System.Security.Cryptography.PasswordDeriveBytes.CryptDeriveKey(System.String,System.String,System.Int32,System.Byte[])?displayProperty=nameWithType> instead. |
| [SYSLIB0034][0034] | Warning | <xref:System.Security.Cryptography.Pkcs.CmsSigner.%23ctor(System.Security.Cryptography.CspParameters)> is obsolete. Use an alternative constructor instead. |
| [SYSLIB0035][0035] | Warning | <xref:System.Security.Cryptography.Pkcs.SignerInfo.ComputeCounterSignature?displayProperty=nameWithType> is obsolete. Use the overload that accepts a <xref:System.Security.Cryptography.Pkcs.CmsSigner> instead. |
| [SYSLIB0036][0036] | Warning | <xref:System.Text.RegularExpressions.Regex.CompileToAssembly%2A?displayProperty=nameWithType> is obsolete and not supported. Use `RegexGeneratorAttribute` with the regular expression source generator instead. |

<!-- Include adds ## Suppress warnings (H2 heading) -->
[!INCLUDE [suppress-syslib-warning](includes/suppress-syslib-warning.md)]
@@ -95,3 +96,4 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
[0033]: syslib0033.md
[0034]: syslib0034.md
[0035]: syslib0035.md
[0036]: syslib0036.md
16 changes: 16 additions & 0 deletions docs/fundamentals/syslib-diagnostics/syslib0036.md
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)]
2 changes: 2 additions & 0 deletions docs/fundamentals/toc.yml
Original file line number Diff line number Diff line change
@@ -460,6 +460,8 @@ items:
href: syslib-diagnostics/syslib0034.md
- name: SYSLIB0035
href: syslib-diagnostics/syslib0035.md
- name: SYSLIB0036
href: syslib-diagnostics/syslib0036.md
- name: Source-generated code
items:
- name: Overview

0 comments on commit e9b7f30

Please sign in to comment.