diff options
author | Atsushi Kanamori <AtsushiKan@users.noreply.github.com> | 2017-04-21 17:36:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-21 17:36:28 +0300 |
commit | 1c93edd06b5bad60532cc884d1c793892eaf15da (patch) | |
tree | 286ae2e14c8e7a18e6003684b54dfb0c3aed488f /src | |
parent | dd90c678e4e715fcf19935b5338a4000bb84561f (diff) |
Fix System.Security.Cryptography.Pkcs failures on Uap/Aot (#18727)
Diffstat (limited to 'src')
5 files changed, 43 insertions, 11 deletions
diff --git a/src/Common/tests/System/PlatformDetection.cs b/src/Common/tests/System/PlatformDetection.cs index 9151013149..d261e9545f 100644 --- a/src/Common/tests/System/PlatformDetection.cs +++ b/src/Common/tests/System/PlatformDetection.cs @@ -324,5 +324,28 @@ namespace System public static extern int GetCurrentApplicationUserModelId( ref uint applicationUserModelIdLength, byte[] applicationUserModelId); + + public static bool IsNonZeroLowerBoundArraySupported + { + get + { + if (s_lazyNonZeroLowerBoundArraySupported == null) + { + bool nonZeroLowerBoundArraysSupported = false; + try + { + Array.CreateInstance(typeof(int), new int[] { 5 }, new int[] { 5 }); + nonZeroLowerBoundArraysSupported = true; + } + catch (PlatformNotSupportedException) + { + } + s_lazyNonZeroLowerBoundArraySupported = Tuple.Create<bool>(nonZeroLowerBoundArraysSupported); + } + return s_lazyNonZeroLowerBoundArraySupported.Item1; + } + } + + private static volatile Tuple<bool> s_lazyNonZeroLowerBoundArraySupported; } } diff --git a/src/System.Security.Cryptography.Pkcs/tests/CmsRecipientCollectionTests.cs b/src/System.Security.Cryptography.Pkcs/tests/CmsRecipientCollectionTests.cs index 7a06cbf40a..ee3f7e5d0c 100644 --- a/src/System.Security.Cryptography.Pkcs/tests/CmsRecipientCollectionTests.cs +++ b/src/System.Security.Cryptography.Pkcs/tests/CmsRecipientCollectionTests.cs @@ -170,9 +170,12 @@ namespace System.Security.Cryptography.Pkcs.Tests Assert.Throws<ArgumentException>(() => ic.CopyTo(new CmsRecipient[2, 2], 1)); Assert.Throws<InvalidCastException>(() => ic.CopyTo(new int[10], 1)); - // Array has non-zero lower bound - Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 }); - Assert.Throws<IndexOutOfRangeException>(() => ic.CopyTo(array, 0)); + if (PlatformDetection.IsNonZeroLowerBoundArraySupported) + { + // Array has non-zero lower bound + Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 }); + Assert.Throws<IndexOutOfRangeException>(() => ic.CopyTo(array, 0)); + } } diff --git a/src/System.Security.Cryptography.Pkcs/tests/CryptographicAttributeObjectCollectionTests.cs b/src/System.Security.Cryptography.Pkcs/tests/CryptographicAttributeObjectCollectionTests.cs index 8c87969c8c..c33bcdacd7 100644 --- a/src/System.Security.Cryptography.Pkcs/tests/CryptographicAttributeObjectCollectionTests.cs +++ b/src/System.Security.Cryptography.Pkcs/tests/CryptographicAttributeObjectCollectionTests.cs @@ -162,9 +162,12 @@ namespace System.Security.Cryptography.Pkcs.Tests Assert.Throws<ArgumentException>(() => ic.CopyTo(new CryptographicAttributeObject[2, 2], 0)); Assert.Throws<InvalidCastException>(() => ic.CopyTo(new int[10], 0)); - // Array has non-zero lower bound - Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 }); - Assert.Throws<IndexOutOfRangeException>(() => ic.CopyTo(array, 0)); + if (PlatformDetection.IsNonZeroLowerBoundArraySupported) + { + // Array has non-zero lower bound + Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 }); + Assert.Throws<IndexOutOfRangeException>(() => ic.CopyTo(array, 0)); + } } private static void AssertEquals(CryptographicAttributeObjectCollection c, IList<CryptographicAttributeObject> expected) diff --git a/src/System.Security.Cryptography.Pkcs/tests/EnvelopedCms/StateTests.cs b/src/System.Security.Cryptography.Pkcs/tests/EnvelopedCms/StateTests.cs index 164f95dd3d..a152397245 100644 --- a/src/System.Security.Cryptography.Pkcs/tests/EnvelopedCms/StateTests.cs +++ b/src/System.Security.Cryptography.Pkcs/tests/EnvelopedCms/StateTests.cs @@ -203,7 +203,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp | TargetFrameworkMonikers.Uap)] + [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)] public static void PostDecode_Encode_net46() { PostDecode_Encode(isRunningOnDesktop: true); @@ -238,7 +238,7 @@ namespace System.Security.Cryptography.Pkcs.EnvelopedCmsTests.Tests } [Fact] - [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp | TargetFrameworkMonikers.Uap)] + [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)] public static void PostDecode_ContentInfo_net46() { PostDecode_ContentInfo(isRunningOnDesktop: true); diff --git a/src/System.Security.Cryptography.Pkcs/tests/RecipientInfoCollectionTests.cs b/src/System.Security.Cryptography.Pkcs/tests/RecipientInfoCollectionTests.cs index 5e95644d71..7b7be6e3b9 100644 --- a/src/System.Security.Cryptography.Pkcs/tests/RecipientInfoCollectionTests.cs +++ b/src/System.Security.Cryptography.Pkcs/tests/RecipientInfoCollectionTests.cs @@ -140,9 +140,12 @@ namespace System.Security.Cryptography.Pkcs.Tests Assert.Throws<ArgumentOutOfRangeException>(() => col.CopyTo(recipients, -1)); Assert.Throws<ArgumentOutOfRangeException>(() => col.CopyTo(recipients, 6)); - // Array has non-zero lower bound - Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 }); - Assert.Throws<IndexOutOfRangeException>(() => col.CopyTo(array, 0)); + if (PlatformDetection.IsNonZeroLowerBoundArraySupported) + { + // Array has non-zero lower bound + Array array = Array.CreateInstance(typeof(object), new int[] { 10 }, new int[] { 10 }); + Assert.Throws<IndexOutOfRangeException>(() => col.CopyTo(array, 0)); + } } |