Skip to content

Commit

Permalink
Add SYSLIB0052 (#37032)
Browse files Browse the repository at this point in the history
  • Loading branch information
gewarren authored Sep 10, 2023
1 parent 9bc71d8 commit 9977b6b
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Breaking change: .NET 8 obsoletions with custom IDs"
titleSuffix: ""
description: Learn about the .NET 8 breaking change in core .NET libraries where some APIs have been marked as obsolete with a custom diagnostic ID.
ms.date: 06/08/2023
ms.date: 09/08/2023
---
# API obsoletions with non-default diagnostic IDs (.NET 8)

Expand All @@ -16,9 +16,11 @@ The following table lists the custom diagnostic IDs and their corresponding warn

| Diagnostic ID | Description | Severity |
| - | - |
| [SYSLIB0011](../../../../fundamentals/syslib-diagnostics/syslib0011.md) | BinaryFormatter serialization is obsolete | Warning/error |
| [SYSLIB0048](../../../../fundamentals/syslib-diagnostics/syslib0048.md) | <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=nameWithType> and <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=nameWithType> are obsolete. Use <xref:System.Security.Cryptography.RSA.Encrypt%2A?displayProperty=nameWithType> and <xref:System.Security.Cryptography.RSA.Decrypt%2A?displayProperty=nameWithType> instead. | Warning |
| [SYSLIB0050](../../../../fundamentals/syslib-diagnostics/syslib0050.md) | Formatter-based serialization is obsolete and should not be used. | Warning |
| [SYSLIB0051](../../../../fundamentals/syslib-diagnostics/syslib0051.md) | APIs that support obsolete formatter-based serialization are obsolete. They should not be called or extended by application code. | Warning |
| [SYSLIB0052](../../../../fundamentals/syslib-diagnostics/syslib0052.md) | APIs that support obsolete mechanisms for Regex extensibility are obsolete. | Warning |
| [SYSLIB0053](../../../../fundamentals/syslib-diagnostics/syslib0053.md) | <xref:System.Security.Cryptography.AesGcm> should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size. | Warning |

## Version introduced
Expand All @@ -37,6 +39,13 @@ These obsoletions can affect [source compatibility](../../categories.md#source-c

## Affected APIs

### SYSLIB0011

- <xref:System.Resources.Extensions.PreserializedResourceWriter.AddBinaryFormattedResource(System.String,System.Byte[],System.String)?displayProperty=fullName>
- <xref:System.Runtime.Serialization.Formatter?displayProperty=fullName>
- <xref:System.Runtime.Serialization.IFormatter?displayProperty=fullName>
- <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter?displayProperty=fullName>

### SYSLIB0048

- <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=fullName>
Expand Down Expand Up @@ -532,6 +541,15 @@ The `SYSLIB0051` API obsoletions are organized here by namespace.
- <xref:System.Xml.Xsl.XsltException.%23ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)?displayProperty=fullName>
- <xref:System.Xml.Xsl.XsltException.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)?displayProperty=fullName>

### SYSLIB0052

- <xref:System.Text.RegularExpressions.Regex.InitializeReferences?displayProperty=fullName>
- <xref:System.Text.RegularExpressions.Regex.UseOptionC?displayProperty=fullName>
- <xref:System.Text.RegularExpressions.Regex.UseOptionR?displayProperty=fullName>
- <xref:System.Text.RegularExpressions.RegexRunner.CharInSet(System.Char,System.String,System.String)?displayProperty=fullName>
- <xref:System.Text.RegularExpressions.RegexRunner.Scan(System.Text.RegularExpressions.Regex,System.String,System.Int32,System.Int32,System.Int32,System.Int32,System.Boolean)?displayProperty=fullName>
- <xref:System.Text.RegularExpressions.RegexRunner.Scan(System.Text.RegularExpressions.Regex,System.String,System.Int32,System.Int32,System.Int32,System.Int32,System.Boolean,System.TimeSpan)?displayProperty=fullName>

### SYSLIB0053

- <xref:System.Security.Cryptography.AesGcm.%23ctor(System.Byte[])>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
| [SYSLIB0048](syslib0048.md) | Warning | <xref:System.Security.Cryptography.RSA.EncryptValue(System.Byte[])?displayProperty=nameWithType> and <xref:System.Security.Cryptography.RSA.DecryptValue(System.Byte[])?displayProperty=nameWithType> are obsolete. Use <xref:System.Security.Cryptography.RSA.Encrypt%2A?displayProperty=nameWithType> and <xref:System.Security.Cryptography.RSA.Decrypt%2A?displayProperty=nameWithType> instead. |
| [SYSLIB0050](syslib0050.md) | Warning | Formatter-based serialization is obsolete and should not be used. |
| [SYSLIB0051](syslib0051.md) | Warning | APIs that support obsolete formatter-based serialization are obsolete. They should not be called or extended by application code. |
| [SYSLIB0052](syslib0052.md) | Warning | APIs that support obsolete mechanisms for Regex extensibility are obsolete. |
| [SYSLIB0053](syslib0053.md) | Warning | <xref:System.Security.Cryptography.AesGcm> should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size. |

## Suppress warnings
Expand Down
4 changes: 2 additions & 2 deletions docs/fundamentals/syslib-diagnostics/syslib0011.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: SYSLIB0011 warning
description: Learn about the obsoletions that generate compile-time warning SYSLIB0011.
ms.date: 05/08/2023
ms.date: 09/08/2023
---
# SYSLIB0011: BinaryFormatter serialization is obsolete

Expand All @@ -15,7 +15,7 @@ Due to [security vulnerabilities](../../standard/serialization/binaryformatter-s
- <xref:System.Runtime.Serialization.IFormatter.Serialize(System.IO.Stream,System.Object)?displayProperty=nameWithType>
- <xref:System.Runtime.Serialization.IFormatter.Deserialize(System.IO.Stream)?displayProperty=nameWithType>

Starting in .NET 8, <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize%2A?displayProperty=nameWithType> and <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize%2A?displayProperty=nameWithType> throw a <xref:System.NotSupportedException> at run time on most project types. In addition, the following APIs are marked obsolete *as error*:
Starting in .NET 8, <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize%2A?displayProperty=nameWithType> and <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize%2A?displayProperty=nameWithType> throw a <xref:System.NotSupportedException> at run time on most project types. In addition, <xref:System.Resources.Extensions.PreserializedResourceWriter.AddBinaryFormattedResource(System.String,System.Byte[],System.String)?displayProperty=nameWithType> is obsolete *as warning*, and the following APIs are obsolete *as error*:

- <xref:System.Runtime.Serialization.Formatter?displayProperty=fullName>
- <xref:System.Runtime.Serialization.IFormatter?displayProperty=fullName>
Expand Down
49 changes: 49 additions & 0 deletions docs/fundamentals/syslib-diagnostics/syslib0052.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: SYSLIB0052 warning - APIs that support obsolete mechanisms for Regex extensibility are obsolete
description: Learn about the obsoletion of APIs that support obsolete mechanisms for Regex extensibility that generates compile-time warning SYSLIB0052.
ms.date: 09/08/2023
---
# SYSLIB0052: APIs that support obsolete mechanisms for Regex extensibility are obsolete

The following <xref:System.Text.RegularExpressions.Regex> and <xref:System.Text.RegularExpressions.RegexRunner> APIs are obsolete, starting in .NET 8. Calling them in code generates warning `SYSLIB0052` at compile time. These APIs supported the now obsolete <xref:System.Text.RegularExpressions.Regex.CompileToAssembly%2A>.

- <xref:System.Text.RegularExpressions.Regex.InitializeReferences?displayProperty=nameWithType>
- <xref:System.Text.RegularExpressions.Regex.UseOptionC?displayProperty=nameWithType>
- <xref:System.Text.RegularExpressions.Regex.UseOptionR?displayProperty=nameWithType>
- <xref:System.Text.RegularExpressions.RegexRunner.CharInSet(System.Char,System.String,System.String)?displayProperty=nameWithType>
- <xref:System.Text.RegularExpressions.RegexRunner.Scan(System.Text.RegularExpressions.Regex,System.String,System.Int32,System.Int32,System.Int32,System.Int32,System.Boolean)?displayProperty=nameWithType>
- <xref:System.Text.RegularExpressions.RegexRunner.Scan(System.Text.RegularExpressions.Regex,System.String,System.Int32,System.Int32,System.Int32,System.Int32,System.Boolean,System.TimeSpan)?displayProperty=nameWithType>

## Workaround

N/A

## Suppress a warning

If you must use the obsolete APIs, you can suppress the warning in code or in your project file.

To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.

```csharp
// Disable the warning.
#pragma warning disable SYSLIB0052

// Code that uses obsolete API.
// ...
// Re-enable the warning.
#pragma warning restore SYSLIB0052
```

To suppress all the `SYSLIB0052` warnings in your project, add a `<NoWarn>` property to your project file.

```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);SYSLIB0052</NoWarn>
</PropertyGroup>
</Project>
```

For more information, see [Suppress warnings](obsoletions-overview.md#suppress-warnings).
2 changes: 2 additions & 0 deletions docs/navigate/tools-diagnostics/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,8 @@ items:
href: ../../fundamentals/syslib-diagnostics/syslib0050.md
- name: SYSLIB0051
href: ../../fundamentals/syslib-diagnostics/syslib0051.md
- name: SYSLIB0052
href: ../../fundamentals/syslib-diagnostics/syslib0052.md
- name: SYSLIB0053
href: ../../fundamentals/syslib-diagnostics/syslib0053.md
- name: Source-generated code
Expand Down

0 comments on commit 9977b6b

Please sign in to comment.