Skip to content

Commit

Permalink
Add new syslib warnings (#23915)
Browse files Browse the repository at this point in the history
  • Loading branch information
gewarren authored Apr 26, 2021
1 parent 04c3392 commit f18277a
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/core/compatibility/syslib-obsoletions.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: Obsolete features in .NET 5+
description: Learn about APIs that are marked as obsolete in .NET 5 and later versions that produce SYSLIB compiler warnings.
ms.date: 10/20/2020
ms.date: 04/23/2021
---
# Obsolete features in .NET 5
# Obsolete features in .NET 5+

Starting in .NET 5, some APIs that are newly marked as obsolete make use of two new properties on <xref:System.ObsoleteAttribute>.

Expand Down Expand Up @@ -31,6 +31,12 @@ The following table provides an index to the `SYSLIBxxxx` obsoletions in .NET 5+
| [SYSLIB0010](syslib-warnings/syslib0010.md) | Some remoting APIs are not supported and throw <xref:System.PlatformNotSupportedException>. |
| [SYSLIB0011](syslib-warnings/syslib0011.md) | <xref:System.Runtime.Serialization.Formatters.Binary.BinaryFormatter> serialization is obsolete and should not be used. |
| [SYSLIB0012](syslib-warnings/syslib0012.md) | <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](syslib-warnings/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. |
| [SYSLIB0014](syslib-warnings/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. |
| [SYSLIB0015](syslib-warnings/syslib0015.md) | <xref:System.Runtime.CompilerServices.DisablePrivateReflectionAttribute> has no effect in .NET 6+ applications. |
| [SYSLIB0016](syslib-warnings/syslib0016.md) | Use the <xref:System.Drawing.Graphics.GetContextInfo%2A?displayProperty=nameWithType> overloads that accept arguments for better performance and fewer allocations. |
| [SYSLIB0019](syslib-warnings/syslib0019.md) | The <xref:System.Runtime.InteropServices.RuntimeEnvironment?displayProperty=nameWithType> members <xref:System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFile>, <xref:System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr(System.Guid,System.Guid)>, and <xref:System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject(System.Guid,System.Guid)> are no longer supported and throw <xref:System.PlatformNotSupportedException>. |
| [SYSLIB0020](syslib-warnings/syslib0020.md) | <xref:System.Text.Json.JsonSerializerOptions.IgnoreNullValues?displayProperty=nameWithType> is obsolete. To ignore null values when serializing, set <xref:System.Text.Json.JsonSerializerOptions.DefaultIgnoreCondition> to <xref:System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull?displayProperty=nameWithType>. |

## Suppress warnings

Expand Down
19 changes: 19 additions & 0 deletions docs/core/compatibility/syslib-warnings/syslib0013.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: SYSLIB0013 warning
description: Learn about the EscapeUriString obsoletion that generates compile-time warning SYSLIB0013.
ms.topic: reference
ms.date: 04/24/2021
---
# SYSLIB0013: EscapeUriString is obsolete

The <xref:System.Uri.EscapeUriString(System.String)?displayProperty=nameWithType> API is marked as obsolete, starting in .NET 6. Using it in code generates warning `SYSLIB0013` at compile time.

<xref:System.Uri.EscapeUriString(System.String)?displayProperty=nameWithType> can corrupt the Uri string in some cases.

For more information, see <https://github.com/dotnet/runtime/issues/31387>.

## Workarounds

Use <xref:System.Uri.EscapeDataString(System.String)?displayProperty=nameWithType> for query string components instead.

[!INCLUDE [suppress-syslib-warning](../../../../includes/suppress-syslib-warning.md)]
24 changes: 24 additions & 0 deletions docs/core/compatibility/syslib-warnings/syslib0014.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: SYSLIB0014 warning
description: Learn about the System.Net obsoletions that generate compile-time warning SYSLIB0014.
ms.topic: reference
ms.date: 04/24/2021
---
# SYSLIB0014: WebRequest, HttpWebRequest, ServicePoint, WebClient are obsolete

The following APIs are marked as obsolete, starting in .NET 6. Using them in code generates warning `SYSLIB0014` at compile time.

- <xref:System.Net.WebRequest?displayProperty=fullName>
- <xref:System.Net.HttpWebRequest?displayProperty=fullName>
- <xref:System.Net.ServicePoint?displayProperty=fullName>
- <xref:System.Net.WebClient?displayProperty=fullName>

## Workarounds

Use <xref:System.Net.Http.HttpClient> instead.

[!INCLUDE [suppress-syslib-warning](../../../../includes/suppress-syslib-warning.md)]

## See also

- [WebRequest, WebClient, and ServicePoint are obsolete](../networking/6.0/webrequest-deprecated.md)
17 changes: 17 additions & 0 deletions docs/core/compatibility/syslib-warnings/syslib0015.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: SYSLIB0015 warning
description: Learn about the obsoletion of DisablePrivateReflectionAttribute that generates compile-time warning SYSLIB0015.
ms.topic: reference
ms.date: 04/24/2021
---
# SYSLIB0015: DisablePrivateReflectionAttribute is obsolete

Starting in .NET 6, the <xref:System.Runtime.CompilerServices.DisablePrivateReflectionAttribute?displayProperty=nameWithType> type is marked as obsolete. This attribute has no effect in .NET Core 2.1 and later apps. Using it in code generates warning `SYSLIB0015` at compile time for .NET 6 and later apps.

For more information, see <https://github.com/dotnet/runtime/issues/11811>.

## Workarounds

None.

[!INCLUDE [suppress-syslib-warning](../../../../includes/suppress-syslib-warning.md)]
17 changes: 17 additions & 0 deletions docs/core/compatibility/syslib-warnings/syslib0016.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: SYSLIB0016 warning
description: Learn about the GetContextInfo obsoletion that generates compile-time warning SYSLIB0016.
ms.topic: reference
ms.date: 04/24/2021
---
# SYSLIB0016: GetContextInfo() is obsolete

The <xref:System.Drawing.Graphics.GetContextInfo?displayProperty=nameWithType> method that takes no arguments is marked as obsolete, starting in .NET 6. Using it in code generates warning `SYSLIB0016` at compile time.

For more information, see <https://github.com/dotnet/runtime/issues/47880>.

## Workarounds

For better performance and fewer allocations, use the <xref:System.Drawing.Graphics.GetContextInfo%2A?displayProperty=nameWithType> overloads that accept arguments.

[!INCLUDE [suppress-syslib-warning](../../../../includes/suppress-syslib-warning.md)]
21 changes: 21 additions & 0 deletions docs/core/compatibility/syslib-warnings/syslib0019.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: SYSLIB0019 warning
description: Learn about the RuntimeEnvironment obsoletions that generate compile-time warning SYSLIB0019.
ms.topic: reference
ms.date: 04/24/2021
---
# SYSLIB0019: Some RuntimeEnvironment APIs are obsolete

The following APIs are marked as obsolete, starting in .NET 6. Using them in code generates warning `SYSLIB0019` at compile time.

- <xref:System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFile?displayProperty=nameWithType> property
- <xref:System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr(System.Guid,System.Guid)?displayProperty=nameWithType> method
- <xref:System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject(System.Guid,System.Guid)?displayProperty=nameWithType> method

These APIs always throw a <xref:System.PlatformNotSupportedException> at run time.

## Workarounds

None.

[!INCLUDE [suppress-syslib-warning](../../../../includes/suppress-syslib-warning.md)]
15 changes: 15 additions & 0 deletions docs/core/compatibility/syslib-warnings/syslib0020.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: SYSLIB0020 warning
description: Learn about the IgnoreNullValues obsoletion that generates compile-time warning SYSLIB0020.
ms.topic: reference
ms.date: 04/24/2021
---
# SYSLIB0020: IgnoreNullValues is obsolete

The <xref:System.Text.Json.JsonSerializerOptions.IgnoreNullValues?displayProperty=nameWithType> property is marked as obsolete, starting in .NET 6. Using it in code generates warning `SYSLIB0020` at compile time.

## Workarounds

To ignore null values when serializing, set <xref:System.Text.Json.JsonSerializerOptions.DefaultIgnoreCondition> to <xref:System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull?displayProperty=nameWithType>. For more information, see <https://github.com/dotnet/runtime/issues/39152>.

[!INCLUDE [suppress-syslib-warning](../../../../includes/suppress-syslib-warning.md)]
12 changes: 12 additions & 0 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -730,3 +730,15 @@ items:
href: syslib-warnings/syslib0011.md
- name: SYSLIB0012
href: syslib-warnings/syslib0012.md
- name: SYSLIB0013
href: syslib-warnings/syslib0013.md
- name: SYSLIB0014
href: syslib-warnings/syslib0014.md
- name: SYSLIB0015
href: syslib-warnings/syslib0015.md
- name: SYSLIB0016
href: syslib-warnings/syslib0016.md
- name: SYSLIB0019
href: syslib-warnings/syslib0019.md
- name: SYSLIB0020
href: syslib-warnings/syslib0020.md

0 comments on commit f18277a

Please sign in to comment.