Skip to content
Open
1 change: 1 addition & 0 deletions docs/core/compatibility/11.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ See [Breaking changes in ASP.NET Core 11](/aspnet/core/breaking-changes/11/overv

| Title | Type of change |
|----------------------------------------------------------------|-------------------|
| [API obsoletions](cryptography/11/obsolete-apis.md) | Source incompatible |
| [DSA removed from macOS](cryptography/11/dsa-removed-macos.md) | Behavioral change |

<!--
Expand Down
6 changes: 4 additions & 2 deletions docs/core/compatibility/core-libraries/11/obsolete-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
title: "Breaking change: .NET 11 obsoletions with custom IDs"
titleSuffix: ""
description: Learn about the APIs that have been marked as obsolete in .NET 11 with a custom diagnostic ID.
ms.date: 04/03/2026
ms.date: 07/06/2026
ai-usage: ai-assisted
---
# API obsoletions with non-default diagnostic IDs (.NET 11)

Some APIs have been marked as obsolete, starting in .NET 11.
Some APIs are marked as obsolete, starting in .NET 11.

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.

Expand Down Expand Up @@ -43,6 +44,7 @@ These obsoletions can affect [source compatibility](../../categories.md#source-c

## See also

- [Cryptography obsoletions (.NET 11)](../../cryptography/11/obsolete-apis.md)
- [API obsoletions with non-default diagnostic IDs (.NET 10)](../10.0/obsolete-apis.md)
- [API obsoletions with non-default diagnostic IDs (.NET 9)](../9.0/obsolete-apis-with-custom-diagnostics.md)
- [API obsoletions with non-default diagnostic IDs (.NET 8)](../8.0/obsolete-apis-with-custom-diagnostics.md)
Expand Down
49 changes: 49 additions & 0 deletions docs/core/compatibility/cryptography/11/obsolete-apis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "Breaking change: .NET 11 obsoletions in cryptography"
titleSuffix: ""
description: Learn about the cryptography APIs that have been marked as obsolete in .NET 11.
ms.date: 07/06/2026
ai-usage: ai-assisted
---
# Cryptography obsoletions (.NET 11)

Some cryptography APIs are marked as obsolete, starting in .NET 11.

For obsoletions in other core .NET library areas, see [API obsoletions with non-default diagnostic IDs (.NET 11)](../../core-libraries/11/obsolete-apis.md).

## Previous behavior

Previously, you could use these APIs without any compile-time warnings about obsoletion.

## New behavior

In .NET 11 and later versions, using these APIs produces a compile-time diagnostic.

The following table lists the custom diagnostic IDs and their corresponding warning messages.

| Diagnostic ID | Description | Severity |
|---------------|-------------|----------|
| [SYSLIB0065](../../../../fundamentals/syslib-diagnostics/syslib0065.md) | The `set` accessor of <xref:System.Security.Cryptography.AsnEncodedData.RawData?displayProperty=nameWithType> is obsolete. Use the constructor of the appropriate type to decode data, or use <xref:System.Security.Cryptography.AsnEncodedData.CopyFrom(System.Security.Cryptography.AsnEncodedData)?displayProperty=nameWithType> for mutable scenarios. | Warning |

## Version introduced

.NET 11 Preview 6

## Type of breaking change

These obsoletions can affect [source compatibility](../../categories.md#source-compatibility).

## Recommended action

If you must keep use the obsolete APIs, suppress the warning by using the custom diagnostic ID.

## Affected APIs

### SYSLIB0065

- `set` accessor of <xref:System.Security.Cryptography.AsnEncodedData.RawData?displayProperty=fullName>

## See also

- [SYSLIB0065: AsnEncodedData.RawData setter is obsolete](../../../../fundamentals/syslib-diagnostics/syslib0065.md)
- [API obsoletions with non-default diagnostic IDs (.NET 11)](../../core-libraries/11/obsolete-apis.md)
2 changes: 2 additions & 0 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ items:
href: core-libraries/11/ziparchive-createasync-eager-load.md
- name: Cryptography
items:
- name: API obsoletions
href: cryptography/11/obsolete-apis.md
- name: DSA removed from macOS
href: cryptography/11/dsa-removed-macos.md
- name: Extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ The following table lists the `SYSLIB0XXX` obsoletions in .NET 5+.
| [SYSLIB0061](syslib0061.md) | Warning | The `Queryable` <xref:System.Linq.Queryable.MaxBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=nameWithType> and <xref:System.Linq.Queryable.MinBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=nameWithType> taking an `IComparer<TSource>` are obsolete. Use the new ones that take an `IComparer<TKey>`. |
| [SYSLIB0062](syslib0062.md) | Warning | <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> is obsolete. |
| [SYSLIB0064](syslib0064.md) | Warning | <xref:System.Security.Cryptography.RSACryptoServiceProvider.Encrypt(System.Byte[],System.Boolean)?displayProperty=nameWithType> and <xref:System.Security.Cryptography.RSACryptoServiceProvider.Decrypt(System.Byte[],System.Boolean)?displayProperty=nameWithType> are obsolete. Use the overloads that accept an <xref:System.Security.Cryptography.RSAEncryptionPadding> instead. |
| [SYSLIB0065](syslib0065.md) | Warning | The `set` accessor of <xref:System.Security.Cryptography.AsnEncodedData.RawData?displayProperty=nameWithType> is obsolete. Use the constructor of the appropriate type to decode data, or use <xref:System.Security.Cryptography.AsnEncodedData.CopyFrom(System.Security.Cryptography.AsnEncodedData)?displayProperty=nameWithType> for mutable scenarios. |

## EXTOBS obsoletions

Expand Down
73 changes: 73 additions & 0 deletions docs/fundamentals/syslib-diagnostics/syslib0065.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: SYSLIB0065 warning - AsnEncodedData.RawData setter is obsolete
description: Learn about the obsoletion of the AsnEncodedData.RawData property setter. Use of this setter generates compile-time warning SYSLIB0065.
ms.date: 07/05/2026
ai-usage: ai-assisted
f1_keywords:
- SYSLIB0065
---

# SYSLIB0065: AsnEncodedData.RawData setter is obsolete

Starting in .NET 11, the `set` accessor of <xref:System.Security.Cryptography.AsnEncodedData.RawData?displayProperty=nameWithType> is obsolete. Setting this property in code generates warning `SYSLIB0065` at compile time.

## Reason for obsoletion

<xref:System.Security.Cryptography.AsnEncodedData> represents an ASN.1-encoded object. Many types derive from it, such as <xref:System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension>, and cache their decoded representation so that property access doesn't repeatedly decode the ASN.1.

Because `RawData` is not `virtual`, setting it on a derived instance causes a discrepancy between the cached decoded state and the new raw data. The derived type can't detect that the raw data changed, so it continues to return stale decoded values. For example:

```csharp
X509BasicConstraintsExtension extension = new(
certificateAuthority: true,
hasPathLengthConstraint: true,
pathLengthConstraint: 3,
critical: true);

X509BasicConstraintsExtension decoded = new();
decoded.RawData = extension.RawData;
Console.WriteLine(decoded.CertificateAuthority); // Unexpectedly prints False
Console.WriteLine(decoded.HasPathLengthConstraint); // Unexpectedly prints False
Console.WriteLine(decoded.PathLengthConstraint); // Unexpectedly prints 0
```

## Workaround

To maintain coherency between the decoded state and the underlying data, use the constructor of the appropriate type to decode data. Treat instances as read-only—construct a new instance instead of reusing an existing one.

```csharp
// Instead of setting RawData, use the constructor.
X509BasicConstraintsExtension decoded = new(extension, extension.Critical);
```

If you need mutable behavior, use <xref:System.Security.Cryptography.AsnEncodedData.CopyFrom(System.Security.Cryptography.AsnEncodedData)?displayProperty=nameWithType>. The `CopyFrom` method is `virtual`, so derived types can invalidate their decoded state when the raw data changes.

## Suppress a warning

If you must use the obsolete setter, 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 SYSLIB0065

// Code that uses obsolete API.
// ...

// Re-enable the warning.
#pragma warning restore SYSLIB0065
```

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

```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);SYSLIB0065</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 @@ -4093,6 +4093,8 @@ items:
href: ../../fundamentals/syslib-diagnostics/syslib0062.md
- name: SYSLIB0064
href: ../../fundamentals/syslib-diagnostics/syslib0064.md
- name: SYSLIB0065
href: ../../fundamentals/syslib-diagnostics/syslib0065.md
- name: Experimental features
items:
- name: Overview
Expand Down
Loading