.NET 7 以降では、一部の API は古い形式としてマークされています。 この重大な変更は、"カスタム診断 ID" を持つ、古いものとしてマークされている API に固有のものです。 C# コンパイラの CS0618 既定の非推奨診断 ID を抑制しても、これらの API が使用されるときにコンパイラによって生成される警告は抑制されません。
変更の説明
以前のバージョンの .NET では、ビルドの警告なしにこれらの API を使用できます。 .NET 7 以降のバージョンでは、これらの API を使用すると、カスタム診断 ID でコンパイル時の警告またはエラーが生成されます。 カスタム診断 ID を使用すると、すべての旧型式であるという警告を一括抑制する代わりに、旧型式であるという警告を個別に抑制することができます。
次の表に、古い API に対するカスタム診断 ID とそれに対応する警告メッセージを示します。
診断識別子 | 説明 | 深刻さ |
---|---|---|
SYSLIB0036 |
Regex.CompileToAssembly は廃止されており、サポートされていません。 代わりに、正規表現のソースジェネレーターと共に RegexGeneratorAttribute を使用してください。 |
Warnung |
SYSLIB0037 | AssemblyName メンバー HashAlgorithm、ProcessorArchitecture、VersionCompatibility は廃止されており、サポートされていません。 | Warnung |
SYSLIB0038 | SerializationFormat.Binary は廃止されているため、使用しないでください。 | Warnung |
SYSLIB0039 | TLS バージョン 1.0 と 1.1 には既知の脆弱性があり、推奨されていません。 代わりに新しいバージョンの TLS を使用するか、SslProtocols.None を使用して OS の既定値に従います。 | Warnung |
SYSLIB0040 | EncryptionPolicy.NoEncryption と EncryptionPolicy.AllowNoEncryption はセキュリティを大幅に低下させるため、運用環境のコードでは使用しないでください。 | Warnung |
SYSLIB0041 | Rfc2898DeriveBytes コンストラクターの既定のハッシュ アルゴリズムと反復回数は古く、安全ではありません。 ハッシュ アルゴリズムと反復回数を受け入れるコンストラクターを使用します。 | Warnung |
SYSLIB0042 |
ToXmlString および FromXmlString には楕円曲線暗号 (ECC) 型の実装はなく、廃止されています。 公開キー用のExportSubjectPublicKeyInfo や ImportSubjectPublicKeyInfo 、秘密キー用の ExportPkcs8PrivateKey や ImportPkcs8PrivateKey などの標準のインポートおよびエクスポート形式を使用します。 |
Warnung |
SYSLIB0043 | ECDiffieHellmanPublicKey.ToByteArray() および関連付けられたコンストラクターには、すべてのプラットフォームで一貫した相互運用可能な実装がありません。 ECDiffieHellmanPublicKey.ExportSubjectPublicKeyInfo() を代わりに使用します。 | Warnung |
SYSLIB0044 | AssemblyName.CodeBase と AssemblyName.EscapedCodeBase は非推奨になっています。 | Warnung |
SYSLIB0045 | アルゴリズム名を受け入れる暗号化ファクトリ メソッドは廃止されました。 代わりに、アルゴリズムの種類に対してパラメーターなしの Create ファクトリ メソッドを使用します。 |
Warnung |
SYSLIB0047 |
XmlSecureResolver は廃止されています。 代わりに XmlResolver.ThrowingResolver を使用して、外部 XML リソースの解決を禁止します。 |
Warnung |
導入されたバージョン
.NET 7
破壊的変更の種類
これらの廃止は、ソースの互換性に影響を与える可能性があります。
推奨されるアクション
警告に記載されている URL リンクを使用して、各診断 ID に対して指定されているガイダンスに従います。
これらの廃止された機能に関する警告やエラーは、古い型またはメンバー用の標準診断 ID では抑制できません。代わりにカスタム
SYSLIBxxxx
診断 ID 値を使用してください。
影響を受ける API
SYSLIB0036
SYSLIB0037
SYSLIB0038
SYSLIB0039
SYSLIB0040
- System.Net.Security.EncryptionPolicy.AllowNoEncryption
- System.Net.Security.EncryptionPolicy.NoEncryption
SYSLIB0041
- Rfc2898DeriveBytes(String, Byte[])
- Rfc2898DeriveBytes(String, Int32)
- Rfc2898DeriveBytes(Byte[], Byte[], Int32)
- Rfc2898DeriveBytes(String, Byte[], Int32)
- Rfc2898DeriveBytes(String, Int32, Int32)
SYSLIB0042
- System.Security.Cryptography.ECDiffieHellmanCng.FromXmlString(String, ECKeyXmlFormat)
- System.Security.Cryptography.ECDiffieHellmanCng.ToXmlString(ECKeyXmlFormat)
- System.Security.Cryptography.ECDiffieHellmanCngPublicKey.FromXmlString(String)
- System.Security.Cryptography.ECDiffieHellmanCngPublicKey.ToXmlString()
- System.Security.Cryptography.ECDiffieHellmanPublicKey.ToXmlString()
- System.Security.Cryptography.ECDsaCng.FromXmlString(String, ECKeyXmlFormat)
- System.Security.Cryptography.ECDsaCng.ToXmlString(ECKeyXmlFormat)
SYSLIB0043
- System.Security.Cryptography.ECDiffieHellmanPublicKey.ToByteArray()
- ECDiffieHellmanPublicKey(Byte[])
SYSLIB0045
- System.Security.Cryptography.Aes.Create(String)
- System.Security.Cryptography.AsymmetricAlgorithm.Create(String)
- System.Security.Cryptography.DES.Create(String)
- System.Security.Cryptography.ECDiffieHellman.Create(String)
- System.Security.Cryptography.ECDsa.Create(String)
- System.Security.Cryptography.HashAlgorithm.Create(String)
- System.Security.Cryptography.KeyedHashAlgorithm.Create(String)
- System.Security.Cryptography.RandomNumberGenerator.Create(String)
- System.Security.Cryptography.RC2.Create(String)
- System.Security.Cryptography.Rijndael.Create(String)
- System.Security.Cryptography.RSA.Create(String)
- System.Security.Cryptography.SHA1.Create(String)
- System.Security.Cryptography.SHA256.Create(String)
- System.Security.Cryptography.SHA384.Create(String)
- System.Security.Cryptography.SHA512.Create(String)
- System.Security.Cryptography.SymmetricAlgorithm.Create(String)
- System.Security.Cryptography.TripleDES.Create(String)
SYSLIB0047
こちらも参照ください
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET