diff --git a/docs/project/list-of-diagnostics.md b/docs/project/list-of-diagnostics.md index f12b4ef549192..1ac9545c029bb 100644 --- a/docs/project/list-of-diagnostics.md +++ b/docs/project/list-of-diagnostics.md @@ -26,6 +26,11 @@ The acceptance criteria for adding an obsoletion includes: * An MSBuild property can be added to the project's first `` to achieve this easily * Example: `true` * This will need to be specified in both the `src` and `ref` projects +* If the library contains types that are forwarded within a generated shim + * Errors will be received when running `build libs`, with obsoletion errors in `src/libraries/shims/generated` files + * This is resolved by adding the obsoletion's diagnostic id to the `` property for partial facade assemblies + * That property is found in `src/libraries/Directory.Build.targets` + * Search for the "Ignore Obsolete errors within the generated shims that type-forward types" comment and add the appropriate diagnostic id to the comment and the `` property (other SYSLIB diagnostics already exist there) * Apply the `breaking-change` label to the PR that introduces the obsoletion * A bot will automatically apply the `needs-breaking-change-doc-created` label when the `breaking-change` label is detected * Follow up with the breaking change process to communicate and document the breaking change @@ -70,6 +75,7 @@ The PR that reveals the implementation of the `$(NoWarn);nullable $(NoWarn);nullable;CA1052 - $(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017 + SYSLIB0003: Code Access Security (CAS). + SYSLIB0004: Constrained Execution Region (CER). + SYSLIB0017: Strong name signing. + SYSLIB0022: Rijndael types. + --> + $(NoWarn);SYSLIB0003;SYSLIB0004;SYSLIB0015;SYSLIB0017;SYSLIB0022 diff --git a/src/libraries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs b/src/libraries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs index 8d3302158e07b..b7d62f2bf43ac 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs @@ -613,6 +613,7 @@ public static void Pbkdf2(System.ReadOnlySpan password, System.ReadOnlySpa public static byte[] Pbkdf2(string password, byte[] salt, int iterations, System.Security.Cryptography.HashAlgorithmName hashAlgorithm, int outputLength) { throw null; } public override void Reset() { } } + [System.ObsoleteAttribute("The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.", DiagnosticId = "SYSLIB0022", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public abstract partial class Rijndael : System.Security.Cryptography.SymmetricAlgorithm @@ -622,6 +623,7 @@ protected Rijndael() { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")] public static new System.Security.Cryptography.Rijndael? Create(string algName) { throw null; } } + [System.ObsoleteAttribute("The Rijndael and RijndaelManaged types are obsolete. Use Aes instead.", DiagnosticId = "SYSLIB0022", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public sealed partial class RijndaelManaged : System.Security.Cryptography.Rijndael diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/RijndaelImplementation.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/RijndaelImplementation.cs index a91a886ba9fe0..8fa834703033b 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/RijndaelImplementation.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/RijndaelImplementation.cs @@ -13,6 +13,7 @@ namespace Internal.Cryptography /// be consistent with the rest of the static Create() methods which return opaque types. /// They both have the same implementation. /// + [Obsolete(Obsoletions.RijndaelMessage, DiagnosticId = Obsoletions.RijndaelDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] internal sealed class RijndaelImplementation : Rijndael { private readonly Aes _impl; diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj b/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj index 35bf864a44808..5227b2935cb4a 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System.Security.Cryptography.Algorithms.csproj @@ -114,6 +114,8 @@ Link="Internal\Cryptography\UniversalCryptoEncryptor.cs" /> + DefaultNameHT Type HMACSHA256Type = typeof(System.Security.Cryptography.HMACSHA256); Type HMACSHA384Type = typeof(System.Security.Cryptography.HMACSHA384); Type HMACSHA512Type = typeof(System.Security.Cryptography.HMACSHA512); +#pragma warning disable SYSLIB0022 // Rijndael types are obsolete Type RijndaelManagedType = typeof(System.Security.Cryptography.RijndaelManaged); +#pragma warning restore SYSLIB0022 Type AesManagedType = typeof(System.Security.Cryptography.AesManaged); Type SHA256DefaultType = typeof(System.Security.Cryptography.SHA256Managed); Type SHA384DefaultType = typeof(System.Security.Cryptography.SHA384Managed); diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rijndael.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rijndael.cs index ba7d5c57ca4bd..35e3f117cbeb0 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rijndael.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/Rijndael.cs @@ -8,6 +8,7 @@ namespace System.Security.Cryptography { + [Obsolete(Obsoletions.RijndaelMessage, DiagnosticId = Obsoletions.RijndaelDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] [UnsupportedOSPlatform("browser")] public abstract class Rijndael : SymmetricAlgorithm diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RijndaelManaged.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RijndaelManaged.cs index 8eda1cf01026c..2c866a2459f69 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RijndaelManaged.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RijndaelManaged.cs @@ -7,6 +7,7 @@ namespace System.Security.Cryptography { + [Obsolete(Obsoletions.RijndaelMessage, DiagnosticId = Obsoletions.RijndaelDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] [UnsupportedOSPlatform("browser")] public sealed class RijndaelManaged : Rijndael diff --git a/src/libraries/System.Security.Cryptography.Algorithms/tests/CryptoConfigTests.cs b/src/libraries/System.Security.Cryptography.Algorithms/tests/CryptoConfigTests.cs index 26135ced35c6a..245f023acb53e 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/tests/CryptoConfigTests.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/tests/CryptoConfigTests.cs @@ -7,6 +7,8 @@ using Test.Cryptography; using Xunit; +#pragma warning disable SYSLIB0022 // Rijndael types are obsolete + namespace System.Security.Cryptography.CryptoConfigTests { public static class CryptoConfigTests @@ -425,3 +427,5 @@ public ClassWithCtorArguments(string s) } } } + +#pragma warning restore SYSLIB0022 diff --git a/src/libraries/System.Security.Cryptography.Algorithms/tests/RijndaelTests.cs b/src/libraries/System.Security.Cryptography.Algorithms/tests/RijndaelTests.cs index 43243df733520..5613b7b7c48d6 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/tests/RijndaelTests.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/tests/RijndaelTests.cs @@ -5,6 +5,8 @@ using Test.Cryptography; using Xunit; +#pragma warning disable SYSLIB0022 // Rijndael types are obsolete + namespace System.Security.Cryptography.Encryption.Rijndael.Tests { using Rijndael = System.Security.Cryptography.Rijndael; @@ -462,3 +464,5 @@ public override void GenerateKey() } } } + +#pragma warning restore SYSLIB0022 diff --git a/src/libraries/System.Security.Cryptography.Primitives/tests/CryptoConfigTests.cs b/src/libraries/System.Security.Cryptography.Primitives/tests/CryptoConfigTests.cs index dbd140ad5465a..36bb7f85caffc 100644 --- a/src/libraries/System.Security.Cryptography.Primitives/tests/CryptoConfigTests.cs +++ b/src/libraries/System.Security.Cryptography.Primitives/tests/CryptoConfigTests.cs @@ -99,11 +99,13 @@ public static void NamedKeyedHashAlgorithmCreate(string identifier, Type actualT [Theory] [InlineData("AES", typeof(Aes))] +#pragma warning disable SYSLIB0022 // Rijndael types are obsolete [InlineData("Rijndael", typeof(Rijndael))] [InlineData("System.Security.Cryptography.Rijndael", typeof(Rijndael))] [InlineData("http://www.w3.org/2001/04/xmlenc#aes128-cbc", typeof(Rijndael))] [InlineData("http://www.w3.org/2001/04/xmlenc#aes192-cbc", typeof(Rijndael))] [InlineData("http://www.w3.org/2001/04/xmlenc#aes256-cbc", typeof(Rijndael))] +#pragma warning restore SYSLIB0022 [InlineData("3DES", typeof(TripleDES))] [InlineData("TripleDES", typeof(TripleDES))] [InlineData("System.Security.Cryptography.TripleDES", typeof(TripleDES))] diff --git a/src/libraries/System.Security.Cryptography.Xml/tests/TestHelpers.cs b/src/libraries/System.Security.Cryptography.Xml/tests/TestHelpers.cs index c2809ce29d898..c155f554f2cd8 100644 --- a/src/libraries/System.Security.Cryptography.Xml/tests/TestHelpers.cs +++ b/src/libraries/System.Security.Cryptography.Xml/tests/TestHelpers.cs @@ -129,6 +129,7 @@ public static Uri ToUri(string fileName) return new Uri("file://" + (path[0] == '/' ? path : '/' + path)); } +#pragma warning disable SYSLIB0022 // Rijndael types are obsolete /// /// Get specification URL from algorithm implementation /// @@ -159,6 +160,7 @@ public static string GetEncryptionMethodName(SymmetricAlgorithm key, bool keyWra throw new ArgumentException($"The specified algorithm `{key.GetType().FullName}` is not supported for XML Encryption."); } +#pragma warning restore SYSLIB0022 /// /// Lists functions creating symmetric algorithms