从 .NET 10 开始,某些 API 标记为已过时。 此中断性变更特定于标记为已过时并带有自定义诊断 ID 的 API。 抑制 C# 编译器默认的过时诊断 ID(即 CS0618)并不会抑制编译器在使用这些 API 时生成的警告。
更改描述
在以前的 .NET 版本中,可以使用这些 API,而不会引发任何生成警告。 在 .NET 10 及更高版本中,使用这些 API 会生成编译时警告或错误,并显示自定义诊断 ID。 使用自定义诊断 ID 可以单独消除过时警告,而不是一并消除所有过时警告。
下表列出了已过时 API 的自定义诊断 ID 及其相应的警告消息。
诊断标识符 | 说明 | 严重性 |
---|---|---|
SYSLIB0058 | SslStream 的 KeyExchangeAlgorithm 、KeyExchangeStrength 、CipherAlgorithm 、CipherAlgorithmStrength 、HashAlgorithm 和 HashStrength 属性已过时。 改用 NegotiatedCipherSuite。 |
警告 |
SYSLIB0059 | SystemEvents.EventsThreadShutdown 回调在进程退出前不会被执行。 改用 AppDomain.ProcessExit。 | 警告 |
SYSLIB0060 | System.Security.Cryptography.Rfc2898DeriveBytes 构造函数已过时。 改用 Rfc2898DeriveBytes.Pbkdf2。 | 警告 |
引入的版本
.NET 10
中断性变更的类型
这种过时可能会影响源兼容性。
建议的操作
使用警告上提供的 URL 链接,按照针对每个诊断 ID 提供的特定指南进行操作。
不能使用过时类型或成员的标准诊断 ID 取消有关这些过时类型或成员的警告或错误;请改用自定义
SYSLIBxxxx
诊断 ID 值。
受影响的 API
SYSLIB0058
- System.Net.Security.SslStream.KeyExchangeAlgorithm
- System.Net.Security.SslStream.KeyExchangeStrength
- System.Net.Security.SslStream.CipherAlgorithm
- System.Net.Security.SslStream.CipherStrength
- System.Net.Security.SslStream.HashAlgorithm
- System.Net.Security.SslStream.HashStrength
- System.Security.Authentication.ExchangeAlgorithmType
- System.Security.Authentication.CipherAlgorithmType
- System.Security.Authentication.HashAlgorithmType
SYSLIB0059
SYSLIB0060
- System.Security.Cryptography.Rfc2898DeriveBytes
- System.Security.Cryptography.Rfc2898DeriveBytes.Pbkdf2