repo_name
stringclasses
6 values
pr_number
int64
512
78.9k
pr_title
stringlengths
3
144
pr_description
stringlengths
0
30.3k
author
stringlengths
2
21
date_created
timestamp[ns, tz=UTC]
date_merged
timestamp[ns, tz=UTC]
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
17
30.4k
filepath
stringlengths
9
210
before_content
stringlengths
0
112M
after_content
stringlengths
0
112M
label
int64
-1
1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintController.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Drawing.Printing { public abstract partial class PrintController { protected PrintController() { } public virtual bool IsPreview => false; /// <summary> /// When overridden in a derived class, begins the control sequence of when and how to print a page in a document. /// </summary> public virtual Graphics? OnStartPage(PrintDocument document, PrintPageEventArgs e) { return null; } /// <summary> /// When overridden in a derived class, completes the control sequence of when and how to print a page in a document. /// </summary> public virtual void OnEndPage(PrintDocument document, PrintPageEventArgs e) { } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Drawing.Printing { public abstract partial class PrintController { protected PrintController() { } public virtual bool IsPreview => false; /// <summary> /// When overridden in a derived class, begins the control sequence of when and how to print a page in a document. /// </summary> public virtual Graphics? OnStartPage(PrintDocument document, PrintPageEventArgs e) { return null; } /// <summary> /// When overridden in a derived class, completes the control sequence of when and how to print a page in a document. /// </summary> public virtual void OnEndPage(PrintDocument document, PrintPageEventArgs e) { } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Directed/coverage/oldtests/switchdefaultonly1.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern legacy library mscorlib {} .assembly extern xunit.core {} .assembly extern System.Console { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:0:0:0 } .assembly switchdefaultonly1 {} .class private auto ansi beforefieldinit switchdefaultonly1 extends [mscorlib]System.Object { .method private hidebysig static int32 Main(string[] args) cil managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint // Code size 49 (0x31) .maxstack 2 .locals init (int32 V_0) IL_0000: ldarg.0 IL_0001: ldlen IL_0002: conv.i4 IL_0003: stloc.0 IL_0004: ldloc.0 IL_0005: ldc.i4.1 IL_0006: sub IL_0007: switch (IL_0014) IL_0014: br.s IL_0026 IL_0026: ldarg.0 IL_0027: ldlen IL_0028: conv.i4 IL_0029: call void [System.Console]System.Console::WriteLine(int32) IL_002e: br.s IL_0030 IL_0030: ldc.i4 100 ret } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern legacy library mscorlib {} .assembly extern xunit.core {} .assembly extern System.Console { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:0:0:0 } .assembly switchdefaultonly1 {} .class private auto ansi beforefieldinit switchdefaultonly1 extends [mscorlib]System.Object { .method private hidebysig static int32 Main(string[] args) cil managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint // Code size 49 (0x31) .maxstack 2 .locals init (int32 V_0) IL_0000: ldarg.0 IL_0001: ldlen IL_0002: conv.i4 IL_0003: stloc.0 IL_0004: ldloc.0 IL_0005: ldc.i4.1 IL_0006: sub IL_0007: switch (IL_0014) IL_0014: br.s IL_0026 IL_0026: ldarg.0 IL_0027: ldlen IL_0028: conv.i4 IL_0029: call void [System.Console]System.Console::WriteLine(int32) IL_002e: br.s IL_0030 IL_0030: ldc.i4 100 ret } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Regression/VS-ia64-JIT/V1.2-M01/b10789/b10789.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="switch.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="switch.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Private.CoreLib/src/System/ISpanFormattable.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System { /// <summary>Provides functionality to format the string representation of an object into a span.</summary> public interface ISpanFormattable : IFormattable { /// <summary>Tries to format the value of the current instance into the provided span of characters.</summary> /// <param name="destination">When this method returns, this instance's value formatted as a span of characters.</param> /// <param name="charsWritten">When this method returns, the number of characters that were written in <paramref name="destination"/>.</param> /// <param name="format">A span containing the characters that represent a standard or custom format string that defines the acceptable format for <paramref name="destination"/>.</param> /// <param name="provider">An optional object that supplies culture-specific formatting information for <paramref name="destination"/>.</param> /// <returns><see langword="true"/> if the formatting was successful; otherwise, <see langword="false"/>.</returns> /// <remarks> /// An implementation of this interface should produce the same string of characters as an implementation of <see cref="IFormattable.ToString(string?, IFormatProvider?)"/> /// on the same type. /// TryFormat should return false only if there is not enough space in the destination buffer. Any other failures should throw an exception. /// </remarks> bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System { /// <summary>Provides functionality to format the string representation of an object into a span.</summary> public interface ISpanFormattable : IFormattable { /// <summary>Tries to format the value of the current instance into the provided span of characters.</summary> /// <param name="destination">When this method returns, this instance's value formatted as a span of characters.</param> /// <param name="charsWritten">When this method returns, the number of characters that were written in <paramref name="destination"/>.</param> /// <param name="format">A span containing the characters that represent a standard or custom format string that defines the acceptable format for <paramref name="destination"/>.</param> /// <param name="provider">An optional object that supplies culture-specific formatting information for <paramref name="destination"/>.</param> /// <returns><see langword="true"/> if the formatting was successful; otherwise, <see langword="false"/>.</returns> /// <remarks> /// An implementation of this interface should produce the same string of characters as an implementation of <see cref="IFormattable.ToString(string?, IFormatProvider?)"/> /// on the same type. /// TryFormat should return false only if there is not enough space in the destination buffer. Any other failures should throw an exception. /// </remarks> bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider); } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/coreclr/inc/iallocator.h
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // We would like to allow "util" collection classes to be usable both // from the VM and from the JIT. The latter case presents a // difficulty, because in the (x86, soon to be cross-platform) JIT // compiler, we require allocation to be done using a "no-release" // (aka, arena-style) allocator that is provided as methods of the // JIT's Compiler type. // To allow utilcode collection classes to deal with this, they may be // written to do allocation and freeing via an instance of the // "IAllocator" class defined in this file. // #ifndef _IALLOCATOR_DEFINED_ #define _IALLOCATOR_DEFINED_ #include "contract.h" #include "safemath.h" class IAllocator { public: virtual void* Alloc(size_t sz) = 0; // Allocate space for an array of "elems" elements, each of size "elemSize". virtual void* ArrayAlloc(size_t elems, size_t elemSize) = 0; virtual void Free(void* p) = 0; }; // This class wraps an allocator that does not allow zero-length allocations, // producing one that does (every zero-length allocation produces a pointer to the same // statically-allocated memory, and freeing that pointer is a no-op). class AllowZeroAllocator: public IAllocator { int m_zeroLenAllocTarg; IAllocator* m_alloc; public: AllowZeroAllocator(IAllocator* alloc) : m_alloc(alloc) {} void* Alloc(size_t sz) { if (sz == 0) { return (void*)(&m_zeroLenAllocTarg); } else { return m_alloc->Alloc(sz); } } void* ArrayAlloc(size_t elemSize, size_t numElems) { if (elemSize == 0 || numElems == 0) { return (void*)(&m_zeroLenAllocTarg); } else { return m_alloc->ArrayAlloc(elemSize, numElems); } } virtual void Free(void * p) { if (p != (void*)(&m_zeroLenAllocTarg)) { m_alloc->Free(p); } } }; #endif // _IALLOCATOR_DEFINED_
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // We would like to allow "util" collection classes to be usable both // from the VM and from the JIT. The latter case presents a // difficulty, because in the (x86, soon to be cross-platform) JIT // compiler, we require allocation to be done using a "no-release" // (aka, arena-style) allocator that is provided as methods of the // JIT's Compiler type. // To allow utilcode collection classes to deal with this, they may be // written to do allocation and freeing via an instance of the // "IAllocator" class defined in this file. // #ifndef _IALLOCATOR_DEFINED_ #define _IALLOCATOR_DEFINED_ #include "contract.h" #include "safemath.h" class IAllocator { public: virtual void* Alloc(size_t sz) = 0; // Allocate space for an array of "elems" elements, each of size "elemSize". virtual void* ArrayAlloc(size_t elems, size_t elemSize) = 0; virtual void Free(void* p) = 0; }; // This class wraps an allocator that does not allow zero-length allocations, // producing one that does (every zero-length allocation produces a pointer to the same // statically-allocated memory, and freeing that pointer is a no-op). class AllowZeroAllocator: public IAllocator { int m_zeroLenAllocTarg; IAllocator* m_alloc; public: AllowZeroAllocator(IAllocator* alloc) : m_alloc(alloc) {} void* Alloc(size_t sz) { if (sz == 0) { return (void*)(&m_zeroLenAllocTarg); } else { return m_alloc->Alloc(sz); } } void* ArrayAlloc(size_t elemSize, size_t numElems) { if (elemSize == 0 || numElems == 0) { return (void*)(&m_zeroLenAllocTarg); } else { return m_alloc->ArrayAlloc(elemSize, numElems); } } virtual void Free(void * p) { if (p != (void*)(&m_zeroLenAllocTarg)) { m_alloc->Free(p); } } }; #endif // _IALLOCATOR_DEFINED_
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Security.Cryptography/tests/HKDFTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using Test.Cryptography; using Xunit; namespace System.Security.Cryptography.Tests { [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")] public abstract class HKDFTests { protected abstract byte[] Extract(HashAlgorithmName hash, int prkLength, byte[] ikm, byte[] salt); protected abstract byte[] Expand(HashAlgorithmName hash, byte[] prk, int outputLength, byte[] info); protected abstract byte[] DeriveKey(HashAlgorithmName hash, byte[] ikm, int outputLength, byte[] salt, byte[] info); [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExtractTests(Rfc5869TestCase test) { byte[] prk = Extract(test.Hash, test.Prk.Length, test.Ikm, test.Salt); Assert.Equal(test.Prk, prk); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExtractTamperHashTests(Rfc5869TestCase test) { byte[] prk = Extract(HashAlgorithmName.MD5, 128 / 8, test.Ikm, test.Salt); Assert.NotEqual(test.Prk, prk); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExtractTamperIkmTests(Rfc5869TestCase test) { byte[] ikm = test.Ikm.ToArray(); ikm[0] ^= 1; byte[] prk = Extract(test.Hash, test.Prk.Length, ikm, test.Salt); Assert.NotEqual(test.Prk, prk); } [Theory] [MemberData(nameof(GetRfc5869TestCasesWithNonEmptySalt))] public void Rfc5869ExtractTamperSaltTests(Rfc5869TestCase test) { byte[] salt = test.Salt.ToArray(); salt[0] ^= 1; byte[] prk = Extract(test.Hash, test.Prk.Length, test.Ikm, salt); Assert.NotEqual(test.Prk, prk); } [Fact] public void Rfc5869ExtractDefaultHash() { byte[] ikm = new byte[20]; byte[] salt = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => Extract(default(HashAlgorithmName), 20, ikm, salt)); } [Fact] public void Rfc5869ExtractNonsensicalHash() { byte[] ikm = new byte[20]; byte[] salt = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => Extract(new HashAlgorithmName("foo"), 20, ikm, salt)); } [Fact] public void Rfc5869ExtractEmptyIkm() { byte[] salt = new byte[20]; byte[] ikm = Array.Empty<byte>(); // Ensure does not throw byte[] prk = Extract(HashAlgorithmName.SHA1, 20, ikm, salt); Assert.Equal("FBDB1D1B18AA6C08324B7D64B71FB76370690E1D", prk.ByteArrayToHex()); } [Fact] public void Rfc5869ExtractEmptySalt() { byte[] ikm = new byte[20]; byte[] salt = Array.Empty<byte>(); byte[] prk = Extract(HashAlgorithmName.SHA1, 20, ikm, salt); Assert.Equal("A3CBF4A40F51A53E046F07397E52DF9286AE93A2", prk.ByteArrayToHex()); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExpandTests(Rfc5869TestCase test) { byte[] okm = Expand(test.Hash, test.Prk, test.Okm.Length, test.Info); Assert.Equal(test.Okm, okm); } [Fact] public void Rfc5869ExpandDefaultHash() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => Expand(default(HashAlgorithmName), prk, 20, null)); } [Fact] public void Rfc5869ExpandNonsensicalHash() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => Expand(new HashAlgorithmName("foo"), prk, 20, null)); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExpandTamperPrkTests(Rfc5869TestCase test) { byte[] prk = test.Prk.ToArray(); prk[0] ^= 1; byte[] okm = Expand(test.Hash, prk, test.Okm.Length, test.Info); Assert.NotEqual(test.Okm, okm); } [Theory] [MemberData(nameof(GetPrkTooShortTestCases))] public void Rfc5869ExpandPrkTooShort(HashAlgorithmName hash, int prkSize) { byte[] prk = new byte[prkSize]; AssertExtensions.Throws<ArgumentException>( "prk", () => Expand(hash, prk, 17, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOkmMaxSize() { byte[] prk = new byte[20]; // Does not throw byte[] okm = Expand(HashAlgorithmName.SHA1, prk, 20 * 255, Array.Empty<byte>()); Assert.Equal(20 * 255, okm.Length); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869DeriveKeyTests(Rfc5869TestCase test) { byte[] okm = DeriveKey(test.Hash, test.Ikm, test.Okm.Length, test.Salt, test.Info); Assert.Equal(test.Okm, okm); } [Fact] public void Rfc5869DeriveKeyDefaultHash() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => DeriveKey(default(HashAlgorithmName), ikm, 20, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyNonSensicalHash() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => DeriveKey(new HashAlgorithmName("foo"), ikm, 20, Array.Empty<byte>(), Array.Empty<byte>())); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869DeriveKeyTamperIkmTests(Rfc5869TestCase test) { byte[] ikm = test.Ikm.ToArray(); ikm[0] ^= 1; byte[] okm = DeriveKey(test.Hash, ikm, test.Okm.Length, test.Salt, test.Info); Assert.NotEqual(test.Okm, okm); } [Theory] [MemberData(nameof(GetRfc5869TestCasesWithNonEmptySalt))] public void Rfc5869DeriveKeyTamperSaltTests(Rfc5869TestCase test) { byte[] salt = test.Salt.ToArray(); salt[0] ^= 1; byte[] okm = DeriveKey(test.Hash, test.Ikm, test.Okm.Length, salt, test.Info); Assert.NotEqual(test.Okm, okm); } [Theory] [MemberData(nameof(GetRfc5869TestCasesWithNonEmptyInfo))] public void Rfc5869DeriveKeyTamperInfoTests(Rfc5869TestCase test) { byte[] info = test.Info.ToArray(); info[0] ^= 1; byte[] okm = DeriveKey(test.Hash, test.Ikm, test.Okm.Length, test.Salt, info); Assert.NotEqual(test.Okm, okm); } public static IEnumerable<object[]> GetRfc5869TestCases() { foreach (Rfc5869TestCase test in Rfc5869TestCases) { yield return new object[] { test }; } } public static IEnumerable<object[]> GetRfc5869TestCasesWithNonEmptySalt() { foreach (Rfc5869TestCase test in Rfc5869TestCases) { if (test.Salt != null && test.Salt.Length != 0) { yield return new object[] { test }; } } } public static IEnumerable<object[]> GetRfc5869TestCasesWithNonEmptyInfo() { foreach (Rfc5869TestCase test in Rfc5869TestCases) { if (test.Info != null && test.Info.Length != 0) { yield return new object[] { test }; } } } public static IEnumerable<object[]> GetPrkTooShortTestCases() { yield return new object[] { HashAlgorithmName.SHA1, 0 }; yield return new object[] { HashAlgorithmName.SHA1, 1 }; yield return new object[] { HashAlgorithmName.SHA1, 160 / 8 - 1 }; yield return new object[] { HashAlgorithmName.SHA256, 256 / 8 - 1 }; yield return new object[] { HashAlgorithmName.SHA512, 512 / 8 - 1 }; yield return new object[] { HashAlgorithmName.MD5, 128 / 8 - 1 }; } private static Rfc5869TestCase[] Rfc5869TestCases { get; } = new Rfc5869TestCase[7] { new Rfc5869TestCase() { Name = "Basic test case with SHA-256", Hash = HashAlgorithmName.SHA256, Ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(), Salt = "000102030405060708090a0b0c".HexToByteArray(), Info = "f0f1f2f3f4f5f6f7f8f9".HexToByteArray(), Prk = ( "077709362c2e32df0ddc3f0dc47bba63" + "90b6c73bb50f9c3122ec844ad7c2b3e5").HexToByteArray(), Okm = ( "3cb25f25faacd57a90434f64d0362f2a" + "2d2d0a90cf1a5a4c5db02d56ecc4c5bf" + "34007208d5b887185865").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-256 and longer inputs/outputs", Hash = HashAlgorithmName.SHA256, Ikm = ( "000102030405060708090a0b0c0d0e0f" + "101112131415161718191a1b1c1d1e1f" + "202122232425262728292a2b2c2d2e2f" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494a4b4c4d4e4f").HexToByteArray(), Salt = ( "606162636465666768696a6b6c6d6e6f" + "707172737475767778797a7b7c7d7e7f" + "808182838485868788898a8b8c8d8e8f" + "909192939495969798999a9b9c9d9e9f" + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf").HexToByteArray(), Info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(), Prk = ( "06a6b88c5853361a06104c9ceb35b45c" + "ef760014904671014a193f40c15fc244").HexToByteArray(), Okm = ( "b11e398dc80327a1c8e7f78c596a4934" + "4f012eda2d4efad8a050cc4c19afa97c" + "59045a99cac7827271cb41c65e590e09" + "da3275600c2f09b8367793a9aca3db71" + "cc30c58179ec3e87c14c01d5c1f3434f" + "1d87").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-256 and zero-length salt/info", Hash = HashAlgorithmName.SHA256, Ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(), Salt = Array.Empty<byte>(), Info = Array.Empty<byte>(), Prk = ( "19ef24a32c717b167f33a91d6f648bdf" + "96596776afdb6377ac434c1c293ccb04").HexToByteArray(), Okm = ( "8da4e775a563c18f715f802a063c5a31" + "b8a11f5c5ee1879ec3454e5f3c738d2d" + "9d201395faa4b61a96c8").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Basic test case with SHA-1", Hash = HashAlgorithmName.SHA1, Ikm = "0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(), Salt = "000102030405060708090a0b0c".HexToByteArray(), Info = "f0f1f2f3f4f5f6f7f8f9".HexToByteArray(), Prk = "9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243".HexToByteArray(), Okm = ( "085a01ea1b10f36933068b56efa5ad81" + "a4f14b822f5b091568a9cdd4f155fda2" + "c22e422478d305f3f896").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-1 and longer inputs/outputs", Hash = HashAlgorithmName.SHA1, Ikm = ( "000102030405060708090a0b0c0d0e0f" + "101112131415161718191a1b1c1d1e1f" + "202122232425262728292a2b2c2d2e2f" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494a4b4c4d4e4f").HexToByteArray(), Salt = ( "606162636465666768696a6b6c6d6e6f" + "707172737475767778797a7b7c7d7e7f" + "808182838485868788898a8b8c8d8e8f" + "909192939495969798999a9b9c9d9e9f" + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf").HexToByteArray(), Info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(), Prk = "8adae09a2a307059478d309b26c4115a224cfaf6".HexToByteArray(), Okm = ( "0bd770a74d1160f7c9f12cd5912a06eb" + "ff6adcae899d92191fe4305673ba2ffe" + "8fa3f1a4e5ad79f3f334b3b202b2173c" + "486ea37ce3d397ed034c7f9dfeb15c5e" + "927336d0441f4c4300e2cff0d0900b52" + "d3b4").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-1 and zero-length salt/info", Hash = HashAlgorithmName.SHA1, Ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(), Salt = Array.Empty<byte>(), Info = Array.Empty<byte>(), Prk = "da8c8a73c7fa77288ec6f5e7c297786aa0d32d01".HexToByteArray(), Okm = ( "0ac1af7002b3d761d1e55298da9d0506" + "b9ae52057220a306e07b6b87e8df21d0" + "ea00033de03984d34918").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-1, salt not provided (defaults to HashLen zero octets), zero-length info", Hash = HashAlgorithmName.SHA1, Ikm = "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c".HexToByteArray(), Salt = null, Info = Array.Empty<byte>(), Prk = "2adccada18779e7c2077ad2eb19d3f3e731385dd".HexToByteArray(), Okm = ( "2c91117204d745f3500d636a62f64f0a" + "b3bae548aa53d423b0d1f27ebba6f5e5" + "673a081d70cce7acfc48").HexToByteArray(), }, }; public struct Rfc5869TestCase { public string Name { get; set; } public HashAlgorithmName Hash { get; set; } public byte[] Ikm { get; set; } public byte[] Salt { get; set; } public byte[] Info { get; set; } public byte[] Prk { get; set; } public byte[] Okm { get; set; } public override string ToString() => Name; } public class HkdfByteArrayTests : HKDFTests { protected override byte[] Extract(HashAlgorithmName hash, int prkLength, byte[] ikm, byte[] salt) { return HKDF.Extract(hash, ikm, salt); } protected override byte[] Expand(HashAlgorithmName hash, byte[] prk, int outputLength, byte[] info) { return HKDF.Expand(hash, prk, outputLength, info); } protected override byte[] DeriveKey(HashAlgorithmName hash, byte[] ikm, int outputLength, byte[] salt, byte[] info) { return HKDF.DeriveKey(hash, ikm, outputLength, salt, info); } [Fact] public void Rfc5869ExtractNullIkm() { byte[] salt = new byte[20]; AssertExtensions.Throws<ArgumentNullException>( "ikm", () => HKDF.Extract(HashAlgorithmName.SHA1, null, salt)); } [Fact] public void Rfc5869ExpandOkmMaxSizePlusOne() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, 20 * 255 + 1, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOkmPotentiallyOverflowingValue() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, 8421505, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOutputLengthZero() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, 0, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOutputLengthLessThanZero() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, -1, Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyNullIkm() { AssertExtensions.Throws<ArgumentNullException>( "ikm", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, null, 20, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyOkmMaxSizePlusOne() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, 20 * 255 + 1, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyOkmPotentiallyOverflowingValue() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, 8421505, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveOutputLengthZero() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, 0, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveOutputLengthLessThanZero() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, -1, Array.Empty<byte>(), Array.Empty<byte>())); } } public class HkdfSpanTests : HKDFTests { protected override byte[] Extract(HashAlgorithmName hash, int prkLength, byte[] ikm, byte[] salt) { byte[] prk = new byte[prkLength]; Assert.Equal(prkLength, HKDF.Extract(hash, ikm, salt, prk)); return prk; } protected override byte[] Expand(HashAlgorithmName hash, byte[] prk, int outputLength, byte[] info) { byte[] output = new byte[outputLength]; HKDF.Expand(hash, prk, output, info); return output; } protected override byte[] DeriveKey(HashAlgorithmName hash, byte[] ikm, int outputLength, byte[] salt, byte[] info) { byte[] output = new byte[outputLength]; HKDF.DeriveKey(hash, ikm, output, salt, info); return output; } [Fact] public void Rfc5869ExtractPrkTooLong() { byte[] prk = new byte[24]; for (int i = 0; i < 4; i++) { prk[20 + i] = (byte)(i + 5); } byte[] ikm = new byte[20]; byte[] salt = new byte[20]; Assert.Equal(20, HKDF.Extract(HashAlgorithmName.SHA1, ikm, salt, prk)); Assert.Equal("A3CBF4A40F51A53E046F07397E52DF9286AE93A2", prk.AsSpan(0, 20).ByteArrayToHex()); for (int i = 0; i < 4; i++) { // ensure we didn't modify anything further Assert.Equal((byte)(i + 5), prk[20 + i]); } } [Fact] public void Rfc5869OkmMaxSizePlusOne() { byte[] prk = new byte[20]; byte[] okm = new byte[20 * 255 + 1]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, okm, Array.Empty<byte>())); } [Fact] public void Rfc5869OkmMaxSizePotentiallyOverflowingValue() { byte[] prk = new byte[20]; byte[] okm = new byte[8421505]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, okm, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOutputLengthZero() { byte[] prk = new byte[20]; byte[] okm = new byte[0]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, okm, Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeySpanOkmMaxSizePlusOne() { byte[] ikm = new byte[20]; byte[] okm = new byte[20 * 255 + 1]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, okm, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeySpanOkmPotentiallyOverflowingValue() { byte[] ikm = new byte[20]; byte[] okm = new byte[8421505]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, okm, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyOutputLengthZero() { byte[] ikm = new byte[20]; byte[] okm = new byte[0]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, okm, Array.Empty<byte>(), Array.Empty<byte>())); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over ikm [InlineData(10, 0)] // ikm +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over ikm public void Rfc5869ExtractOverlapsPrkOverKeyMaterial(int ikmOffset, int outputOffset) { ReadOnlySpan<byte> ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(); ReadOnlySpan<byte> salt = "000102030405060708090a0b0c".HexToByteArray(); byte[] expectedPrk = "077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5".HexToByteArray(); int length = Math.Max(ikm.Length, expectedPrk.Length) + Math.Max(ikmOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> ikmBuffer = buffer.Slice(ikmOffset, ikm.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedPrk.Length); ikm.CopyTo(ikmBuffer); HKDF.Extract(HashAlgorithmName.SHA256, ikmBuffer, salt, outputBuffer); Assert.Equal(expectedPrk, outputBuffer.ToArray()); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over salt [InlineData(10, 0)] // salt +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over salt public void Rfc5869ExtractOverlapsPrkOverSalt(int saltOffset, int outputOffset) { ReadOnlySpan<byte> ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(); ReadOnlySpan<byte> salt = "000102030405060708090a0b0c".HexToByteArray(); byte[] expectedPrk = "077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5".HexToByteArray(); int length = Math.Max(ikm.Length, expectedPrk.Length) + Math.Max(saltOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> saltBuffer = buffer.Slice(saltOffset, salt.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedPrk.Length); salt.CopyTo(saltBuffer); HKDF.Extract(HashAlgorithmName.SHA256, ikm, saltBuffer, outputBuffer); Assert.Equal(expectedPrk, outputBuffer.ToArray()); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over info [InlineData(10, 0)] // Info +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over info public void Rfc5869ExpandOverlapsOutputOverInfo(int infoOffset, int outputOffset) { ReadOnlySpan<byte> info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(); ReadOnlySpan<byte> prk = "06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244".HexToByteArray(); byte[] expectedOkm = ( "b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c" + "59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71" + "cc30c58179ec3e87c14c01d5c1f3434f1d87").HexToByteArray(); int length = Math.Max(info.Length, expectedOkm.Length) + Math.Max(infoOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> infoBuffer = buffer.Slice(infoOffset, info.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedOkm.Length); info.CopyTo(infoBuffer); HKDF.Expand(HashAlgorithmName.SHA256, prk, output: outputBuffer, info: infoBuffer); Assert.Equal(expectedOkm, outputBuffer.ToArray()); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over info [InlineData(10, 0)] // Info +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over info public void Rfc5869ExpandOverlapsOutputOverInfoShortOkm(int infoOffset, int outputOffset) { ReadOnlySpan<byte> info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(); ReadOnlySpan<byte> prk = "06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244".HexToByteArray(); byte[] expectedOkm = "b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c".HexToByteArray(); int length = Math.Max(info.Length, expectedOkm.Length) + Math.Max(infoOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> infoBuffer = buffer.Slice(infoOffset, info.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedOkm.Length); info.CopyTo(infoBuffer); HKDF.Expand(HashAlgorithmName.SHA256, prk, output: outputBuffer, info: infoBuffer); Assert.Equal(expectedOkm, outputBuffer.ToArray()); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over prk [InlineData(10, 0)] // Prk +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over prk public void Rfc5869ExpandOverlapsOutputOverPrk(int prkOffset, int outputOffset) { ReadOnlySpan<byte> info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(); ReadOnlySpan<byte> prk = "06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244".HexToByteArray(); byte[] expectedOkm = ( "b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c" + "59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71" + "cc30c58179ec3e87c14c01d5c1f3434f1d87").HexToByteArray(); int length = Math.Max(prk.Length, expectedOkm.Length) + Math.Max(prkOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> prkBuffer = buffer.Slice(prkOffset, prk.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedOkm.Length); prk.CopyTo(prkBuffer); HKDF.Expand(HashAlgorithmName.SHA256, prkBuffer, output: outputBuffer, info: info); Assert.Equal(expectedOkm, outputBuffer.ToArray()); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using Test.Cryptography; using Xunit; namespace System.Security.Cryptography.Tests { [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")] public abstract class HKDFTests { protected abstract byte[] Extract(HashAlgorithmName hash, int prkLength, byte[] ikm, byte[] salt); protected abstract byte[] Expand(HashAlgorithmName hash, byte[] prk, int outputLength, byte[] info); protected abstract byte[] DeriveKey(HashAlgorithmName hash, byte[] ikm, int outputLength, byte[] salt, byte[] info); [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExtractTests(Rfc5869TestCase test) { byte[] prk = Extract(test.Hash, test.Prk.Length, test.Ikm, test.Salt); Assert.Equal(test.Prk, prk); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExtractTamperHashTests(Rfc5869TestCase test) { byte[] prk = Extract(HashAlgorithmName.MD5, 128 / 8, test.Ikm, test.Salt); Assert.NotEqual(test.Prk, prk); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExtractTamperIkmTests(Rfc5869TestCase test) { byte[] ikm = test.Ikm.ToArray(); ikm[0] ^= 1; byte[] prk = Extract(test.Hash, test.Prk.Length, ikm, test.Salt); Assert.NotEqual(test.Prk, prk); } [Theory] [MemberData(nameof(GetRfc5869TestCasesWithNonEmptySalt))] public void Rfc5869ExtractTamperSaltTests(Rfc5869TestCase test) { byte[] salt = test.Salt.ToArray(); salt[0] ^= 1; byte[] prk = Extract(test.Hash, test.Prk.Length, test.Ikm, salt); Assert.NotEqual(test.Prk, prk); } [Fact] public void Rfc5869ExtractDefaultHash() { byte[] ikm = new byte[20]; byte[] salt = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => Extract(default(HashAlgorithmName), 20, ikm, salt)); } [Fact] public void Rfc5869ExtractNonsensicalHash() { byte[] ikm = new byte[20]; byte[] salt = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => Extract(new HashAlgorithmName("foo"), 20, ikm, salt)); } [Fact] public void Rfc5869ExtractEmptyIkm() { byte[] salt = new byte[20]; byte[] ikm = Array.Empty<byte>(); // Ensure does not throw byte[] prk = Extract(HashAlgorithmName.SHA1, 20, ikm, salt); Assert.Equal("FBDB1D1B18AA6C08324B7D64B71FB76370690E1D", prk.ByteArrayToHex()); } [Fact] public void Rfc5869ExtractEmptySalt() { byte[] ikm = new byte[20]; byte[] salt = Array.Empty<byte>(); byte[] prk = Extract(HashAlgorithmName.SHA1, 20, ikm, salt); Assert.Equal("A3CBF4A40F51A53E046F07397E52DF9286AE93A2", prk.ByteArrayToHex()); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExpandTests(Rfc5869TestCase test) { byte[] okm = Expand(test.Hash, test.Prk, test.Okm.Length, test.Info); Assert.Equal(test.Okm, okm); } [Fact] public void Rfc5869ExpandDefaultHash() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => Expand(default(HashAlgorithmName), prk, 20, null)); } [Fact] public void Rfc5869ExpandNonsensicalHash() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => Expand(new HashAlgorithmName("foo"), prk, 20, null)); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869ExpandTamperPrkTests(Rfc5869TestCase test) { byte[] prk = test.Prk.ToArray(); prk[0] ^= 1; byte[] okm = Expand(test.Hash, prk, test.Okm.Length, test.Info); Assert.NotEqual(test.Okm, okm); } [Theory] [MemberData(nameof(GetPrkTooShortTestCases))] public void Rfc5869ExpandPrkTooShort(HashAlgorithmName hash, int prkSize) { byte[] prk = new byte[prkSize]; AssertExtensions.Throws<ArgumentException>( "prk", () => Expand(hash, prk, 17, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOkmMaxSize() { byte[] prk = new byte[20]; // Does not throw byte[] okm = Expand(HashAlgorithmName.SHA1, prk, 20 * 255, Array.Empty<byte>()); Assert.Equal(20 * 255, okm.Length); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869DeriveKeyTests(Rfc5869TestCase test) { byte[] okm = DeriveKey(test.Hash, test.Ikm, test.Okm.Length, test.Salt, test.Info); Assert.Equal(test.Okm, okm); } [Fact] public void Rfc5869DeriveKeyDefaultHash() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => DeriveKey(default(HashAlgorithmName), ikm, 20, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyNonSensicalHash() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "hashAlgorithmName", () => DeriveKey(new HashAlgorithmName("foo"), ikm, 20, Array.Empty<byte>(), Array.Empty<byte>())); } [Theory] [MemberData(nameof(GetRfc5869TestCases))] public void Rfc5869DeriveKeyTamperIkmTests(Rfc5869TestCase test) { byte[] ikm = test.Ikm.ToArray(); ikm[0] ^= 1; byte[] okm = DeriveKey(test.Hash, ikm, test.Okm.Length, test.Salt, test.Info); Assert.NotEqual(test.Okm, okm); } [Theory] [MemberData(nameof(GetRfc5869TestCasesWithNonEmptySalt))] public void Rfc5869DeriveKeyTamperSaltTests(Rfc5869TestCase test) { byte[] salt = test.Salt.ToArray(); salt[0] ^= 1; byte[] okm = DeriveKey(test.Hash, test.Ikm, test.Okm.Length, salt, test.Info); Assert.NotEqual(test.Okm, okm); } [Theory] [MemberData(nameof(GetRfc5869TestCasesWithNonEmptyInfo))] public void Rfc5869DeriveKeyTamperInfoTests(Rfc5869TestCase test) { byte[] info = test.Info.ToArray(); info[0] ^= 1; byte[] okm = DeriveKey(test.Hash, test.Ikm, test.Okm.Length, test.Salt, info); Assert.NotEqual(test.Okm, okm); } public static IEnumerable<object[]> GetRfc5869TestCases() { foreach (Rfc5869TestCase test in Rfc5869TestCases) { yield return new object[] { test }; } } public static IEnumerable<object[]> GetRfc5869TestCasesWithNonEmptySalt() { foreach (Rfc5869TestCase test in Rfc5869TestCases) { if (test.Salt != null && test.Salt.Length != 0) { yield return new object[] { test }; } } } public static IEnumerable<object[]> GetRfc5869TestCasesWithNonEmptyInfo() { foreach (Rfc5869TestCase test in Rfc5869TestCases) { if (test.Info != null && test.Info.Length != 0) { yield return new object[] { test }; } } } public static IEnumerable<object[]> GetPrkTooShortTestCases() { yield return new object[] { HashAlgorithmName.SHA1, 0 }; yield return new object[] { HashAlgorithmName.SHA1, 1 }; yield return new object[] { HashAlgorithmName.SHA1, 160 / 8 - 1 }; yield return new object[] { HashAlgorithmName.SHA256, 256 / 8 - 1 }; yield return new object[] { HashAlgorithmName.SHA512, 512 / 8 - 1 }; yield return new object[] { HashAlgorithmName.MD5, 128 / 8 - 1 }; } private static Rfc5869TestCase[] Rfc5869TestCases { get; } = new Rfc5869TestCase[7] { new Rfc5869TestCase() { Name = "Basic test case with SHA-256", Hash = HashAlgorithmName.SHA256, Ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(), Salt = "000102030405060708090a0b0c".HexToByteArray(), Info = "f0f1f2f3f4f5f6f7f8f9".HexToByteArray(), Prk = ( "077709362c2e32df0ddc3f0dc47bba63" + "90b6c73bb50f9c3122ec844ad7c2b3e5").HexToByteArray(), Okm = ( "3cb25f25faacd57a90434f64d0362f2a" + "2d2d0a90cf1a5a4c5db02d56ecc4c5bf" + "34007208d5b887185865").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-256 and longer inputs/outputs", Hash = HashAlgorithmName.SHA256, Ikm = ( "000102030405060708090a0b0c0d0e0f" + "101112131415161718191a1b1c1d1e1f" + "202122232425262728292a2b2c2d2e2f" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494a4b4c4d4e4f").HexToByteArray(), Salt = ( "606162636465666768696a6b6c6d6e6f" + "707172737475767778797a7b7c7d7e7f" + "808182838485868788898a8b8c8d8e8f" + "909192939495969798999a9b9c9d9e9f" + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf").HexToByteArray(), Info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(), Prk = ( "06a6b88c5853361a06104c9ceb35b45c" + "ef760014904671014a193f40c15fc244").HexToByteArray(), Okm = ( "b11e398dc80327a1c8e7f78c596a4934" + "4f012eda2d4efad8a050cc4c19afa97c" + "59045a99cac7827271cb41c65e590e09" + "da3275600c2f09b8367793a9aca3db71" + "cc30c58179ec3e87c14c01d5c1f3434f" + "1d87").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-256 and zero-length salt/info", Hash = HashAlgorithmName.SHA256, Ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(), Salt = Array.Empty<byte>(), Info = Array.Empty<byte>(), Prk = ( "19ef24a32c717b167f33a91d6f648bdf" + "96596776afdb6377ac434c1c293ccb04").HexToByteArray(), Okm = ( "8da4e775a563c18f715f802a063c5a31" + "b8a11f5c5ee1879ec3454e5f3c738d2d" + "9d201395faa4b61a96c8").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Basic test case with SHA-1", Hash = HashAlgorithmName.SHA1, Ikm = "0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(), Salt = "000102030405060708090a0b0c".HexToByteArray(), Info = "f0f1f2f3f4f5f6f7f8f9".HexToByteArray(), Prk = "9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243".HexToByteArray(), Okm = ( "085a01ea1b10f36933068b56efa5ad81" + "a4f14b822f5b091568a9cdd4f155fda2" + "c22e422478d305f3f896").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-1 and longer inputs/outputs", Hash = HashAlgorithmName.SHA1, Ikm = ( "000102030405060708090a0b0c0d0e0f" + "101112131415161718191a1b1c1d1e1f" + "202122232425262728292a2b2c2d2e2f" + "303132333435363738393a3b3c3d3e3f" + "404142434445464748494a4b4c4d4e4f").HexToByteArray(), Salt = ( "606162636465666768696a6b6c6d6e6f" + "707172737475767778797a7b7c7d7e7f" + "808182838485868788898a8b8c8d8e8f" + "909192939495969798999a9b9c9d9e9f" + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf").HexToByteArray(), Info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(), Prk = "8adae09a2a307059478d309b26c4115a224cfaf6".HexToByteArray(), Okm = ( "0bd770a74d1160f7c9f12cd5912a06eb" + "ff6adcae899d92191fe4305673ba2ffe" + "8fa3f1a4e5ad79f3f334b3b202b2173c" + "486ea37ce3d397ed034c7f9dfeb15c5e" + "927336d0441f4c4300e2cff0d0900b52" + "d3b4").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-1 and zero-length salt/info", Hash = HashAlgorithmName.SHA1, Ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(), Salt = Array.Empty<byte>(), Info = Array.Empty<byte>(), Prk = "da8c8a73c7fa77288ec6f5e7c297786aa0d32d01".HexToByteArray(), Okm = ( "0ac1af7002b3d761d1e55298da9d0506" + "b9ae52057220a306e07b6b87e8df21d0" + "ea00033de03984d34918").HexToByteArray(), }, new Rfc5869TestCase() { Name = "Test with SHA-1, salt not provided (defaults to HashLen zero octets), zero-length info", Hash = HashAlgorithmName.SHA1, Ikm = "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c".HexToByteArray(), Salt = null, Info = Array.Empty<byte>(), Prk = "2adccada18779e7c2077ad2eb19d3f3e731385dd".HexToByteArray(), Okm = ( "2c91117204d745f3500d636a62f64f0a" + "b3bae548aa53d423b0d1f27ebba6f5e5" + "673a081d70cce7acfc48").HexToByteArray(), }, }; public struct Rfc5869TestCase { public string Name { get; set; } public HashAlgorithmName Hash { get; set; } public byte[] Ikm { get; set; } public byte[] Salt { get; set; } public byte[] Info { get; set; } public byte[] Prk { get; set; } public byte[] Okm { get; set; } public override string ToString() => Name; } public class HkdfByteArrayTests : HKDFTests { protected override byte[] Extract(HashAlgorithmName hash, int prkLength, byte[] ikm, byte[] salt) { return HKDF.Extract(hash, ikm, salt); } protected override byte[] Expand(HashAlgorithmName hash, byte[] prk, int outputLength, byte[] info) { return HKDF.Expand(hash, prk, outputLength, info); } protected override byte[] DeriveKey(HashAlgorithmName hash, byte[] ikm, int outputLength, byte[] salt, byte[] info) { return HKDF.DeriveKey(hash, ikm, outputLength, salt, info); } [Fact] public void Rfc5869ExtractNullIkm() { byte[] salt = new byte[20]; AssertExtensions.Throws<ArgumentNullException>( "ikm", () => HKDF.Extract(HashAlgorithmName.SHA1, null, salt)); } [Fact] public void Rfc5869ExpandOkmMaxSizePlusOne() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, 20 * 255 + 1, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOkmPotentiallyOverflowingValue() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, 8421505, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOutputLengthZero() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, 0, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOutputLengthLessThanZero() { byte[] prk = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, -1, Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyNullIkm() { AssertExtensions.Throws<ArgumentNullException>( "ikm", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, null, 20, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyOkmMaxSizePlusOne() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, 20 * 255 + 1, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyOkmPotentiallyOverflowingValue() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, 8421505, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveOutputLengthZero() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, 0, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveOutputLengthLessThanZero() { byte[] ikm = new byte[20]; AssertExtensions.Throws<ArgumentOutOfRangeException>( "outputLength", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, -1, Array.Empty<byte>(), Array.Empty<byte>())); } } public class HkdfSpanTests : HKDFTests { protected override byte[] Extract(HashAlgorithmName hash, int prkLength, byte[] ikm, byte[] salt) { byte[] prk = new byte[prkLength]; Assert.Equal(prkLength, HKDF.Extract(hash, ikm, salt, prk)); return prk; } protected override byte[] Expand(HashAlgorithmName hash, byte[] prk, int outputLength, byte[] info) { byte[] output = new byte[outputLength]; HKDF.Expand(hash, prk, output, info); return output; } protected override byte[] DeriveKey(HashAlgorithmName hash, byte[] ikm, int outputLength, byte[] salt, byte[] info) { byte[] output = new byte[outputLength]; HKDF.DeriveKey(hash, ikm, output, salt, info); return output; } [Fact] public void Rfc5869ExtractPrkTooLong() { byte[] prk = new byte[24]; for (int i = 0; i < 4; i++) { prk[20 + i] = (byte)(i + 5); } byte[] ikm = new byte[20]; byte[] salt = new byte[20]; Assert.Equal(20, HKDF.Extract(HashAlgorithmName.SHA1, ikm, salt, prk)); Assert.Equal("A3CBF4A40F51A53E046F07397E52DF9286AE93A2", prk.AsSpan(0, 20).ByteArrayToHex()); for (int i = 0; i < 4; i++) { // ensure we didn't modify anything further Assert.Equal((byte)(i + 5), prk[20 + i]); } } [Fact] public void Rfc5869OkmMaxSizePlusOne() { byte[] prk = new byte[20]; byte[] okm = new byte[20 * 255 + 1]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, okm, Array.Empty<byte>())); } [Fact] public void Rfc5869OkmMaxSizePotentiallyOverflowingValue() { byte[] prk = new byte[20]; byte[] okm = new byte[8421505]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, okm, Array.Empty<byte>())); } [Fact] public void Rfc5869ExpandOutputLengthZero() { byte[] prk = new byte[20]; byte[] okm = new byte[0]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.Expand(HashAlgorithmName.SHA1, prk, okm, Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeySpanOkmMaxSizePlusOne() { byte[] ikm = new byte[20]; byte[] okm = new byte[20 * 255 + 1]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, okm, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeySpanOkmPotentiallyOverflowingValue() { byte[] ikm = new byte[20]; byte[] okm = new byte[8421505]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, okm, Array.Empty<byte>(), Array.Empty<byte>())); } [Fact] public void Rfc5869DeriveKeyOutputLengthZero() { byte[] ikm = new byte[20]; byte[] okm = new byte[0]; AssertExtensions.Throws<ArgumentException>( "output", () => HKDF.DeriveKey(HashAlgorithmName.SHA1, ikm, okm, Array.Empty<byte>(), Array.Empty<byte>())); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over ikm [InlineData(10, 0)] // ikm +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over ikm public void Rfc5869ExtractOverlapsPrkOverKeyMaterial(int ikmOffset, int outputOffset) { ReadOnlySpan<byte> ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(); ReadOnlySpan<byte> salt = "000102030405060708090a0b0c".HexToByteArray(); byte[] expectedPrk = "077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5".HexToByteArray(); int length = Math.Max(ikm.Length, expectedPrk.Length) + Math.Max(ikmOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> ikmBuffer = buffer.Slice(ikmOffset, ikm.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedPrk.Length); ikm.CopyTo(ikmBuffer); HKDF.Extract(HashAlgorithmName.SHA256, ikmBuffer, salt, outputBuffer); Assert.Equal(expectedPrk, outputBuffer.ToArray()); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over salt [InlineData(10, 0)] // salt +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over salt public void Rfc5869ExtractOverlapsPrkOverSalt(int saltOffset, int outputOffset) { ReadOnlySpan<byte> ikm = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b".HexToByteArray(); ReadOnlySpan<byte> salt = "000102030405060708090a0b0c".HexToByteArray(); byte[] expectedPrk = "077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5".HexToByteArray(); int length = Math.Max(ikm.Length, expectedPrk.Length) + Math.Max(saltOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> saltBuffer = buffer.Slice(saltOffset, salt.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedPrk.Length); salt.CopyTo(saltBuffer); HKDF.Extract(HashAlgorithmName.SHA256, ikm, saltBuffer, outputBuffer); Assert.Equal(expectedPrk, outputBuffer.ToArray()); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over info [InlineData(10, 0)] // Info +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over info public void Rfc5869ExpandOverlapsOutputOverInfo(int infoOffset, int outputOffset) { ReadOnlySpan<byte> info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(); ReadOnlySpan<byte> prk = "06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244".HexToByteArray(); byte[] expectedOkm = ( "b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c" + "59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71" + "cc30c58179ec3e87c14c01d5c1f3434f1d87").HexToByteArray(); int length = Math.Max(info.Length, expectedOkm.Length) + Math.Max(infoOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> infoBuffer = buffer.Slice(infoOffset, info.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedOkm.Length); info.CopyTo(infoBuffer); HKDF.Expand(HashAlgorithmName.SHA256, prk, output: outputBuffer, info: infoBuffer); Assert.Equal(expectedOkm, outputBuffer.ToArray()); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over info [InlineData(10, 0)] // Info +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over info public void Rfc5869ExpandOverlapsOutputOverInfoShortOkm(int infoOffset, int outputOffset) { ReadOnlySpan<byte> info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(); ReadOnlySpan<byte> prk = "06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244".HexToByteArray(); byte[] expectedOkm = "b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c".HexToByteArray(); int length = Math.Max(info.Length, expectedOkm.Length) + Math.Max(infoOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> infoBuffer = buffer.Slice(infoOffset, info.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedOkm.Length); info.CopyTo(infoBuffer); HKDF.Expand(HashAlgorithmName.SHA256, prk, output: outputBuffer, info: infoBuffer); Assert.Equal(expectedOkm, outputBuffer.ToArray()); } [Theory] [InlineData(0, 0)] // Overlap exactly [InlineData(0, 10)] // Output +10 offset over prk [InlineData(10, 0)] // Prk +10 offset over output [InlineData(10, 20)] // Both offset, output +10 over prk public void Rfc5869ExpandOverlapsOutputOverPrk(int prkOffset, int outputOffset) { ReadOnlySpan<byte> info = ( "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef" + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").HexToByteArray(); ReadOnlySpan<byte> prk = "06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244".HexToByteArray(); byte[] expectedOkm = ( "b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c" + "59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71" + "cc30c58179ec3e87c14c01d5c1f3434f1d87").HexToByteArray(); int length = Math.Max(prk.Length, expectedOkm.Length) + Math.Max(prkOffset, outputOffset); Span<byte> buffer = new byte[length]; Span<byte> prkBuffer = buffer.Slice(prkOffset, prk.Length); Span<byte> outputBuffer = buffer.Slice(outputOffset, expectedOkm.Length); prk.CopyTo(prkBuffer); HKDF.Expand(HashAlgorithmName.SHA256, prkBuffer, output: outputBuffer, info: info); Assert.Equal(expectedOkm, outputBuffer.ToArray()); } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Text.Encoding/tests/Decoder/DecoderGetCharCount2.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Text.Tests { // GetCharCount(System.Byte[],System.Int32,System.Int32,System.Boolean) public class DecoderGetCharCount2 { #region Private Fields private const int c_SIZE_OF_ARRAY = 127; private readonly RandomDataGenerator _generator = new RandomDataGenerator(); #endregion #region Positive Test Cases // PosTest1: Call GetCharCount with ASCII decoder and ASCII byte array [Fact] public void PosTest1() { Decoder decoder = Encoding.UTF8.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; int expected = bytes.Length; for (int i = 0; i < bytes.Length; ++i) { bytes[i] = (byte)i; } VerificationHelper(decoder, bytes, 0, bytes.Length, true, expected, "001.1"); VerificationHelper(decoder, bytes, 0, bytes.Length, false, expected, "001.2"); } // PosTest2: Call GetCharCount with Unicode decoder and ASCII byte array [Fact] public void PosTest2() { Decoder decoder = Encoding.Unicode.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; for (int i = 0; i < bytes.Length; ++i) { bytes[i] = (byte)i; } VerificationHelper(decoder, bytes, 0, bytes.Length, true, bytes.Length / 2 + 1, "002.1"); VerificationHelper(decoder, bytes, 0, bytes.Length, false, bytes.Length / 2, "002.2"); } // PosTest3: Call GetCharCount with Unicode decoder and Unicode byte array [Fact] public void PosTest3() { Decoder decoder = Encoding.Unicode.GetDecoder(); int expected = 6; // Unicode string: \u8FD9\u4E2A\u4E00\u4E2A\u6D4B\u8BD5 byte[] bytes = new byte[] { 217, 143, 42, 78, 0, 78, 42, 78, 75, 109, 213, 139 }; VerificationHelper(decoder, bytes, 0, bytes.Length, true, expected, "003.1"); VerificationHelper(decoder, bytes, 0, bytes.Length, false, expected, "003.2"); } // PosTest4: Call GetCharCount with Unicode decoder and Arbitrary byte array [Fact] public void PosTest4() { Decoder decoder = Encoding.Unicode.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; _generator.GetBytes(-55, bytes); decoder.GetCharCount(bytes, 0, bytes.Length, true); decoder.GetCharCount(bytes, 0, bytes.Length, false); } // PosTest5: Call GetCharCount with ASCII decoder and Arbitrary byte array [Fact] public void PosTest5() { Decoder decoder = Encoding.UTF8.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; _generator.GetBytes(-55, bytes); decoder.GetCharCount(bytes, 0, bytes.Length, true); decoder.GetCharCount(bytes, 0, bytes.Length, false); } // PosTest6: Call GetCharCount with ASCII decoder and convert partial of ASCII array [Fact] public void PosTest6() { Decoder decoder = Encoding.UTF8.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; int expected = bytes.Length / 2; for (int i = 0; i < bytes.Length; ++i) { bytes[i] = (byte)i; } VerificationHelper(decoder, bytes, 0, expected, true, expected, "006.1"); VerificationHelper(decoder, bytes, 0, expected, false, expected, "006.2"); VerificationHelper(decoder, bytes, expected, expected, true, expected, "006.3"); VerificationHelper(decoder, bytes, 1, expected, false, expected, "006.4"); } // PosTest7: Call GetCharCount with Unicode decoder and convert partial of Unicode byte array [Fact] public void PosTest7() { Decoder decoder = Encoding.Unicode.GetDecoder(); // Unicode string: \u8FD9\u4E2A\u4E00\u4E2A\u6D4B\u8BD5 byte[] bytes = new byte[] { 217, 143, 42, 78, 0, 78, 42, 78, 75, 109, 213, 139 }; int expected = 3; VerificationHelper(decoder, bytes, 0, bytes.Length / 2, true, expected, "007.1"); VerificationHelper(decoder, bytes, 0, bytes.Length / 2, false, expected, "007.2"); VerificationHelper(decoder, bytes, bytes.Length / 2, 0, true, 0, "007.3"); // Set index to 1, so some characters may be not converted VerificationHelper(decoder, bytes, 1, bytes.Length / 2, false, expected, "007.4"); } // PosTest8: Call GetCharCount with ASCII decoder and count = 0 [Fact] public void PosTest8() { Decoder decoder = Encoding.UTF8.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; int expected = 0; for (int i = 0; i < bytes.Length; ++i) { bytes[i] = (byte)i; } VerificationHelper(decoder, bytes, 0, expected, true, expected, "008.1"); VerificationHelper(decoder, bytes, 0, expected, false, expected, "008.2"); VerificationHelper(decoder, bytes, 1, expected, true, expected, "008.3"); VerificationHelper(decoder, bytes, bytes.Length, expected, false, expected, "008.4"); } #endregion private void VerificationHelper(Decoder decoder, byte[] bytes, int index, int count, bool flush, int expected, string errorno) { int ret = decoder.GetCharCount(bytes, index, count, flush); Assert.Equal(expected, ret); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Text.Tests { // GetCharCount(System.Byte[],System.Int32,System.Int32,System.Boolean) public class DecoderGetCharCount2 { #region Private Fields private const int c_SIZE_OF_ARRAY = 127; private readonly RandomDataGenerator _generator = new RandomDataGenerator(); #endregion #region Positive Test Cases // PosTest1: Call GetCharCount with ASCII decoder and ASCII byte array [Fact] public void PosTest1() { Decoder decoder = Encoding.UTF8.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; int expected = bytes.Length; for (int i = 0; i < bytes.Length; ++i) { bytes[i] = (byte)i; } VerificationHelper(decoder, bytes, 0, bytes.Length, true, expected, "001.1"); VerificationHelper(decoder, bytes, 0, bytes.Length, false, expected, "001.2"); } // PosTest2: Call GetCharCount with Unicode decoder and ASCII byte array [Fact] public void PosTest2() { Decoder decoder = Encoding.Unicode.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; for (int i = 0; i < bytes.Length; ++i) { bytes[i] = (byte)i; } VerificationHelper(decoder, bytes, 0, bytes.Length, true, bytes.Length / 2 + 1, "002.1"); VerificationHelper(decoder, bytes, 0, bytes.Length, false, bytes.Length / 2, "002.2"); } // PosTest3: Call GetCharCount with Unicode decoder and Unicode byte array [Fact] public void PosTest3() { Decoder decoder = Encoding.Unicode.GetDecoder(); int expected = 6; // Unicode string: \u8FD9\u4E2A\u4E00\u4E2A\u6D4B\u8BD5 byte[] bytes = new byte[] { 217, 143, 42, 78, 0, 78, 42, 78, 75, 109, 213, 139 }; VerificationHelper(decoder, bytes, 0, bytes.Length, true, expected, "003.1"); VerificationHelper(decoder, bytes, 0, bytes.Length, false, expected, "003.2"); } // PosTest4: Call GetCharCount with Unicode decoder and Arbitrary byte array [Fact] public void PosTest4() { Decoder decoder = Encoding.Unicode.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; _generator.GetBytes(-55, bytes); decoder.GetCharCount(bytes, 0, bytes.Length, true); decoder.GetCharCount(bytes, 0, bytes.Length, false); } // PosTest5: Call GetCharCount with ASCII decoder and Arbitrary byte array [Fact] public void PosTest5() { Decoder decoder = Encoding.UTF8.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; _generator.GetBytes(-55, bytes); decoder.GetCharCount(bytes, 0, bytes.Length, true); decoder.GetCharCount(bytes, 0, bytes.Length, false); } // PosTest6: Call GetCharCount with ASCII decoder and convert partial of ASCII array [Fact] public void PosTest6() { Decoder decoder = Encoding.UTF8.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; int expected = bytes.Length / 2; for (int i = 0; i < bytes.Length; ++i) { bytes[i] = (byte)i; } VerificationHelper(decoder, bytes, 0, expected, true, expected, "006.1"); VerificationHelper(decoder, bytes, 0, expected, false, expected, "006.2"); VerificationHelper(decoder, bytes, expected, expected, true, expected, "006.3"); VerificationHelper(decoder, bytes, 1, expected, false, expected, "006.4"); } // PosTest7: Call GetCharCount with Unicode decoder and convert partial of Unicode byte array [Fact] public void PosTest7() { Decoder decoder = Encoding.Unicode.GetDecoder(); // Unicode string: \u8FD9\u4E2A\u4E00\u4E2A\u6D4B\u8BD5 byte[] bytes = new byte[] { 217, 143, 42, 78, 0, 78, 42, 78, 75, 109, 213, 139 }; int expected = 3; VerificationHelper(decoder, bytes, 0, bytes.Length / 2, true, expected, "007.1"); VerificationHelper(decoder, bytes, 0, bytes.Length / 2, false, expected, "007.2"); VerificationHelper(decoder, bytes, bytes.Length / 2, 0, true, 0, "007.3"); // Set index to 1, so some characters may be not converted VerificationHelper(decoder, bytes, 1, bytes.Length / 2, false, expected, "007.4"); } // PosTest8: Call GetCharCount with ASCII decoder and count = 0 [Fact] public void PosTest8() { Decoder decoder = Encoding.UTF8.GetDecoder(); byte[] bytes = new byte[c_SIZE_OF_ARRAY]; int expected = 0; for (int i = 0; i < bytes.Length; ++i) { bytes[i] = (byte)i; } VerificationHelper(decoder, bytes, 0, expected, true, expected, "008.1"); VerificationHelper(decoder, bytes, 0, expected, false, expected, "008.2"); VerificationHelper(decoder, bytes, 1, expected, true, expected, "008.3"); VerificationHelper(decoder, bytes, bytes.Length, expected, false, expected, "008.4"); } #endregion private void VerificationHelper(Decoder decoder, byte[] bytes, int index, int count, bool flush, int expected, string errorno) { int ret = decoder.GetCharCount(bytes, index, count, flush); Assert.Equal(expected, ret); } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Directed/coverage/importer/ceeillegal.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="ceeillegal.il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="ceeillegal.il" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Loader/classloader/generics/Instantiation/Positive/AbstractBase03.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <OutputType>Exe</OutputType> </PropertyGroup> <ItemGroup> <Compile Include="AbstractBase03.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <OutputType>Exe</OutputType> </PropertyGroup> <ItemGroup> <Compile Include="AbstractBase03.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Methodical/ldtoken/ldtokena_il_d.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="ldtokena.il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="ldtokena.il" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest1007/Generated1007.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 4:0:0:0 } .assembly extern TestFramework { .publickeytoken = ( B0 3F 5F 7F 11 D5 0A 3A ) } //TYPES IN FORWARDER ASSEMBLIES: //TEST ASSEMBLY: .assembly Generated1007 { .hash algorithm 0x00008004 } .assembly extern xunit.core {} .class public BaseClass0 { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class public BaseClass1 extends BaseClass0 { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void BaseClass0::.ctor() ret } } .class public G3_C1479`1<T0> extends class G2_C499`2<!T0,class BaseClass1> implements class IBase1`1<!T0> { .method public hidebysig newslot virtual instance string Method4() cil managed noinlining { ldstr "G3_C1479::Method4.16369()" ret } .method public hidebysig newslot virtual instance string Method5() cil managed noinlining { ldstr "G3_C1479::Method5.16370()" ret } .method public hidebysig newslot virtual instance string 'IBase1<T0>.Method5'() cil managed noinlining { .override method instance string class IBase1`1<!T0>::Method5() ldstr "G3_C1479::Method5.MI.16371()" ret } .method public hidebysig newslot virtual instance string Method6<M0>() cil managed noinlining { ldstr "G3_C1479::Method6.16372<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase1<T0>.Method6'<M0>() cil managed noinlining { .override method instance string class IBase1`1<!T0>::Method6<[1]>() ldstr "G3_C1479::Method6.MI.16373<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'G2_C499<T0,class BaseClass1>.ClassMethod2356'<M0>() cil managed noinlining { .override method instance string class G2_C499`2<!T0,class BaseClass1>::ClassMethod2356<[1]>() ldstr "G3_C1479::ClassMethod2356.MI.16374<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'G2_C499<T0,class BaseClass1>.ClassMethod2357'<M0>() cil managed noinlining { .override method instance string class G2_C499`2<!T0,class BaseClass1>::ClassMethod2357<[1]>() ldstr "G3_C1479::ClassMethod2357.MI.16375<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void class G2_C499`2<!T0,class BaseClass1>::.ctor() ret } } .class public abstract G2_C499`2<T0, T1> extends class G1_C9`2<!T0,!T1> implements class IBase1`1<class BaseClass1>, IBase0 { .method public hidebysig virtual instance string Method4() cil managed noinlining { ldstr "G2_C499::Method4.9548()" ret } .method public hidebysig virtual instance string Method5() cil managed noinlining { ldstr "G2_C499::Method5.9549()" ret } .method public hidebysig newslot virtual instance string 'IBase1<class BaseClass1>.Method5'() cil managed noinlining { .override method instance string class IBase1`1<class BaseClass1>::Method5() ldstr "G2_C499::Method5.MI.9550()" ret } .method public hidebysig virtual instance string Method6<M0>() cil managed noinlining { ldstr "G2_C499::Method6.9551<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string Method0() cil managed noinlining { ldstr "G2_C499::Method0.9552()" ret } .method public hidebysig newslot virtual instance string 'IBase0.Method0'() cil managed noinlining { .override method instance string IBase0::Method0() ldstr "G2_C499::Method0.MI.9553()" ret } .method public hidebysig newslot virtual instance string Method1() cil managed noinlining { ldstr "G2_C499::Method1.9554()" ret } .method public hidebysig newslot virtual instance string 'IBase0.Method1'() cil managed noinlining { .override method instance string IBase0::Method1() ldstr "G2_C499::Method1.MI.9555()" ret } .method public hidebysig virtual instance string Method2<M0>() cil managed noinlining { ldstr "G2_C499::Method2.9556<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase0.Method2'<M0>() cil managed noinlining { .override method instance string IBase0::Method2<[1]>() ldstr "G2_C499::Method2.MI.9557<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig virtual instance string Method3<M0>() cil managed noinlining { ldstr "G2_C499::Method3.9558<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase0.Method3'<M0>() cil managed noinlining { .override method instance string IBase0::Method3<[1]>() ldstr "G2_C499::Method3.MI.9559<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod2356<M0>() cil managed noinlining { ldstr "G2_C499::ClassMethod2356.9560<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod2357<M0>() cil managed noinlining { ldstr "G2_C499::ClassMethod2357.9561<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'G1_C9<T0,T1>.ClassMethod1339'<M0>() cil managed noinlining { .override method instance string class G1_C9`2<!T0,!T1>::ClassMethod1339<[1]>() ldstr "G2_C499::ClassMethod1339.MI.9562<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void class G1_C9`2<!T0,!T1>::.ctor() ret } } .class interface public abstract IBase1`1<+T0> { .method public hidebysig newslot abstract virtual instance string Method4() cil managed { } .method public hidebysig newslot abstract virtual instance string Method5() cil managed { } .method public hidebysig newslot abstract virtual instance string Method6<M0>() cil managed { } } .class public abstract G1_C9`2<T0, T1> implements class IBase2`2<class BaseClass0,!T0>, class IBase1`1<class BaseClass0> { .method public hidebysig virtual instance string Method7<M0>() cil managed noinlining { ldstr "G1_C9::Method7.4833<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig virtual instance string Method4() cil managed noinlining { ldstr "G1_C9::Method4.4834()" ret } .method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method4'() cil managed noinlining { .override method instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G1_C9::Method4.MI.4835()" ret } .method public hidebysig newslot virtual instance string Method5() cil managed noinlining { ldstr "G1_C9::Method5.4836()" ret } .method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method5'() cil managed noinlining { .override method instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G1_C9::Method5.MI.4837()" ret } .method public hidebysig virtual instance string Method6<M0>() cil managed noinlining { ldstr "G1_C9::Method6.4838<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method6'<M0>() cil managed noinlining { .override method instance string class IBase1`1<class BaseClass0>::Method6<[1]>() ldstr "G1_C9::Method6.MI.4839<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod1336() cil managed noinlining { ldstr "G1_C9::ClassMethod1336.4840()" ret } .method public hidebysig newslot virtual instance string ClassMethod1337() cil managed noinlining { ldstr "G1_C9::ClassMethod1337.4841()" ret } .method public hidebysig newslot virtual instance string ClassMethod1338<M0>() cil managed noinlining { ldstr "G1_C9::ClassMethod1338.4842<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod1339<M0>() cil managed noinlining { ldstr "G1_C9::ClassMethod1339.4843<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class interface public abstract IBase0 { .method public hidebysig newslot abstract virtual instance string Method0() cil managed { } .method public hidebysig newslot abstract virtual instance string Method1() cil managed { } .method public hidebysig newslot abstract virtual instance string Method2<M0>() cil managed { } .method public hidebysig newslot abstract virtual instance string Method3<M0>() cil managed { } } .class interface public abstract IBase2`2<+T0, -T1> { .method public hidebysig newslot abstract virtual instance string Method7<M0>() cil managed { } } .class public auto ansi beforefieldinit Generated1007 { .method static void M.BaseClass0<(BaseClass0)W>(!!W inst, string exp) cil managed { .maxstack 5 .locals init (string[] actualResults) ldc.i4.s 0 newarr string stloc.s actualResults ldarg.1 ldstr "M.BaseClass0<(BaseClass0)W>(!!W inst, string exp)" ldc.i4.s 0 ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.BaseClass1<(BaseClass1)W>(!!W inst, string exp) cil managed { .maxstack 5 .locals init (string[] actualResults) ldc.i4.s 0 newarr string stloc.s actualResults ldarg.1 ldstr "M.BaseClass1<(BaseClass1)W>(!!W inst, string exp)" ldc.i4.s 0 ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1479.T<T0,(class G3_C1479`1<!!T0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1479.T<T0,(class G3_C1479`1<!!T0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1479.A<(class G3_C1479`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1479.A<(class G3_C1479`1<class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1479.B<(class G3_C1479`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1479.B<(class G3_C1479`1<class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.T.T<T0,T1,(class G2_C499`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.T.T<T0,T1,(class G2_C499`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.A.T<T1,(class G2_C499`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.A.T<T1,(class G2_C499`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.A.A<(class G2_C499`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.A.A<(class G2_C499`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.A.B<(class G2_C499`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.A.B<(class G2_C499`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.B.T<T1,(class G2_C499`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.B.T<T1,(class G2_C499`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.B.A<(class G2_C499`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.B.A<(class G2_C499`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.B.B<(class G2_C499`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.B.B<(class G2_C499`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.T.T<T0,T1,(class G1_C9`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.T.T<T0,T1,(class G1_C9`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.A.T<T1,(class G1_C9`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.A.T<T1,(class G1_C9`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.A.A<(class G1_C9`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.A.A<(class G1_C9`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.A.B<(class G1_C9`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.A.B<(class G1_C9`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.B.T<T1,(class G1_C9`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.B.T<T1,(class G1_C9`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.B.A<(class G1_C9`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.B.A<(class G1_C9`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.B.B<(class G1_C9`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.B.B<(class G1_C9`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase0<(IBase0)W>(!!W inst, string exp) cil managed { .maxstack 9 .locals init (string[] actualResults) ldc.i4.s 4 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase0<(IBase0)W>(!!W inst, string exp)" ldc.i4.s 4 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method3<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method public hidebysig static void MethodCallingTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Method Calling Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1479`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method5() ldstr "G2_C499::Method5.9549()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2357<object>() ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2356<object>() ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method3<object>() ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method2<object>() ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method1() ldstr "G2_C499::Method1.9554()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method0() ldstr "G2_C499::Method0.9552()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method5() ldstr "G2_C499::Method5.9549()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass1>::Method5() ldstr "G2_C499::Method5.MI.9550()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G2_C499::Method0.MI.9553()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G2_C499::Method1.MI.9555()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G2_C499::Method2.MI.9557<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G2_C499::Method3.MI.9559<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method6<object>() ldstr "G3_C1479::Method6.16372<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method5() ldstr "G3_C1479::Method5.16370()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod2357<object>() ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod2356<object>() ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method3<object>() ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method2<object>() ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method1() ldstr "G2_C499::Method1.9554()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method0() ldstr "G2_C499::Method0.9552()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G3_C1479`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method5() ldstr "G2_C499::Method5.9549()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2357<object>() ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2356<object>() ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G2_C499::Method1.9554()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G2_C499::Method0.9552()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method5() ldstr "G2_C499::Method5.9549()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass1>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass1>::Method5() ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>() ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G2_C499::Method0.MI.9553()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G2_C499::Method1.MI.9555()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G2_C499::Method2.MI.9557<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G2_C499::Method3.MI.9559<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method6<object>() ldstr "G3_C1479::Method6.16372<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method5() ldstr "G3_C1479::Method5.16370()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod2357<object>() ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod2356<object>() ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method3<object>() ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method2<object>() ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method1() ldstr "G2_C499::Method1.9554()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method0() ldstr "G2_C499::Method0.9552()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void ConstrainedCallsTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Constrained Calls Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1479`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.T.T<class BaseClass0,class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.A.T<class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.A.B<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1479`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.T<class BaseClass0,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.A<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.T<class BaseClass0,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.A<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.T<class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.B<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.T.T<class BaseClass0,class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.A.T<class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.A.B<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C499::Method4.9548()#G2_C499::Method5.MI.9550()#G2_C499::Method6.9551<System.Object>()#" call void Generated1007::M.IBase1.T<class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C499::Method4.9548()#G2_C499::Method5.MI.9550()#G2_C499::Method6.9551<System.Object>()#" call void Generated1007::M.IBase1.B<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C499::Method0.MI.9553()#G2_C499::Method1.MI.9555()#G2_C499::Method2.MI.9557<System.Object>()#G2_C499::Method3.MI.9559<System.Object>()#" call void Generated1007::M.IBase0<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G3_C1479::Method4.16369()#G3_C1479::Method5.16370()#G3_C1479::Method6.16372<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G3_C1479.T<class BaseClass0,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G3_C1479::Method4.16369()#G3_C1479::Method5.16370()#G3_C1479::Method6.16372<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G3_C1479.A<class G3_C1479`1<class BaseClass0>>(!!0,string) newobj instance void class G3_C1479`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.T.T<class BaseClass1,class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.B.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.B.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.T<class BaseClass0,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.A<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.T.T<class BaseClass1,class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.B.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.B.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C499::Method0.MI.9553()#G2_C499::Method1.MI.9555()#G2_C499::Method2.MI.9557<System.Object>()#G2_C499::Method3.MI.9559<System.Object>()#" call void Generated1007::M.IBase0<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G3_C1479::Method4.16369()#G3_C1479::Method5.16370()#G3_C1479::Method6.16372<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G3_C1479.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G3_C1479::Method4.16369()#G3_C1479::Method5.16370()#G3_C1479::Method6.16372<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G3_C1479.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void StructConstrainedInterfaceCallsTest() cil managed { .maxstack 10 ldstr "===================== Struct Constrained Interface Calls Test =====================" call void [mscorlib]System.Console::WriteLine(string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void CalliTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Method Calli Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1479`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method5.9549()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method4.9548()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2357<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2356<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method3<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method2<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method1() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method1.9554()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method0() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method0.9552()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method5.9549()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method4.9548()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method4.9548()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method5.MI.9550()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method0.MI.9553()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method1.MI.9555()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method2.MI.9557<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method3.MI.9559<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method6.16372<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method5.16370()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method4.16369()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod2357<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod2356<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method3<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method2<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method1() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method1.9554()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method0() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method0.9552()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G3_C1479`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method5.9549()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method4.9548()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2357<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2356<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method1.9554()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method0.9552()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method5.9549()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method4.9548()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method0.MI.9553()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method1.MI.9555()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method2.MI.9557<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method3.MI.9559<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method6.16372<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method5.16370()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method4.16369()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod2357<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod2356<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method3<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method2<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method1() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method1.9554()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method0() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method0.9552()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static int32 Main() cil managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .maxstack 10 call void Generated1007::MethodCallingTest() call void Generated1007::ConstrainedCallsTest() call void Generated1007::StructConstrainedInterfaceCallsTest() call void Generated1007::CalliTest() ldc.i4 100 ret } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 4:0:0:0 } .assembly extern TestFramework { .publickeytoken = ( B0 3F 5F 7F 11 D5 0A 3A ) } //TYPES IN FORWARDER ASSEMBLIES: //TEST ASSEMBLY: .assembly Generated1007 { .hash algorithm 0x00008004 } .assembly extern xunit.core {} .class public BaseClass0 { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class public BaseClass1 extends BaseClass0 { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void BaseClass0::.ctor() ret } } .class public G3_C1479`1<T0> extends class G2_C499`2<!T0,class BaseClass1> implements class IBase1`1<!T0> { .method public hidebysig newslot virtual instance string Method4() cil managed noinlining { ldstr "G3_C1479::Method4.16369()" ret } .method public hidebysig newslot virtual instance string Method5() cil managed noinlining { ldstr "G3_C1479::Method5.16370()" ret } .method public hidebysig newslot virtual instance string 'IBase1<T0>.Method5'() cil managed noinlining { .override method instance string class IBase1`1<!T0>::Method5() ldstr "G3_C1479::Method5.MI.16371()" ret } .method public hidebysig newslot virtual instance string Method6<M0>() cil managed noinlining { ldstr "G3_C1479::Method6.16372<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase1<T0>.Method6'<M0>() cil managed noinlining { .override method instance string class IBase1`1<!T0>::Method6<[1]>() ldstr "G3_C1479::Method6.MI.16373<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'G2_C499<T0,class BaseClass1>.ClassMethod2356'<M0>() cil managed noinlining { .override method instance string class G2_C499`2<!T0,class BaseClass1>::ClassMethod2356<[1]>() ldstr "G3_C1479::ClassMethod2356.MI.16374<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'G2_C499<T0,class BaseClass1>.ClassMethod2357'<M0>() cil managed noinlining { .override method instance string class G2_C499`2<!T0,class BaseClass1>::ClassMethod2357<[1]>() ldstr "G3_C1479::ClassMethod2357.MI.16375<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void class G2_C499`2<!T0,class BaseClass1>::.ctor() ret } } .class public abstract G2_C499`2<T0, T1> extends class G1_C9`2<!T0,!T1> implements class IBase1`1<class BaseClass1>, IBase0 { .method public hidebysig virtual instance string Method4() cil managed noinlining { ldstr "G2_C499::Method4.9548()" ret } .method public hidebysig virtual instance string Method5() cil managed noinlining { ldstr "G2_C499::Method5.9549()" ret } .method public hidebysig newslot virtual instance string 'IBase1<class BaseClass1>.Method5'() cil managed noinlining { .override method instance string class IBase1`1<class BaseClass1>::Method5() ldstr "G2_C499::Method5.MI.9550()" ret } .method public hidebysig virtual instance string Method6<M0>() cil managed noinlining { ldstr "G2_C499::Method6.9551<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string Method0() cil managed noinlining { ldstr "G2_C499::Method0.9552()" ret } .method public hidebysig newslot virtual instance string 'IBase0.Method0'() cil managed noinlining { .override method instance string IBase0::Method0() ldstr "G2_C499::Method0.MI.9553()" ret } .method public hidebysig newslot virtual instance string Method1() cil managed noinlining { ldstr "G2_C499::Method1.9554()" ret } .method public hidebysig newslot virtual instance string 'IBase0.Method1'() cil managed noinlining { .override method instance string IBase0::Method1() ldstr "G2_C499::Method1.MI.9555()" ret } .method public hidebysig virtual instance string Method2<M0>() cil managed noinlining { ldstr "G2_C499::Method2.9556<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase0.Method2'<M0>() cil managed noinlining { .override method instance string IBase0::Method2<[1]>() ldstr "G2_C499::Method2.MI.9557<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig virtual instance string Method3<M0>() cil managed noinlining { ldstr "G2_C499::Method3.9558<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase0.Method3'<M0>() cil managed noinlining { .override method instance string IBase0::Method3<[1]>() ldstr "G2_C499::Method3.MI.9559<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod2356<M0>() cil managed noinlining { ldstr "G2_C499::ClassMethod2356.9560<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod2357<M0>() cil managed noinlining { ldstr "G2_C499::ClassMethod2357.9561<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'G1_C9<T0,T1>.ClassMethod1339'<M0>() cil managed noinlining { .override method instance string class G1_C9`2<!T0,!T1>::ClassMethod1339<[1]>() ldstr "G2_C499::ClassMethod1339.MI.9562<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void class G1_C9`2<!T0,!T1>::.ctor() ret } } .class interface public abstract IBase1`1<+T0> { .method public hidebysig newslot abstract virtual instance string Method4() cil managed { } .method public hidebysig newslot abstract virtual instance string Method5() cil managed { } .method public hidebysig newslot abstract virtual instance string Method6<M0>() cil managed { } } .class public abstract G1_C9`2<T0, T1> implements class IBase2`2<class BaseClass0,!T0>, class IBase1`1<class BaseClass0> { .method public hidebysig virtual instance string Method7<M0>() cil managed noinlining { ldstr "G1_C9::Method7.4833<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig virtual instance string Method4() cil managed noinlining { ldstr "G1_C9::Method4.4834()" ret } .method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method4'() cil managed noinlining { .override method instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G1_C9::Method4.MI.4835()" ret } .method public hidebysig newslot virtual instance string Method5() cil managed noinlining { ldstr "G1_C9::Method5.4836()" ret } .method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method5'() cil managed noinlining { .override method instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G1_C9::Method5.MI.4837()" ret } .method public hidebysig virtual instance string Method6<M0>() cil managed noinlining { ldstr "G1_C9::Method6.4838<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string 'IBase1<class BaseClass0>.Method6'<M0>() cil managed noinlining { .override method instance string class IBase1`1<class BaseClass0>::Method6<[1]>() ldstr "G1_C9::Method6.MI.4839<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod1336() cil managed noinlining { ldstr "G1_C9::ClassMethod1336.4840()" ret } .method public hidebysig newslot virtual instance string ClassMethod1337() cil managed noinlining { ldstr "G1_C9::ClassMethod1337.4841()" ret } .method public hidebysig newslot virtual instance string ClassMethod1338<M0>() cil managed noinlining { ldstr "G1_C9::ClassMethod1338.4842<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig newslot virtual instance string ClassMethod1339<M0>() cil managed noinlining { ldstr "G1_C9::ClassMethod1339.4843<" ldtoken !!M0 call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) call string [mscorlib]System.String::Concat(object,object) ldstr ">()" call string [mscorlib]System.String::Concat(object,object) ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class interface public abstract IBase0 { .method public hidebysig newslot abstract virtual instance string Method0() cil managed { } .method public hidebysig newslot abstract virtual instance string Method1() cil managed { } .method public hidebysig newslot abstract virtual instance string Method2<M0>() cil managed { } .method public hidebysig newslot abstract virtual instance string Method3<M0>() cil managed { } } .class interface public abstract IBase2`2<+T0, -T1> { .method public hidebysig newslot abstract virtual instance string Method7<M0>() cil managed { } } .class public auto ansi beforefieldinit Generated1007 { .method static void M.BaseClass0<(BaseClass0)W>(!!W inst, string exp) cil managed { .maxstack 5 .locals init (string[] actualResults) ldc.i4.s 0 newarr string stloc.s actualResults ldarg.1 ldstr "M.BaseClass0<(BaseClass0)W>(!!W inst, string exp)" ldc.i4.s 0 ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.BaseClass1<(BaseClass1)W>(!!W inst, string exp) cil managed { .maxstack 5 .locals init (string[] actualResults) ldc.i4.s 0 newarr string stloc.s actualResults ldarg.1 ldstr "M.BaseClass1<(BaseClass1)W>(!!W inst, string exp)" ldc.i4.s 0 ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1479.T<T0,(class G3_C1479`1<!!T0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1479.T<T0,(class G3_C1479`1<!!T0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<!!T0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1479.A<(class G3_C1479`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1479.A<(class G3_C1479`1<class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G3_C1479.B<(class G3_C1479`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G3_C1479.B<(class G3_C1479`1<class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G3_C1479`1<class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.T.T<T0,T1,(class G2_C499`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.T.T<T0,T1,(class G2_C499`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.A.T<T1,(class G2_C499`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.A.T<T1,(class G2_C499`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.A.A<(class G2_C499`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.A.A<(class G2_C499`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.A.B<(class G2_C499`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.A.B<(class G2_C499`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.B.T<T1,(class G2_C499`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.B.T<T1,(class G2_C499`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.B.A<(class G2_C499`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.B.A<(class G2_C499`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G2_C499.B.B<(class G2_C499`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 19 .locals init (string[] actualResults) ldc.i4.s 14 newarr string stloc.s actualResults ldarg.1 ldstr "M.G2_C499.B.B<(class G2_C499`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 14 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2356<object>() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2357<object>() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 8 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 9 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method3<object>() stelem.ref ldloc.s actualResults ldc.i4.s 10 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 11 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 12 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 13 ldarga.s 0 constrained. !!W callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.T<T0,(class IBase1`1<!!T0>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<!!T0>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.A<(class IBase1`1<class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 8 .locals init (string[] actualResults) ldc.i4.s 3 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase1.B<(class IBase1`1<class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 3 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.T.T<T0,T1,(class G1_C9`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.T.T<T0,T1,(class G1_C9`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.A.T<T1,(class G1_C9`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.A.T<T1,(class G1_C9`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.A.A<(class G1_C9`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.A.A<(class G1_C9`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.A.B<(class G1_C9`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.A.B<(class G1_C9`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.B.T<T1,(class G1_C9`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.B.T<T1,(class G1_C9`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.B.A<(class G1_C9`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.B.A<(class G1_C9`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.G1_C9.B.B<(class G1_C9`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 13 .locals init (string[] actualResults) ldc.i4.s 8 newarr string stloc.s actualResults ldarg.1 ldstr "M.G1_C9.B.B<(class G1_C9`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 8 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1336() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1337() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() stelem.ref ldloc.s actualResults ldc.i4.s 4 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method4() stelem.ref ldloc.s actualResults ldc.i4.s 5 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method5() stelem.ref ldloc.s actualResults ldc.i4.s 6 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method6<object>() stelem.ref ldloc.s actualResults ldc.i4.s 7 ldarga.s 0 constrained. !!W callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase0<(IBase0)W>(!!W inst, string exp) cil managed { .maxstack 9 .locals init (string[] actualResults) ldc.i4.s 4 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase0<(IBase0)W>(!!W inst, string exp)" ldc.i4.s 4 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method0() stelem.ref ldloc.s actualResults ldc.i4.s 1 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method1() stelem.ref ldloc.s actualResults ldc.i4.s 2 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method2<object>() stelem.ref ldloc.s actualResults ldc.i4.s 3 ldarga.s 0 constrained. !!W callvirt instance string IBase0::Method3<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.T.T<T0,T1,(class IBase2`2<!!T0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<!!T0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.T<T1,(class IBase2`2<class BaseClass0,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.A<(class IBase2`2<class BaseClass0,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.A.B<(class IBase2`2<class BaseClass0,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.T<T1,(class IBase2`2<class BaseClass1,!!T1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,!!T1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.A<(class IBase2`2<class BaseClass1,class BaseClass0>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,class BaseClass0>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method static void M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp) cil managed { .maxstack 6 .locals init (string[] actualResults) ldc.i4.s 1 newarr string stloc.s actualResults ldarg.1 ldstr "M.IBase2.B.B<(class IBase2`2<class BaseClass1,class BaseClass1>)W>(!!W 'inst', string exp)" ldc.i4.s 1 ldloc.s actualResults ldc.i4.s 0 ldarga.s 0 constrained. !!W callvirt instance string class IBase2`2<class BaseClass1,class BaseClass1>::Method7<object>() stelem.ref ldloc.s actualResults call void [TestFramework]TestFramework::MethodCallTest(string,string,int32,string[]) ret } .method public hidebysig static void MethodCallingTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Method Calling Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1479`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method5() ldstr "G2_C499::Method5.9549()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass0,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2357<object>() ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2356<object>() ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method3<object>() ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method2<object>() ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method1() ldstr "G2_C499::Method1.9554()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method0() ldstr "G2_C499::Method0.9552()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method5() ldstr "G2_C499::Method5.9549()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass0,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass1>::Method5() ldstr "G2_C499::Method5.MI.9550()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G2_C499::Method0.MI.9553()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G2_C499::Method1.MI.9555()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G2_C499::Method2.MI.9557<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G2_C499::Method3.MI.9559<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method6<object>() ldstr "G3_C1479::Method6.16372<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method5() ldstr "G3_C1479::Method5.16370()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod2357<object>() ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod2356<object>() ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method3<object>() ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method2<object>() ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method1() ldstr "G2_C499::Method1.9554()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method0() ldstr "G2_C499::Method0.9552()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass0> callvirt instance string class G3_C1479`1<class BaseClass0>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop newobj instance void class G3_C1479`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method5() ldstr "G2_C499::Method5.9549()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G1_C9`2<class BaseClass1,class BaseClass1> callvirt instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass0>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method5() ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass0>::Method6<object>() ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2357<object>() ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2356<object>() ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method3<object>() ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method2<object>() ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method1() ldstr "G2_C499::Method1.9554()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method0() ldstr "G2_C499::Method0.9552()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method6<object>() ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method5() ldstr "G2_C499::Method5.9549()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method4() ldstr "G2_C499::Method4.9548()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G2_C499`2<class BaseClass1,class BaseClass1> callvirt instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string class IBase1`1<class BaseClass1>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass1>::Method5() ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string class IBase1`1<class BaseClass1>::Method6<object>() ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup callvirt instance string IBase0::Method0() ldstr "G2_C499::Method0.MI.9553()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method1() ldstr "G2_C499::Method1.MI.9555()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method2<object>() ldstr "G2_C499::Method2.MI.9557<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup callvirt instance string IBase0::Method3<object>() ldstr "G2_C499::Method3.MI.9559<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldloc.0 dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method6<object>() ldstr "G3_C1479::Method6.16372<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method5() ldstr "G3_C1479::Method5.16370()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method4() ldstr "G3_C1479::Method4.16369()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod2357<object>() ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod2356<object>() ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method3<object>() ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method2<object>() ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method1() ldstr "G2_C499::Method1.9554()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method0() ldstr "G2_C499::Method0.9552()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1339<object>() ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1338<object>() ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1337() ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::ClassMethod1336() ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) dup castclass class G3_C1479`1<class BaseClass1> callvirt instance string class G3_C1479`1<class BaseClass1>::Method7<object>() ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) pop ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void ConstrainedCallsTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Constrained Calls Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1479`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.T.T<class BaseClass0,class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.A.T<class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.A.B<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.T.T<class BaseClass0,class BaseClass0,class G3_C1479`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.T<class BaseClass0,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.A<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.T<class BaseClass0,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.A<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.T<class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.B<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.T.T<class BaseClass0,class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!2,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.A.T<class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.A.B<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C499::Method4.9548()#G2_C499::Method5.MI.9550()#G2_C499::Method6.9551<System.Object>()#" call void Generated1007::M.IBase1.T<class BaseClass1,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G2_C499::Method4.9548()#G2_C499::Method5.MI.9550()#G2_C499::Method6.9551<System.Object>()#" call void Generated1007::M.IBase1.B<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G2_C499::Method0.MI.9553()#G2_C499::Method1.MI.9555()#G2_C499::Method2.MI.9557<System.Object>()#G2_C499::Method3.MI.9559<System.Object>()#" call void Generated1007::M.IBase0<class G3_C1479`1<class BaseClass0>>(!!0,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G3_C1479::Method4.16369()#G3_C1479::Method5.16370()#G3_C1479::Method6.16372<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G3_C1479.T<class BaseClass0,class G3_C1479`1<class BaseClass0>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G3_C1479::Method4.16369()#G3_C1479::Method5.16370()#G3_C1479::Method6.16372<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G3_C1479.A<class G3_C1479`1<class BaseClass0>>(!!0,string) newobj instance void class G3_C1479`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.T.T<class BaseClass1,class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.B.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G1_C9.B.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.T.T<class BaseClass0,class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.IBase2.A.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.T<class BaseClass0,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.A<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.T.T<class BaseClass1,class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!2,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.B.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G2_C499::Method4.9548()#G2_C499::Method5.9549()#G2_C499::Method6.9551<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G2_C499.B.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G3_C1479::Method4.16369()#G3_C1479::Method5.MI.16371()#G3_C1479::Method6.MI.16373<System.Object>()#" call void Generated1007::M.IBase1.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G2_C499::Method0.MI.9553()#G2_C499::Method1.MI.9555()#G2_C499::Method2.MI.9557<System.Object>()#G2_C499::Method3.MI.9559<System.Object>()#" call void Generated1007::M.IBase0<class G3_C1479`1<class BaseClass1>>(!!0,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G3_C1479::Method4.16369()#G3_C1479::Method5.16370()#G3_C1479::Method6.16372<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G3_C1479.T<class BaseClass1,class G3_C1479`1<class BaseClass1>>(!!1,string) ldloc.0 ldstr "G1_C9::ClassMethod1336.4840()#G1_C9::ClassMethod1337.4841()#G1_C9::ClassMethod1338.4842<System.Object>()#G2_C499::ClassMethod1339.MI.9562<System.Object>()#G3_C1479::ClassMethod2356.MI.16374<System.Object>()#G3_C1479::ClassMethod2357.MI.16375<System.Object>()#G2_C499::Method0.9552()#G2_C499::Method1.9554()#G2_C499::Method2.9556<System.Object>()#G2_C499::Method3.9558<System.Object>()#G3_C1479::Method4.16369()#G3_C1479::Method5.16370()#G3_C1479::Method6.16372<System.Object>()#G1_C9::Method7.4833<System.Object>()#" call void Generated1007::M.G3_C1479.B<class G3_C1479`1<class BaseClass1>>(!!0,string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void StructConstrainedInterfaceCallsTest() cil managed { .maxstack 10 ldstr "===================== Struct Constrained Interface Calls Test =====================" call void [mscorlib]System.Console::WriteLine(string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static void CalliTest() cil managed { .maxstack 10 .locals init (object V_0) ldstr "========================== Method Calli Test ==========================" call void [mscorlib]System.Console::WriteLine(string) newobj instance void class G3_C1479`1<class BaseClass0>::.ctor() stloc.0 ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method5.9549()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method4.9548()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G1_C9`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass0>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2357<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod2356<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method3<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method2<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method1() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method1.9554()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method0() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method0.9552()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method5.9549()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method4.9548()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass0,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G2_C499`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method4.9548()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method5.MI.9550()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method0.MI.9553()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method1.MI.9555()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method2.MI.9557<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method3.MI.9559<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method6.16372<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method5() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method5.16370()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method4() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::Method4.16369()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod2357<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod2356<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method3<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method2<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method1() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method1.9554()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method0() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::Method0.9552()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass0> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass0>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass0>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G3_C1479`1<class BaseClass0> on type class G3_C1479`1<class BaseClass0>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) newobj instance void class G3_C1479`1<class BaseClass1>::.ctor() stloc.0 ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method5.9549()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method4.9548()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G1_C9`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G1_C9`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G1_C9`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase2`2<class BaseClass0,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class IBase2`2<class BaseClass0,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass0>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass0> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2357<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod2356<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method3<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method2<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method1() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method1.9554()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method0() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method0.9552()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method6.9551<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method5.9549()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method4.9548()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G2_C499`2<class BaseClass1,class BaseClass1> ldloc.0 ldvirtftn instance string class G2_C499`2<class BaseClass1,class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G2_C499`2<class BaseClass1,class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method4.16369()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method5.MI.16371()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string class IBase1`1<class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method6.MI.16373<System.Object>()" ldstr "class IBase1`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method0() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method0.MI.9553()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method1() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method1.MI.9555()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method2<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method2.MI.9557<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 ldloc.0 ldvirtftn instance string IBase0::Method3<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method3.MI.9559<System.Object>()" ldstr "IBase0 on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method6<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method6.16372<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method5() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method5.16370()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method4() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::Method4.16369()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod2357<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::ClassMethod2357.MI.16375<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod2356<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G3_C1479::ClassMethod2356.MI.16374<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method3<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method3.9558<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method2<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method2.9556<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method1() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method1.9554()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method0() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::Method0.9552()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod1339<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G2_C499::ClassMethod1339.MI.9562<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod1338<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1338.4842<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod1337() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1337.4841()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::ClassMethod1336() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::ClassMethod1336.4840()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldloc.0 castclass class G3_C1479`1<class BaseClass1> ldloc.0 ldvirtftn instance string class G3_C1479`1<class BaseClass1>::Method7<object>() calli default string(class G3_C1479`1<class BaseClass1>) ldstr "G1_C9::Method7.4833<System.Object>()" ldstr "class G3_C1479`1<class BaseClass1> on type class G3_C1479`1<class BaseClass1>" call void [TestFramework]TestFramework::MethodCallTest(string,string,string) ldstr "========================================================================\n\n" call void [mscorlib]System.Console::WriteLine(string) ret } .method public hidebysig static int32 Main() cil managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .maxstack 10 call void Generated1007::MethodCallingTest() call void Generated1007::ConstrainedCallsTest() call void Generated1007::StructConstrainedInterfaceCallsTest() call void Generated1007::CalliTest() ldc.i4 100 ret } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Directed/FaultHandlers/Nesting/Nesting.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).il" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Dynamic.Runtime/tests/Dynamic.Context/Conformance.dynamic.context.operator.compound.lift.SubEqual.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.CSharp.RuntimeBinder; using Xunit; using static Dynamic.Operator.Tests.LiftCommon; namespace Dynamic.Operator.Tests { public class MinusEqualsLiftTests { [Fact] public static void Bool() { dynamic d = true; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); Assert.Throws<RuntimeBinderException>(() => d -= s_byte); Assert.Throws<RuntimeBinderException>(() => d -= s_char); Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); Assert.Throws<RuntimeBinderException>(() => d -= s_double); Assert.Throws<RuntimeBinderException>(() => d -= s_float); Assert.Throws<RuntimeBinderException>(() => d -= s_int); Assert.Throws<RuntimeBinderException>(() => d -= s_long); Assert.Throws<RuntimeBinderException>(() => d -= s_object); Assert.Throws<RuntimeBinderException>(() => d -= s_sbyte); Assert.Throws<RuntimeBinderException>(() => d -= s_short); d = true; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = true; Assert.Throws<RuntimeBinderException>(() => d -= s_uint); Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); Assert.Throws<RuntimeBinderException>(() => d -= s_ushort); } [Fact] public static void Byte() { dynamic d = (byte)1; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (byte)1; d -= s_byte; d = (byte)1; d -= s_char; d = (byte)1; d -= s_decimal; d = (byte)1; d -= s_double; d = (byte)1; d -= s_float; d = (byte)1; d -= s_int; d = (byte)1; d -= s_long; d = (byte)1; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (byte)1; d -= s_sbyte; d = (byte)1; d -= s_short; d = (byte)1; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (byte)1; d -= s_uint; d = (byte)1; unchecked { d -= s_ulong; } d = (byte)1; d -= s_ushort; } [Fact] public static void Char() { dynamic d = 'a'; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 'a'; d -= s_byte; d = 'a'; d -= s_char; d = 'a'; d -= s_decimal; d = 'a'; d -= s_double; d = 'a'; d -= s_float; d = 'a'; d -= s_int; d = 'a'; d -= s_long; d = 'a'; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 'a'; d -= s_sbyte; d = 'a'; d -= s_short; d = 'a'; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 'a'; d -= s_uint; d = 'a'; d -= s_ulong; d = 'a'; d -= s_ushort; } [Fact] public static void Decimal() { dynamic d = 10m; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10m; d -= s_byte; d = 10m; d -= s_char; d = 10m; d -= s_decimal; d = 10m; Assert.Throws<RuntimeBinderException>(() => d -= s_double); Assert.Throws<RuntimeBinderException>(() => d -= s_float); d = 10m; d -= s_int; d = 10m; d -= s_long; d = 10m; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10m; d -= s_sbyte; d = 10m; d -= s_short; d = 10m; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10m; d -= s_uint; d = 10m; d -= s_ulong; d = 10m; d -= s_ushort; } [Fact] public static void Double() { dynamic d = 10d; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10d; d -= s_byte; d = 10d; d -= s_char; d = 10d; Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); d = 10d; d -= s_double; d = 10d; d -= s_float; d = 10d; d -= s_int; d = 10d; d -= s_long; d = 10d; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10d; d -= s_sbyte; d = 10d; d -= s_short; d = 10d; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10d; d -= s_uint; d = 10d; d -= s_ulong; d = 10d; d -= s_ushort; } [Fact] public static void Float() { dynamic d = 10f; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10f; d -= s_byte; d = 10f; d -= s_char; d = 10f; Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); d = 10f; d -= s_double; d = 10f; d -= s_float; d = 10f; d -= s_int; d = 10f; d -= s_long; d = 10f; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10f; d -= s_sbyte; d = 10f; d -= s_short; d = 10f; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10f; d -= s_uint; d = 10f; d -= s_ulong; d = 10f; d -= s_ushort; } [Fact] public static void Int() { dynamic d = 10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10; d -= s_byte; d = 10; d -= s_char; d = 10; d -= s_decimal; d = 10; d -= s_double; d = 10; d -= s_float; d = 10; d -= s_int; d = 10; d -= s_long; d = 10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10; d -= s_sbyte; d = 10; d -= s_short; d = 10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10; d -= s_uint; d = 10; Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); d = 10; d -= s_ushort; } [Fact] public static void Long() { dynamic d = 10L; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10L; d -= s_byte; d = 10L; d -= s_char; d = 10L; d -= s_decimal; d = 10L; d -= s_double; d = 10L; d -= s_float; d = 10L; d -= s_int; d = 10L; d -= s_long; d = 10L; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10L; d -= s_sbyte; d = 10L; d -= s_short; d = 10L; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10L; d -= s_uint; d = 10L; Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); d = 10L; d -= s_ushort; } [Fact] public static void Object() { dynamic d = new object(); Assert.Throws<RuntimeBinderException>(() => d -= s_bool); Assert.Throws<RuntimeBinderException>(() => d -= s_byte); Assert.Throws<RuntimeBinderException>(() => d -= s_char); Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); Assert.Throws<RuntimeBinderException>(() => d -= s_double); Assert.Throws<RuntimeBinderException>(() => d -= s_float); Assert.Throws<RuntimeBinderException>(() => d -= s_int); Assert.Throws<RuntimeBinderException>(() => d -= s_long); Assert.Throws<RuntimeBinderException>(() => d -= s_object); Assert.Throws<RuntimeBinderException>(() => d -= s_sbyte); Assert.Throws<RuntimeBinderException>(() => d -= s_short); d = new object(); Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = new object(); Assert.Throws<RuntimeBinderException>(() => d -= s_uint); Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); Assert.Throws<RuntimeBinderException>(() => d -= s_ushort); } [Fact] public static void SByte() { dynamic d = (sbyte)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (sbyte)10; d -= s_byte; d = (sbyte)10; d -= s_char; d = (sbyte)10; d -= s_decimal; d = (sbyte)10; d -= s_double; d = (sbyte)10; d -= s_float; d = (sbyte)10; d -= s_int; d = (sbyte)10; d -= s_long; d = (sbyte)10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (sbyte)10; d -= s_sbyte; d = (sbyte)10; d -= s_short; d = (sbyte)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (sbyte)10; d -= s_uint; d = (sbyte)10; Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); d = (sbyte)10; d -= s_ushort; } [Fact] public static void Short() { dynamic d = (short)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (short)10; d -= s_byte; d = (short)10; d -= s_char; d = (short)10; d -= s_decimal; d = (short)10; d -= s_double; d = (short)10; d -= s_float; d = (short)10; d -= s_int; d = (short)10; d -= s_long; d = (short)10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (short)10; d -= s_sbyte; d = (short)10; d -= s_short; d = (short)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (short)10; d -= s_uint; d = (short)10; Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); d = (short)10; d -= s_ushort; } [Fact] public static void String() { dynamic d = "a"; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); Assert.Throws<RuntimeBinderException>(() => d -= s_byte); Assert.Throws<RuntimeBinderException>(() => d -= s_char); Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); Assert.Throws<RuntimeBinderException>(() => d -= s_double); Assert.Throws<RuntimeBinderException>(() => d -= s_float); Assert.Throws<RuntimeBinderException>(() => d -= s_int); Assert.Throws<RuntimeBinderException>(() => d -= s_long); Assert.Throws<RuntimeBinderException>(() => d -= s_object); Assert.Throws<RuntimeBinderException>(() => d -= s_sbyte); Assert.Throws<RuntimeBinderException>(() => d -= s_short); Assert.Throws<RuntimeBinderException>(() => d -= s_string); Assert.Throws<RuntimeBinderException>(() => d -= s_uint); Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); Assert.Throws<RuntimeBinderException>(() => d -= s_ushort); } [Fact] public static void UInt() { dynamic d = (uint)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (uint)10; d -= s_byte; d = (uint)10; d -= s_char; d = (uint)10; d -= s_decimal; d = (uint)10; d -= s_double; d = (uint)10; d -= s_float; d = (uint)10; d -= s_int; d = (uint)10; d -= s_long; d = (uint)10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (uint)10; d -= s_sbyte; d = (uint)10; d -= s_short; d = (uint)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (uint)10; d -= s_uint; d = (uint)10; d -= s_ulong; d = (uint)10; d -= s_ushort; } [Fact] public static void ULong() { dynamic d = (ulong)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (ulong)10; d -= s_byte; d = (ulong)10; d -= s_char; d = (ulong)10; d -= s_decimal; d = (ulong)10; d -= s_double; d = (ulong)10; d -= s_float; d = (ulong)10; Assert.Throws<RuntimeBinderException>(() => d -= s_int); Assert.Throws<RuntimeBinderException>(() => d -= s_long); Assert.Throws<RuntimeBinderException>(() => d -= s_object); Assert.Throws<RuntimeBinderException>(() => d -= s_sbyte); Assert.Throws<RuntimeBinderException>(() => d -= s_short); d = (ulong)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (ulong)10; d -= s_uint; d = (ulong)10; d -= s_ulong; d = (ulong)10; d -= s_ushort; } [Fact] public static void UShort() { dynamic d = (ushort)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (ushort)10; d -= s_byte; d = (ushort)10; d -= s_char; d = (ushort)10; d -= s_decimal; d = (ushort)10; d -= s_double; d = (ushort)10; d -= s_float; d = (ushort)10; d -= s_int; d = (ushort)10; d -= s_long; d = (ushort)10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (ushort)10; d -= s_sbyte; d = (ushort)10; d -= s_short; d = (ushort)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (ushort)10; d -= s_uint; d = (ushort)10; d -= s_ulong; d = (ushort)10; d -= s_ushort; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.CSharp.RuntimeBinder; using Xunit; using static Dynamic.Operator.Tests.LiftCommon; namespace Dynamic.Operator.Tests { public class MinusEqualsLiftTests { [Fact] public static void Bool() { dynamic d = true; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); Assert.Throws<RuntimeBinderException>(() => d -= s_byte); Assert.Throws<RuntimeBinderException>(() => d -= s_char); Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); Assert.Throws<RuntimeBinderException>(() => d -= s_double); Assert.Throws<RuntimeBinderException>(() => d -= s_float); Assert.Throws<RuntimeBinderException>(() => d -= s_int); Assert.Throws<RuntimeBinderException>(() => d -= s_long); Assert.Throws<RuntimeBinderException>(() => d -= s_object); Assert.Throws<RuntimeBinderException>(() => d -= s_sbyte); Assert.Throws<RuntimeBinderException>(() => d -= s_short); d = true; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = true; Assert.Throws<RuntimeBinderException>(() => d -= s_uint); Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); Assert.Throws<RuntimeBinderException>(() => d -= s_ushort); } [Fact] public static void Byte() { dynamic d = (byte)1; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (byte)1; d -= s_byte; d = (byte)1; d -= s_char; d = (byte)1; d -= s_decimal; d = (byte)1; d -= s_double; d = (byte)1; d -= s_float; d = (byte)1; d -= s_int; d = (byte)1; d -= s_long; d = (byte)1; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (byte)1; d -= s_sbyte; d = (byte)1; d -= s_short; d = (byte)1; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (byte)1; d -= s_uint; d = (byte)1; unchecked { d -= s_ulong; } d = (byte)1; d -= s_ushort; } [Fact] public static void Char() { dynamic d = 'a'; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 'a'; d -= s_byte; d = 'a'; d -= s_char; d = 'a'; d -= s_decimal; d = 'a'; d -= s_double; d = 'a'; d -= s_float; d = 'a'; d -= s_int; d = 'a'; d -= s_long; d = 'a'; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 'a'; d -= s_sbyte; d = 'a'; d -= s_short; d = 'a'; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 'a'; d -= s_uint; d = 'a'; d -= s_ulong; d = 'a'; d -= s_ushort; } [Fact] public static void Decimal() { dynamic d = 10m; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10m; d -= s_byte; d = 10m; d -= s_char; d = 10m; d -= s_decimal; d = 10m; Assert.Throws<RuntimeBinderException>(() => d -= s_double); Assert.Throws<RuntimeBinderException>(() => d -= s_float); d = 10m; d -= s_int; d = 10m; d -= s_long; d = 10m; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10m; d -= s_sbyte; d = 10m; d -= s_short; d = 10m; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10m; d -= s_uint; d = 10m; d -= s_ulong; d = 10m; d -= s_ushort; } [Fact] public static void Double() { dynamic d = 10d; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10d; d -= s_byte; d = 10d; d -= s_char; d = 10d; Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); d = 10d; d -= s_double; d = 10d; d -= s_float; d = 10d; d -= s_int; d = 10d; d -= s_long; d = 10d; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10d; d -= s_sbyte; d = 10d; d -= s_short; d = 10d; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10d; d -= s_uint; d = 10d; d -= s_ulong; d = 10d; d -= s_ushort; } [Fact] public static void Float() { dynamic d = 10f; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10f; d -= s_byte; d = 10f; d -= s_char; d = 10f; Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); d = 10f; d -= s_double; d = 10f; d -= s_float; d = 10f; d -= s_int; d = 10f; d -= s_long; d = 10f; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10f; d -= s_sbyte; d = 10f; d -= s_short; d = 10f; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10f; d -= s_uint; d = 10f; d -= s_ulong; d = 10f; d -= s_ushort; } [Fact] public static void Int() { dynamic d = 10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10; d -= s_byte; d = 10; d -= s_char; d = 10; d -= s_decimal; d = 10; d -= s_double; d = 10; d -= s_float; d = 10; d -= s_int; d = 10; d -= s_long; d = 10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10; d -= s_sbyte; d = 10; d -= s_short; d = 10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10; d -= s_uint; d = 10; Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); d = 10; d -= s_ushort; } [Fact] public static void Long() { dynamic d = 10L; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = 10L; d -= s_byte; d = 10L; d -= s_char; d = 10L; d -= s_decimal; d = 10L; d -= s_double; d = 10L; d -= s_float; d = 10L; d -= s_int; d = 10L; d -= s_long; d = 10L; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = 10L; d -= s_sbyte; d = 10L; d -= s_short; d = 10L; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = 10L; d -= s_uint; d = 10L; Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); d = 10L; d -= s_ushort; } [Fact] public static void Object() { dynamic d = new object(); Assert.Throws<RuntimeBinderException>(() => d -= s_bool); Assert.Throws<RuntimeBinderException>(() => d -= s_byte); Assert.Throws<RuntimeBinderException>(() => d -= s_char); Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); Assert.Throws<RuntimeBinderException>(() => d -= s_double); Assert.Throws<RuntimeBinderException>(() => d -= s_float); Assert.Throws<RuntimeBinderException>(() => d -= s_int); Assert.Throws<RuntimeBinderException>(() => d -= s_long); Assert.Throws<RuntimeBinderException>(() => d -= s_object); Assert.Throws<RuntimeBinderException>(() => d -= s_sbyte); Assert.Throws<RuntimeBinderException>(() => d -= s_short); d = new object(); Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = new object(); Assert.Throws<RuntimeBinderException>(() => d -= s_uint); Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); Assert.Throws<RuntimeBinderException>(() => d -= s_ushort); } [Fact] public static void SByte() { dynamic d = (sbyte)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (sbyte)10; d -= s_byte; d = (sbyte)10; d -= s_char; d = (sbyte)10; d -= s_decimal; d = (sbyte)10; d -= s_double; d = (sbyte)10; d -= s_float; d = (sbyte)10; d -= s_int; d = (sbyte)10; d -= s_long; d = (sbyte)10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (sbyte)10; d -= s_sbyte; d = (sbyte)10; d -= s_short; d = (sbyte)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (sbyte)10; d -= s_uint; d = (sbyte)10; Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); d = (sbyte)10; d -= s_ushort; } [Fact] public static void Short() { dynamic d = (short)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (short)10; d -= s_byte; d = (short)10; d -= s_char; d = (short)10; d -= s_decimal; d = (short)10; d -= s_double; d = (short)10; d -= s_float; d = (short)10; d -= s_int; d = (short)10; d -= s_long; d = (short)10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (short)10; d -= s_sbyte; d = (short)10; d -= s_short; d = (short)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (short)10; d -= s_uint; d = (short)10; Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); d = (short)10; d -= s_ushort; } [Fact] public static void String() { dynamic d = "a"; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); Assert.Throws<RuntimeBinderException>(() => d -= s_byte); Assert.Throws<RuntimeBinderException>(() => d -= s_char); Assert.Throws<RuntimeBinderException>(() => d -= s_decimal); Assert.Throws<RuntimeBinderException>(() => d -= s_double); Assert.Throws<RuntimeBinderException>(() => d -= s_float); Assert.Throws<RuntimeBinderException>(() => d -= s_int); Assert.Throws<RuntimeBinderException>(() => d -= s_long); Assert.Throws<RuntimeBinderException>(() => d -= s_object); Assert.Throws<RuntimeBinderException>(() => d -= s_sbyte); Assert.Throws<RuntimeBinderException>(() => d -= s_short); Assert.Throws<RuntimeBinderException>(() => d -= s_string); Assert.Throws<RuntimeBinderException>(() => d -= s_uint); Assert.Throws<RuntimeBinderException>(() => d -= s_ulong); Assert.Throws<RuntimeBinderException>(() => d -= s_ushort); } [Fact] public static void UInt() { dynamic d = (uint)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (uint)10; d -= s_byte; d = (uint)10; d -= s_char; d = (uint)10; d -= s_decimal; d = (uint)10; d -= s_double; d = (uint)10; d -= s_float; d = (uint)10; d -= s_int; d = (uint)10; d -= s_long; d = (uint)10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (uint)10; d -= s_sbyte; d = (uint)10; d -= s_short; d = (uint)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (uint)10; d -= s_uint; d = (uint)10; d -= s_ulong; d = (uint)10; d -= s_ushort; } [Fact] public static void ULong() { dynamic d = (ulong)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (ulong)10; d -= s_byte; d = (ulong)10; d -= s_char; d = (ulong)10; d -= s_decimal; d = (ulong)10; d -= s_double; d = (ulong)10; d -= s_float; d = (ulong)10; Assert.Throws<RuntimeBinderException>(() => d -= s_int); Assert.Throws<RuntimeBinderException>(() => d -= s_long); Assert.Throws<RuntimeBinderException>(() => d -= s_object); Assert.Throws<RuntimeBinderException>(() => d -= s_sbyte); Assert.Throws<RuntimeBinderException>(() => d -= s_short); d = (ulong)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (ulong)10; d -= s_uint; d = (ulong)10; d -= s_ulong; d = (ulong)10; d -= s_ushort; } [Fact] public static void UShort() { dynamic d = (ushort)10; Assert.Throws<RuntimeBinderException>(() => d -= s_bool); d = (ushort)10; d -= s_byte; d = (ushort)10; d -= s_char; d = (ushort)10; d -= s_decimal; d = (ushort)10; d -= s_double; d = (ushort)10; d -= s_float; d = (ushort)10; d -= s_int; d = (ushort)10; d -= s_long; d = (ushort)10; Assert.Throws<RuntimeBinderException>(() => d -= s_object); d = (ushort)10; d -= s_sbyte; d = (ushort)10; d -= s_short; d = (ushort)10; Assert.Throws<RuntimeBinderException>(() => d -= s_string); d = (ushort)10; d -= s_uint; d = (ushort)10; d -= s_ulong; d = (ushort)10; d -= s_ushort; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Globalization.Calendars/tests/ISOWeek/ISOWeekTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using Xunit; namespace System.Globalization { public static class ISOWeekTests { // The following 71 years in a 400-year cycle have 53 weeks (371 days). // Years not listed have 52 weeks (364 days). Add 2000 for current years. private static readonly HashSet<int> s_yearsWith53Weeks = new HashSet<int> { 004, 009, 015, 020, 026, 032, 037, 043, 048, 054, 060, 065, 071, 076, 082, 088, 093, 099, 105, 111, 116, 122, 128, 133, 139, 144, 150, 156, 161, 167, 172, 178, 184, 189, 195, 201, 207, 212, 218, 224, 229, 235, 240, 246, 252, 257, 263, 268, 274, 280, 285, 291, 296, 303, 308, 314, 320, 325, 331, 336, 342, 348, 353, 359, 364, 370, 376, 381, 387, 392, 398 }; // From https://en.wikipedia.org/wiki/ISO_week_date#Relation_with_the_Gregorian_calendar. private static readonly DateData[] s_dateData = { new DateData(new DateTime(0001, 01, 01), 0001, 01, DayOfWeek.Monday), new DateData(new DateTime(2005, 01, 01), 2004, 53, DayOfWeek.Saturday), new DateData(new DateTime(2005, 01, 02), 2004, 53, DayOfWeek.Sunday), new DateData(new DateTime(2005, 12, 31), 2005, 52, DayOfWeek.Saturday), new DateData(new DateTime(2006, 01, 01), 2005, 52, DayOfWeek.Sunday), new DateData(new DateTime(2006, 01, 02), 2006, 01, DayOfWeek.Monday), new DateData(new DateTime(2006, 12, 31), 2006, 52, DayOfWeek.Sunday), new DateData(new DateTime(2007, 01, 01), 2007, 01, DayOfWeek.Monday), new DateData(new DateTime(2007, 12, 30), 2007, 52, DayOfWeek.Sunday), new DateData(new DateTime(2007, 12, 31), 2008, 01, DayOfWeek.Monday), new DateData(new DateTime(2008, 01, 01), 2008, 01, DayOfWeek.Tuesday), new DateData(new DateTime(2008, 12, 28), 2008, 52, DayOfWeek.Sunday), new DateData(new DateTime(2008, 12, 29), 2009, 01, DayOfWeek.Monday), new DateData(new DateTime(2008, 12, 30), 2009, 01, DayOfWeek.Tuesday), new DateData(new DateTime(2008, 12, 31), 2009, 01, DayOfWeek.Wednesday), new DateData(new DateTime(2009, 01, 01), 2009, 01, DayOfWeek.Thursday), new DateData(new DateTime(2009, 12, 31), 2009, 53, DayOfWeek.Thursday), new DateData(new DateTime(2010, 01, 01), 2009, 53, DayOfWeek.Friday), new DateData(new DateTime(2010, 01, 02), 2009, 53, DayOfWeek.Saturday), new DateData(new DateTime(2010, 01, 03), 2009, 53, DayOfWeek.Sunday), new DateData(new DateTime(9999, 12, 31), 9999, 52, DayOfWeek.Friday), }; private static readonly YearData[] s_yearData = { new YearData(0001, new DateTime(0001, 01, 01), new DateTime(0001, 12, 30)), new YearData(2005, new DateTime(2005, 01, 03), new DateTime(2006, 01, 01)), new YearData(2006, new DateTime(2006, 01, 02), new DateTime(2006, 12, 31)), new YearData(2007, new DateTime(2007, 01, 01), new DateTime(2007, 12, 30)), new YearData(2008, new DateTime(2007, 12, 31), new DateTime(2008, 12, 28)), new YearData(2009, new DateTime(2008, 12, 29), new DateTime(2010, 01, 03)), new YearData(9998, new DateTime(9997, 12, 29), new DateTime(9999, 01, 03)), }; public static IEnumerable<object[]> GetWeekOfYear_TestData() { return s_dateData.Select(x => new object[] {x.Date, x.Week}); } public static IEnumerable<object[]> GetYear_TestData() { return s_dateData.Select(x => new object[] {x.Date, x.Year}); } public static IEnumerable<object[]> ToDateTime_TestData() { return s_dateData.Select(x => new object[] {x.Year, x.Week, x.DayOfWeek, x.Date}); } public static IEnumerable<object[]> GetYearStart_TestData() { return s_yearData.Select(x => new object[] {x.Year, x.StartDate}); } public static IEnumerable<object[]> GetYearEnd_TestData() { return s_yearData.Select(x => new object[] {x.Year, x.EndDate}); } [Theory, MemberData(nameof(GetWeekOfYear_TestData))] public static void GetWeekOfYear(DateTime date, int expected) { Assert.Equal(expected, ISOWeek.GetWeekOfYear(date)); } [Theory, MemberData(nameof(GetYear_TestData))] public static void GetYear(DateTime date, int expected) { Assert.Equal(expected, ISOWeek.GetYear(date)); } [Theory, MemberData(nameof(ToDateTime_TestData))] public static void ToDateTime(int year, int week, DayOfWeek dayOfWeek, DateTime expected) { Assert.Equal(expected, ISOWeek.ToDateTime(year, week, dayOfWeek)); } [Theory] [InlineData(0)] [InlineData(10000)] public static void ToDateTime_WithInvalidYear_Throws(int year) { AssertExtensions.Throws<ArgumentOutOfRangeException>(nameof(year), () => ISOWeek.ToDateTime(year, 1, DayOfWeek.Friday)); } [Theory] [InlineData(0)] [InlineData(54)] public static void ToDateTime_WithInvalidWeek_Throws(int week) { AssertExtensions.Throws<ArgumentOutOfRangeException>(nameof(week), () => ISOWeek.ToDateTime(2018, week, DayOfWeek.Friday)); } [Theory] [InlineData(-1)] [InlineData(8)] public static void ToDateTime_WithInvalidDayOfWeek_Throws(int dayOfWeek) { AssertExtensions.Throws<ArgumentOutOfRangeException>(nameof(dayOfWeek), () => ISOWeek.ToDateTime(2018, 1, (DayOfWeek)dayOfWeek)); } [Fact] public static void GetWeeksInYear() { for (int year = 0; year <= 400; year++) { int expected = s_yearsWith53Weeks.Contains(year) ? 53 : 52; Assert.Equal(expected, ISOWeek.GetWeeksInYear(2000 + year)); } } [Theory] [InlineData(0)] [InlineData(10000)] public static void GetWeeksInYear_WithInvalidYear_Throws(int year) { AssertExtensions.Throws<ArgumentOutOfRangeException>(nameof(year), () => ISOWeek.GetWeeksInYear(year)); } [Theory, MemberData(nameof(GetYearStart_TestData))] public static void GetYearStart(int year, DateTime expected) { Assert.Equal(expected, ISOWeek.GetYearStart(year)); } [Theory, MemberData(nameof(GetYearEnd_TestData))] public static void GetYearEnd(int year, DateTime expected) { Assert.Equal(expected, ISOWeek.GetYearEnd(year)); } [Fact] public static void GetYearEnd_ForYear9999_Throws() { AssertExtensions.Throws<ArgumentOutOfRangeException>("value", () => ISOWeek.GetYearEnd(9999)); } private struct DateData { public readonly DateTime Date; public readonly int Year; public readonly int Week; public readonly DayOfWeek DayOfWeek; public DateData(DateTime date, int year, int week, DayOfWeek dayOfWeek) { Date = date; Year = year; Week = week; DayOfWeek = dayOfWeek; } } private struct YearData { public readonly int Year; public readonly DateTime StartDate; public readonly DateTime EndDate; public YearData(int year, DateTime startDate, DateTime endDate) { Year = year; StartDate = startDate; EndDate = endDate; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using Xunit; namespace System.Globalization { public static class ISOWeekTests { // The following 71 years in a 400-year cycle have 53 weeks (371 days). // Years not listed have 52 weeks (364 days). Add 2000 for current years. private static readonly HashSet<int> s_yearsWith53Weeks = new HashSet<int> { 004, 009, 015, 020, 026, 032, 037, 043, 048, 054, 060, 065, 071, 076, 082, 088, 093, 099, 105, 111, 116, 122, 128, 133, 139, 144, 150, 156, 161, 167, 172, 178, 184, 189, 195, 201, 207, 212, 218, 224, 229, 235, 240, 246, 252, 257, 263, 268, 274, 280, 285, 291, 296, 303, 308, 314, 320, 325, 331, 336, 342, 348, 353, 359, 364, 370, 376, 381, 387, 392, 398 }; // From https://en.wikipedia.org/wiki/ISO_week_date#Relation_with_the_Gregorian_calendar. private static readonly DateData[] s_dateData = { new DateData(new DateTime(0001, 01, 01), 0001, 01, DayOfWeek.Monday), new DateData(new DateTime(2005, 01, 01), 2004, 53, DayOfWeek.Saturday), new DateData(new DateTime(2005, 01, 02), 2004, 53, DayOfWeek.Sunday), new DateData(new DateTime(2005, 12, 31), 2005, 52, DayOfWeek.Saturday), new DateData(new DateTime(2006, 01, 01), 2005, 52, DayOfWeek.Sunday), new DateData(new DateTime(2006, 01, 02), 2006, 01, DayOfWeek.Monday), new DateData(new DateTime(2006, 12, 31), 2006, 52, DayOfWeek.Sunday), new DateData(new DateTime(2007, 01, 01), 2007, 01, DayOfWeek.Monday), new DateData(new DateTime(2007, 12, 30), 2007, 52, DayOfWeek.Sunday), new DateData(new DateTime(2007, 12, 31), 2008, 01, DayOfWeek.Monday), new DateData(new DateTime(2008, 01, 01), 2008, 01, DayOfWeek.Tuesday), new DateData(new DateTime(2008, 12, 28), 2008, 52, DayOfWeek.Sunday), new DateData(new DateTime(2008, 12, 29), 2009, 01, DayOfWeek.Monday), new DateData(new DateTime(2008, 12, 30), 2009, 01, DayOfWeek.Tuesday), new DateData(new DateTime(2008, 12, 31), 2009, 01, DayOfWeek.Wednesday), new DateData(new DateTime(2009, 01, 01), 2009, 01, DayOfWeek.Thursday), new DateData(new DateTime(2009, 12, 31), 2009, 53, DayOfWeek.Thursday), new DateData(new DateTime(2010, 01, 01), 2009, 53, DayOfWeek.Friday), new DateData(new DateTime(2010, 01, 02), 2009, 53, DayOfWeek.Saturday), new DateData(new DateTime(2010, 01, 03), 2009, 53, DayOfWeek.Sunday), new DateData(new DateTime(9999, 12, 31), 9999, 52, DayOfWeek.Friday), }; private static readonly YearData[] s_yearData = { new YearData(0001, new DateTime(0001, 01, 01), new DateTime(0001, 12, 30)), new YearData(2005, new DateTime(2005, 01, 03), new DateTime(2006, 01, 01)), new YearData(2006, new DateTime(2006, 01, 02), new DateTime(2006, 12, 31)), new YearData(2007, new DateTime(2007, 01, 01), new DateTime(2007, 12, 30)), new YearData(2008, new DateTime(2007, 12, 31), new DateTime(2008, 12, 28)), new YearData(2009, new DateTime(2008, 12, 29), new DateTime(2010, 01, 03)), new YearData(9998, new DateTime(9997, 12, 29), new DateTime(9999, 01, 03)), }; public static IEnumerable<object[]> GetWeekOfYear_TestData() { return s_dateData.Select(x => new object[] {x.Date, x.Week}); } public static IEnumerable<object[]> GetYear_TestData() { return s_dateData.Select(x => new object[] {x.Date, x.Year}); } public static IEnumerable<object[]> ToDateTime_TestData() { return s_dateData.Select(x => new object[] {x.Year, x.Week, x.DayOfWeek, x.Date}); } public static IEnumerable<object[]> GetYearStart_TestData() { return s_yearData.Select(x => new object[] {x.Year, x.StartDate}); } public static IEnumerable<object[]> GetYearEnd_TestData() { return s_yearData.Select(x => new object[] {x.Year, x.EndDate}); } [Theory, MemberData(nameof(GetWeekOfYear_TestData))] public static void GetWeekOfYear(DateTime date, int expected) { Assert.Equal(expected, ISOWeek.GetWeekOfYear(date)); } [Theory, MemberData(nameof(GetYear_TestData))] public static void GetYear(DateTime date, int expected) { Assert.Equal(expected, ISOWeek.GetYear(date)); } [Theory, MemberData(nameof(ToDateTime_TestData))] public static void ToDateTime(int year, int week, DayOfWeek dayOfWeek, DateTime expected) { Assert.Equal(expected, ISOWeek.ToDateTime(year, week, dayOfWeek)); } [Theory] [InlineData(0)] [InlineData(10000)] public static void ToDateTime_WithInvalidYear_Throws(int year) { AssertExtensions.Throws<ArgumentOutOfRangeException>(nameof(year), () => ISOWeek.ToDateTime(year, 1, DayOfWeek.Friday)); } [Theory] [InlineData(0)] [InlineData(54)] public static void ToDateTime_WithInvalidWeek_Throws(int week) { AssertExtensions.Throws<ArgumentOutOfRangeException>(nameof(week), () => ISOWeek.ToDateTime(2018, week, DayOfWeek.Friday)); } [Theory] [InlineData(-1)] [InlineData(8)] public static void ToDateTime_WithInvalidDayOfWeek_Throws(int dayOfWeek) { AssertExtensions.Throws<ArgumentOutOfRangeException>(nameof(dayOfWeek), () => ISOWeek.ToDateTime(2018, 1, (DayOfWeek)dayOfWeek)); } [Fact] public static void GetWeeksInYear() { for (int year = 0; year <= 400; year++) { int expected = s_yearsWith53Weeks.Contains(year) ? 53 : 52; Assert.Equal(expected, ISOWeek.GetWeeksInYear(2000 + year)); } } [Theory] [InlineData(0)] [InlineData(10000)] public static void GetWeeksInYear_WithInvalidYear_Throws(int year) { AssertExtensions.Throws<ArgumentOutOfRangeException>(nameof(year), () => ISOWeek.GetWeeksInYear(year)); } [Theory, MemberData(nameof(GetYearStart_TestData))] public static void GetYearStart(int year, DateTime expected) { Assert.Equal(expected, ISOWeek.GetYearStart(year)); } [Theory, MemberData(nameof(GetYearEnd_TestData))] public static void GetYearEnd(int year, DateTime expected) { Assert.Equal(expected, ISOWeek.GetYearEnd(year)); } [Fact] public static void GetYearEnd_ForYear9999_Throws() { AssertExtensions.Throws<ArgumentOutOfRangeException>("value", () => ISOWeek.GetYearEnd(9999)); } private struct DateData { public readonly DateTime Date; public readonly int Year; public readonly int Week; public readonly DayOfWeek DayOfWeek; public DateData(DateTime date, int year, int week, DayOfWeek dayOfWeek) { Date = date; Year = year; Week = week; DayOfWeek = dayOfWeek; } } private struct YearData { public readonly int Year; public readonly DateTime StartDate; public readonly DateTime EndDate; public YearData(int year, DateTime startDate, DateTime endDate) { Year = year; StartDate = startDate; EndDate = endDate; } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Regression/JitBlue/GitHub_16377/GitHub_16377.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType /> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType /> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/mono/wasm/runtime/method-binding.ts
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. import { WasmRoot, WasmRootBuffer, mono_wasm_new_root } from "./roots"; import { MonoClass, MonoMethod, MonoObject, coerceNull, VoidPtrNull, MonoType, MarshalType } from "./types"; import { BINDING, Module, runtimeHelpers } from "./imports"; import { js_to_mono_enum, _js_to_mono_obj, _js_to_mono_uri } from "./js-to-cs"; import { js_string_to_mono_string, js_string_to_mono_string_interned } from "./strings"; import { _unbox_mono_obj_root_with_known_nonprimitive_type } from "./cs-to-js"; import { _create_temp_frame, getI32, getU32, getF32, getF64, setI32, setU32, setF32, setF64, setI64, } from "./memory"; import { _get_args_root_buffer_for_method_call, _get_buffer_for_method_call, _handle_exception_for_call, _teardown_after_call } from "./method-calls"; import cwraps from "./cwraps"; import { VoidPtr } from "./types/emscripten"; const primitiveConverters = new Map<string, Converter>(); const _signature_converters = new Map<string, Converter>(); const _method_descriptions = new Map<MonoMethod, string>(); export function _get_type_name(typePtr: MonoType): string { if (!typePtr) return "<null>"; return cwraps.mono_wasm_get_type_name(typePtr); } export function _get_type_aqn(typePtr: MonoType): string { if (!typePtr) return "<null>"; return cwraps.mono_wasm_get_type_aqn(typePtr); } export function _get_class_name(classPtr: MonoClass): string { if (!classPtr) return "<null>"; return cwraps.mono_wasm_get_type_name(cwraps.mono_wasm_class_get_type(classPtr)); } export function find_method(klass: MonoClass, name: string, n: number): MonoMethod { const result = cwraps.mono_wasm_assembly_find_method(klass, name, n); if (result) { _method_descriptions.set(result, name); } return result; } export function get_method(method_name: string): MonoMethod { const res = find_method(runtimeHelpers.wasm_runtime_class, method_name, -1); if (!res) throw "Can't find method " + runtimeHelpers.runtime_namespace + "." + runtimeHelpers.runtime_classname + ":" + method_name; return res; } export function bind_runtime_method(method_name: string, signature: string): Function { const method = get_method(method_name); return mono_bind_method(method, null, signature, "BINDINGS_" + method_name); } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export function _create_named_function(name: string, argumentNames: string[], body: string, closure: any): Function { let result = null; let closureArgumentList: any[] | null = null; let closureArgumentNames = null; if (closure) { closureArgumentNames = Object.keys(closure); closureArgumentList = new Array(closureArgumentNames.length); for (let i = 0, l = closureArgumentNames.length; i < l; i++) closureArgumentList[i] = closure[closureArgumentNames[i]]; } const constructor = _create_rebindable_named_function(name, argumentNames, body, closureArgumentNames); // eslint-disable-next-line prefer-spread result = constructor.apply(null, closureArgumentList); return result; } export function _create_rebindable_named_function(name: string, argumentNames: string[], body: string, closureArgNames: string[] | null): Function { const strictPrefix = "\"use strict\";\r\n"; let uriPrefix = "", escapedFunctionIdentifier = ""; if (name) { uriPrefix = "//# sourceURL=https://mono-wasm.invalid/" + name + "\r\n"; escapedFunctionIdentifier = name; } else { escapedFunctionIdentifier = "unnamed"; } let rawFunctionText = "function " + escapedFunctionIdentifier + "(" + argumentNames.join(", ") + ") {\r\n" + body + "\r\n};\r\n"; const lineBreakRE = /\r(\n?)/g; rawFunctionText = uriPrefix + strictPrefix + rawFunctionText.replace(lineBreakRE, "\r\n ") + ` return ${escapedFunctionIdentifier};\r\n`; let result = null, keys = null; if (closureArgNames) { keys = closureArgNames.concat([rawFunctionText]); } else { keys = [rawFunctionText]; } result = Function.apply(Function, keys); return result; } export function _create_primitive_converters(): void { const result = primitiveConverters; result.set("m", { steps: [{}], size: 0 }); result.set("s", { steps: [{ convert: js_string_to_mono_string.bind(BINDING) }], size: 0, needs_root: true }); result.set("S", { steps: [{ convert: js_string_to_mono_string_interned.bind(BINDING) }], size: 0, needs_root: true }); // note we also bind first argument to false for both _js_to_mono_obj and _js_to_mono_uri, // because we will root the reference, so we don't need in-flight reference // also as those are callback arguments and we don't have platform code which would release the in-flight reference on C# end result.set("o", { steps: [{ convert: _js_to_mono_obj.bind(BINDING, false) }], size: 0, needs_root: true }); result.set("u", { steps: [{ convert: _js_to_mono_uri.bind(BINDING, false) }], size: 0, needs_root: true }); // result.set ('k', { steps: [{ convert: js_to_mono_enum.bind (this), indirect: 'i64'}], size: 8}); result.set("j", { steps: [{ convert: js_to_mono_enum.bind(BINDING), indirect: "i32" }], size: 8 }); result.set("i", { steps: [{ indirect: "i32" }], size: 8 }); result.set("l", { steps: [{ indirect: "i64" }], size: 8 }); result.set("f", { steps: [{ indirect: "float" }], size: 8 }); result.set("d", { steps: [{ indirect: "double" }], size: 8 }); } function _create_converter_for_marshal_string(args_marshal: string/*ArgsMarshalString*/): Converter { const steps = []; let size = 0; let is_result_definitely_unmarshaled = false, is_result_possibly_unmarshaled = false, result_unmarshaled_if_argc = -1, needs_root_buffer = false; for (let i = 0; i < args_marshal.length; ++i) { const key = args_marshal[i]; if (i === args_marshal.length - 1) { if (key === "!") { is_result_definitely_unmarshaled = true; continue; } else if (key === "m") { is_result_possibly_unmarshaled = true; result_unmarshaled_if_argc = args_marshal.length - 1; } } else if (key === "!") throw new Error("! must be at the end of the signature"); const conv = primitiveConverters.get(key); if (!conv) throw new Error("Unknown parameter type " + key); const localStep = Object.create(conv.steps[0]); localStep.size = conv.size; if (conv.needs_root) needs_root_buffer = true; localStep.needs_root = conv.needs_root; localStep.key = key; steps.push(localStep); size += conv.size; } return { steps, size, args_marshal, is_result_definitely_unmarshaled, is_result_possibly_unmarshaled, result_unmarshaled_if_argc, needs_root_buffer }; } function _get_converter_for_marshal_string(args_marshal: string/*ArgsMarshalString*/): Converter { let converter = _signature_converters.get(args_marshal); if (!converter) { converter = _create_converter_for_marshal_string(args_marshal); _signature_converters.set(args_marshal, converter); } return converter; } export function _compile_converter_for_marshal_string(args_marshal: string/*ArgsMarshalString*/): Converter { const converter = _get_converter_for_marshal_string(args_marshal); if (typeof (converter.args_marshal) !== "string") throw new Error("Corrupt converter for '" + args_marshal + "'"); if (converter.compiled_function && converter.compiled_variadic_function) return converter; const converterName = args_marshal.replace("!", "_result_unmarshaled"); converter.name = converterName; let body = []; let argumentNames = ["buffer", "rootBuffer", "method"]; // worst-case allocation size instead of allocating dynamically, plus padding const bufferSizeBytes = converter.size + (args_marshal.length * 4) + 16; // ensure the indirect values are 8-byte aligned so that aligned loads and stores will work const indirectBaseOffset = ((((args_marshal.length * 4) + 7) / 8) | 0) * 8; const closure: any = { Module, _malloc: Module._malloc, mono_wasm_unbox_rooted: cwraps.mono_wasm_unbox_rooted, setI32, setU32, setF32, setF64, setI64 }; let indirectLocalOffset = 0; body.push( "if (!method) throw new Error('no method provided');", `if (!buffer) buffer = _malloc (${bufferSizeBytes});`, `let indirectStart = buffer + ${indirectBaseOffset};`, "" ); for (let i = 0; i < converter.steps.length; i++) { const step = converter.steps[i]; const closureKey = "step" + i; const valueKey = "value" + i; const argKey = "arg" + i; argumentNames.push(argKey); if (step.convert) { closure[closureKey] = step.convert; body.push(`let ${valueKey} = ${closureKey}(${argKey}, method, ${i});`); } else { body.push(`let ${valueKey} = ${argKey};`); } if (step.needs_root) { body.push("if (!rootBuffer) throw new Error('no root buffer provided');"); body.push(`rootBuffer.set (${i}, ${valueKey});`); } // HACK: needs_unbox indicates that we were passed a pointer to a managed object, and either // it was already rooted by our caller or (needs_root = true) by us. Now we can unbox it and // pass the raw address of its boxed value into the callee. // FIXME: I don't think this is GC safe if (step.needs_unbox) body.push(`${valueKey} = mono_wasm_unbox_rooted (${valueKey});`); if (step.indirect) { const offsetText = `(indirectStart + ${indirectLocalOffset})`; switch (step.indirect) { case "u32": body.push(`setU32(${offsetText}, ${valueKey});`); break; case "i32": body.push(`setI32(${offsetText}, ${valueKey});`); break; case "float": body.push(`setF32(${offsetText}, ${valueKey});`); break; case "double": body.push(`setF64(${offsetText}, ${valueKey});`); break; case "i64": body.push(`setI64(${offsetText}, ${valueKey});`); break; default: throw new Error("Unimplemented indirect type: " + step.indirect); } body.push(`setU32(buffer + (${i} * 4), ${offsetText});`); indirectLocalOffset += step.size!; } else { body.push(`setI32(buffer + (${i} * 4), ${valueKey});`); indirectLocalOffset += 4; } body.push(""); } body.push("return buffer;"); let bodyJs = body.join("\r\n"), compiledFunction = null, compiledVariadicFunction = null; try { compiledFunction = _create_named_function("converter_" + converterName, argumentNames, bodyJs, closure); converter.compiled_function = compiledFunction; } catch (exc) { converter.compiled_function = null; console.warn("compiling converter failed for", bodyJs, "with error", exc); throw exc; } argumentNames = ["existingBuffer", "rootBuffer", "method", "args"]; const variadicClosure = { converter: compiledFunction }; body = [ "return converter(", " existingBuffer, rootBuffer, method," ]; for (let i = 0; i < converter.steps.length; i++) { body.push( " args[" + i + ( (i == converter.steps.length - 1) ? "]" : "], " ) ); } body.push(");"); bodyJs = body.join("\r\n"); try { compiledVariadicFunction = _create_named_function("variadic_converter_" + converterName, argumentNames, bodyJs, variadicClosure); converter.compiled_variadic_function = compiledVariadicFunction; } catch (exc) { converter.compiled_variadic_function = null; console.warn("compiling converter failed for", bodyJs, "with error", exc); throw exc; } converter.scratchRootBuffer = null; converter.scratchBuffer = VoidPtrNull; return converter; } function _maybe_produce_signature_warning(converter: Converter) { if (converter.has_warned_about_signature) return; console.warn("MONO_WASM: Deprecated raw return value signature: '" + converter.args_marshal + "'. End the signature with '!' instead of 'm'."); converter.has_warned_about_signature = true; } export function _decide_if_result_is_marshaled(converter: Converter, argc: number): boolean { if (!converter) return true; if ( converter.is_result_possibly_unmarshaled && (argc === converter.result_unmarshaled_if_argc) ) { if (argc < converter.result_unmarshaled_if_argc) throw new Error(`Expected >= ${converter.result_unmarshaled_if_argc} argument(s) but got ${argc} for signature '${converter.args_marshal}'`); _maybe_produce_signature_warning(converter); return false; } else { if (argc < converter.steps.length) throw new Error(`Expected ${converter.steps.length} argument(s) but got ${argc} for signature '${converter.args_marshal}'`); return !converter.is_result_definitely_unmarshaled; } } export function mono_bind_method(method: MonoMethod, this_arg: MonoObject | null, args_marshal: string/*ArgsMarshalString*/, friendly_name: string): Function { if (typeof (args_marshal) !== "string") throw new Error("args_marshal argument invalid, expected string"); this_arg = coerceNull(this_arg); let converter: Converter | null = null; if (typeof (args_marshal) === "string") { converter = _compile_converter_for_marshal_string(args_marshal); } // FIXME const unbox_buffer_size = 8192; const unbox_buffer = Module._malloc(unbox_buffer_size); const token: BoundMethodToken = { friendlyName: friendly_name, method, converter, scratchRootBuffer: null, scratchBuffer: VoidPtrNull, scratchResultRoot: mono_wasm_new_root(), scratchExceptionRoot: mono_wasm_new_root() }; const closure: any = { Module, mono_wasm_new_root, _create_temp_frame, _get_args_root_buffer_for_method_call, _get_buffer_for_method_call, _handle_exception_for_call, _teardown_after_call, mono_wasm_try_unbox_primitive_and_get_type: cwraps.mono_wasm_try_unbox_primitive_and_get_type, _unbox_mono_obj_root_with_known_nonprimitive_type, invoke_method: cwraps.mono_wasm_invoke_method, method, this_arg, token, unbox_buffer, unbox_buffer_size, getI32, getU32, getF32, getF64 }; const converterKey = converter ? "converter_" + converter.name : ""; if (converter) closure[converterKey] = converter; const argumentNames = []; const body = [ "_create_temp_frame();", "let resultRoot = token.scratchResultRoot, exceptionRoot = token.scratchExceptionRoot;", "token.scratchResultRoot = null;", "token.scratchExceptionRoot = null;", "if (resultRoot === null)", " resultRoot = mono_wasm_new_root ();", "if (exceptionRoot === null)", " exceptionRoot = mono_wasm_new_root ();", "" ]; if (converter) { body.push( `let argsRootBuffer = _get_args_root_buffer_for_method_call(${converterKey}, token);`, `let scratchBuffer = _get_buffer_for_method_call(${converterKey}, token);`, `let buffer = ${converterKey}.compiled_function(`, " scratchBuffer, argsRootBuffer, method," ); for (let i = 0; i < converter.steps.length; i++) { const argName = "arg" + i; argumentNames.push(argName); body.push( " " + argName + ( (i == converter.steps.length - 1) ? "" : ", " ) ); } body.push(");"); } else { body.push("let argsRootBuffer = null, buffer = 0;"); } if (converter && converter.is_result_definitely_unmarshaled) { body.push("let is_result_marshaled = false;"); } else if (converter && converter.is_result_possibly_unmarshaled) { body.push(`let is_result_marshaled = arguments.length !== ${converter.result_unmarshaled_if_argc};`); } else { body.push("let is_result_marshaled = true;"); } // We inline a bunch of the invoke and marshaling logic here in order to eliminate the GC pressure normally // created by the unboxing part of the call process. Because unbox_mono_obj(_root) can return non-numeric // types, v8 and spidermonkey allocate and store its result on the heap (in the nursery, to be fair). // For a bound method however, we know the result will always be the same type because C# methods have known // return types. Inlining the invoke and marshaling logic means that even though the bound method has logic // for handling various types, only one path through the method (for its appropriate return type) will ever // be taken, and the JIT will see that the 'result' local and thus the return value of this function are // always of the exact same type. All of the branches related to this end up being predicted and low-cost. // The end result is that bound method invocations don't always allocate, so no more nursery GCs. Yay! -kg body.push( "", "resultRoot.value = invoke_method (method, this_arg, buffer, exceptionRoot.get_address ());", `_handle_exception_for_call (${converterKey}, token, buffer, resultRoot, exceptionRoot, argsRootBuffer);`, "", "let resultPtr = resultRoot.value, result = undefined;" ); if (converter) { if (converter.is_result_possibly_unmarshaled) body.push("if (!is_result_marshaled) "); if (converter.is_result_definitely_unmarshaled || converter.is_result_possibly_unmarshaled) body.push(" result = resultPtr;"); if (!converter.is_result_definitely_unmarshaled) body.push( "if (is_result_marshaled && (resultPtr !== 0)) {", // For the common scenario where the return type is a primitive, we want to try and unbox it directly // into our existing heap allocation and then read it out of the heap. Doing this all in one operation // means that we only need to enter a gc safe region twice (instead of 3+ times with the normal, // slower check-type-and-then-unbox flow which has extra checks since unbox verifies the type). " let resultType = mono_wasm_try_unbox_primitive_and_get_type (resultPtr, unbox_buffer, unbox_buffer_size);", " switch (resultType) {", ` case ${MarshalType.INT}:`, " result = getI32(unbox_buffer); break;", ` case ${MarshalType.POINTER}:`, // FIXME: Is this right? ` case ${MarshalType.UINT32}:`, " result = getU32(unbox_buffer); break;", ` case ${MarshalType.FP32}:`, " result = getF32(unbox_buffer); break;", ` case ${MarshalType.FP64}:`, " result = getF64(unbox_buffer); break;", ` case ${MarshalType.BOOL}:`, " result = getI32(unbox_buffer) !== 0; break;", ` case ${MarshalType.CHAR}:`, " result = String.fromCharCode(getI32(unbox_buffer)); break;", " default:", " result = _unbox_mono_obj_root_with_known_nonprimitive_type (resultRoot, resultType, unbox_buffer); break;", " }", "}" ); } else { throw new Error("No converter"); } if (friendly_name) { const escapeRE = /[^A-Za-z0-9_$]/g; friendly_name = friendly_name.replace(escapeRE, "_"); } let displayName = friendly_name || ("clr_" + method); if (this_arg) displayName += "_this" + this_arg; body.push( `_teardown_after_call (${converterKey}, token, buffer, resultRoot, exceptionRoot, argsRootBuffer);`, "return result;" ); const bodyJs = body.join("\r\n"); const result = _create_named_function(displayName, argumentNames, bodyJs, closure); return result; } /* We currently don't use these types because it makes typeScript compiler very slow. declare const enum ArgsMarshal { Int32 = "i", // int32 Int32Enum = "j", // int32 - Enum with underlying type of int32 Int64 = "l", // int64 Int64Enum = "k", // int64 - Enum with underlying type of int64 Float32 = "f", // float Float64 = "d", // double String = "s", // string Char = "s", // interned string JSObj = "o", // js object will be converted to a C# object (this will box numbers/bool/promises) MONOObj = "m", // raw mono object. Don't use it unless you know what you're doing } // to suppress marshaling of the return value, place '!' at the end of args_marshal, i.e. 'ii!' instead of 'ii' type _ExtraArgsMarshalOperators = "!" | ""; export type ArgsMarshalString = "" | `${ArgsMarshal}${_ExtraArgsMarshalOperators}` | `${ArgsMarshal}${ArgsMarshal}${_ExtraArgsMarshalOperators}` | `${ArgsMarshal}${ArgsMarshal}${ArgsMarshal}${_ExtraArgsMarshalOperators}` | `${ArgsMarshal}${ArgsMarshal}${ArgsMarshal}${ArgsMarshal}${_ExtraArgsMarshalOperators}`; */ type ConverterStepIndirects = "u32" | "i32" | "float" | "double" | "i64" export type Converter = { steps: { convert?: boolean | Function; needs_root?: boolean; needs_unbox?: boolean; indirect?: ConverterStepIndirects; size?: number; }[]; size: number; args_marshal?: string/*ArgsMarshalString*/; is_result_definitely_unmarshaled?: boolean; is_result_possibly_unmarshaled?: boolean; result_unmarshaled_if_argc?: number; needs_root_buffer?: boolean; key?: string; name?: string; needs_root?: boolean; needs_unbox?: boolean; compiled_variadic_function?: Function | null; compiled_function?: Function | null; scratchRootBuffer?: WasmRootBuffer | null; scratchBuffer?: VoidPtr; has_warned_about_signature?: boolean; convert?: Function | null; method?: MonoMethod | null; } export type BoundMethodToken = { friendlyName: string; method: MonoMethod; converter: Converter | null; scratchRootBuffer: WasmRootBuffer | null; scratchBuffer: VoidPtr; scratchResultRoot: WasmRoot<MonoObject>; scratchExceptionRoot: WasmRoot<MonoObject>; }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. import { WasmRoot, WasmRootBuffer, mono_wasm_new_root } from "./roots"; import { MonoClass, MonoMethod, MonoObject, coerceNull, VoidPtrNull, MonoType, MarshalType } from "./types"; import { BINDING, Module, runtimeHelpers } from "./imports"; import { js_to_mono_enum, _js_to_mono_obj, _js_to_mono_uri } from "./js-to-cs"; import { js_string_to_mono_string, js_string_to_mono_string_interned } from "./strings"; import { _unbox_mono_obj_root_with_known_nonprimitive_type } from "./cs-to-js"; import { _create_temp_frame, getI32, getU32, getF32, getF64, setI32, setU32, setF32, setF64, setI64, } from "./memory"; import { _get_args_root_buffer_for_method_call, _get_buffer_for_method_call, _handle_exception_for_call, _teardown_after_call } from "./method-calls"; import cwraps from "./cwraps"; import { VoidPtr } from "./types/emscripten"; const primitiveConverters = new Map<string, Converter>(); const _signature_converters = new Map<string, Converter>(); const _method_descriptions = new Map<MonoMethod, string>(); export function _get_type_name(typePtr: MonoType): string { if (!typePtr) return "<null>"; return cwraps.mono_wasm_get_type_name(typePtr); } export function _get_type_aqn(typePtr: MonoType): string { if (!typePtr) return "<null>"; return cwraps.mono_wasm_get_type_aqn(typePtr); } export function _get_class_name(classPtr: MonoClass): string { if (!classPtr) return "<null>"; return cwraps.mono_wasm_get_type_name(cwraps.mono_wasm_class_get_type(classPtr)); } export function find_method(klass: MonoClass, name: string, n: number): MonoMethod { const result = cwraps.mono_wasm_assembly_find_method(klass, name, n); if (result) { _method_descriptions.set(result, name); } return result; } export function get_method(method_name: string): MonoMethod { const res = find_method(runtimeHelpers.wasm_runtime_class, method_name, -1); if (!res) throw "Can't find method " + runtimeHelpers.runtime_namespace + "." + runtimeHelpers.runtime_classname + ":" + method_name; return res; } export function bind_runtime_method(method_name: string, signature: string): Function { const method = get_method(method_name); return mono_bind_method(method, null, signature, "BINDINGS_" + method_name); } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export function _create_named_function(name: string, argumentNames: string[], body: string, closure: any): Function { let result = null; let closureArgumentList: any[] | null = null; let closureArgumentNames = null; if (closure) { closureArgumentNames = Object.keys(closure); closureArgumentList = new Array(closureArgumentNames.length); for (let i = 0, l = closureArgumentNames.length; i < l; i++) closureArgumentList[i] = closure[closureArgumentNames[i]]; } const constructor = _create_rebindable_named_function(name, argumentNames, body, closureArgumentNames); // eslint-disable-next-line prefer-spread result = constructor.apply(null, closureArgumentList); return result; } export function _create_rebindable_named_function(name: string, argumentNames: string[], body: string, closureArgNames: string[] | null): Function { const strictPrefix = "\"use strict\";\r\n"; let uriPrefix = "", escapedFunctionIdentifier = ""; if (name) { uriPrefix = "//# sourceURL=https://mono-wasm.invalid/" + name + "\r\n"; escapedFunctionIdentifier = name; } else { escapedFunctionIdentifier = "unnamed"; } let rawFunctionText = "function " + escapedFunctionIdentifier + "(" + argumentNames.join(", ") + ") {\r\n" + body + "\r\n};\r\n"; const lineBreakRE = /\r(\n?)/g; rawFunctionText = uriPrefix + strictPrefix + rawFunctionText.replace(lineBreakRE, "\r\n ") + ` return ${escapedFunctionIdentifier};\r\n`; let result = null, keys = null; if (closureArgNames) { keys = closureArgNames.concat([rawFunctionText]); } else { keys = [rawFunctionText]; } result = Function.apply(Function, keys); return result; } export function _create_primitive_converters(): void { const result = primitiveConverters; result.set("m", { steps: [{}], size: 0 }); result.set("s", { steps: [{ convert: js_string_to_mono_string.bind(BINDING) }], size: 0, needs_root: true }); result.set("S", { steps: [{ convert: js_string_to_mono_string_interned.bind(BINDING) }], size: 0, needs_root: true }); // note we also bind first argument to false for both _js_to_mono_obj and _js_to_mono_uri, // because we will root the reference, so we don't need in-flight reference // also as those are callback arguments and we don't have platform code which would release the in-flight reference on C# end result.set("o", { steps: [{ convert: _js_to_mono_obj.bind(BINDING, false) }], size: 0, needs_root: true }); result.set("u", { steps: [{ convert: _js_to_mono_uri.bind(BINDING, false) }], size: 0, needs_root: true }); // result.set ('k', { steps: [{ convert: js_to_mono_enum.bind (this), indirect: 'i64'}], size: 8}); result.set("j", { steps: [{ convert: js_to_mono_enum.bind(BINDING), indirect: "i32" }], size: 8 }); result.set("i", { steps: [{ indirect: "i32" }], size: 8 }); result.set("l", { steps: [{ indirect: "i64" }], size: 8 }); result.set("f", { steps: [{ indirect: "float" }], size: 8 }); result.set("d", { steps: [{ indirect: "double" }], size: 8 }); } function _create_converter_for_marshal_string(args_marshal: string/*ArgsMarshalString*/): Converter { const steps = []; let size = 0; let is_result_definitely_unmarshaled = false, is_result_possibly_unmarshaled = false, result_unmarshaled_if_argc = -1, needs_root_buffer = false; for (let i = 0; i < args_marshal.length; ++i) { const key = args_marshal[i]; if (i === args_marshal.length - 1) { if (key === "!") { is_result_definitely_unmarshaled = true; continue; } else if (key === "m") { is_result_possibly_unmarshaled = true; result_unmarshaled_if_argc = args_marshal.length - 1; } } else if (key === "!") throw new Error("! must be at the end of the signature"); const conv = primitiveConverters.get(key); if (!conv) throw new Error("Unknown parameter type " + key); const localStep = Object.create(conv.steps[0]); localStep.size = conv.size; if (conv.needs_root) needs_root_buffer = true; localStep.needs_root = conv.needs_root; localStep.key = key; steps.push(localStep); size += conv.size; } return { steps, size, args_marshal, is_result_definitely_unmarshaled, is_result_possibly_unmarshaled, result_unmarshaled_if_argc, needs_root_buffer }; } function _get_converter_for_marshal_string(args_marshal: string/*ArgsMarshalString*/): Converter { let converter = _signature_converters.get(args_marshal); if (!converter) { converter = _create_converter_for_marshal_string(args_marshal); _signature_converters.set(args_marshal, converter); } return converter; } export function _compile_converter_for_marshal_string(args_marshal: string/*ArgsMarshalString*/): Converter { const converter = _get_converter_for_marshal_string(args_marshal); if (typeof (converter.args_marshal) !== "string") throw new Error("Corrupt converter for '" + args_marshal + "'"); if (converter.compiled_function && converter.compiled_variadic_function) return converter; const converterName = args_marshal.replace("!", "_result_unmarshaled"); converter.name = converterName; let body = []; let argumentNames = ["buffer", "rootBuffer", "method"]; // worst-case allocation size instead of allocating dynamically, plus padding const bufferSizeBytes = converter.size + (args_marshal.length * 4) + 16; // ensure the indirect values are 8-byte aligned so that aligned loads and stores will work const indirectBaseOffset = ((((args_marshal.length * 4) + 7) / 8) | 0) * 8; const closure: any = { Module, _malloc: Module._malloc, mono_wasm_unbox_rooted: cwraps.mono_wasm_unbox_rooted, setI32, setU32, setF32, setF64, setI64 }; let indirectLocalOffset = 0; body.push( "if (!method) throw new Error('no method provided');", `if (!buffer) buffer = _malloc (${bufferSizeBytes});`, `let indirectStart = buffer + ${indirectBaseOffset};`, "" ); for (let i = 0; i < converter.steps.length; i++) { const step = converter.steps[i]; const closureKey = "step" + i; const valueKey = "value" + i; const argKey = "arg" + i; argumentNames.push(argKey); if (step.convert) { closure[closureKey] = step.convert; body.push(`let ${valueKey} = ${closureKey}(${argKey}, method, ${i});`); } else { body.push(`let ${valueKey} = ${argKey};`); } if (step.needs_root) { body.push("if (!rootBuffer) throw new Error('no root buffer provided');"); body.push(`rootBuffer.set (${i}, ${valueKey});`); } // HACK: needs_unbox indicates that we were passed a pointer to a managed object, and either // it was already rooted by our caller or (needs_root = true) by us. Now we can unbox it and // pass the raw address of its boxed value into the callee. // FIXME: I don't think this is GC safe if (step.needs_unbox) body.push(`${valueKey} = mono_wasm_unbox_rooted (${valueKey});`); if (step.indirect) { const offsetText = `(indirectStart + ${indirectLocalOffset})`; switch (step.indirect) { case "u32": body.push(`setU32(${offsetText}, ${valueKey});`); break; case "i32": body.push(`setI32(${offsetText}, ${valueKey});`); break; case "float": body.push(`setF32(${offsetText}, ${valueKey});`); break; case "double": body.push(`setF64(${offsetText}, ${valueKey});`); break; case "i64": body.push(`setI64(${offsetText}, ${valueKey});`); break; default: throw new Error("Unimplemented indirect type: " + step.indirect); } body.push(`setU32(buffer + (${i} * 4), ${offsetText});`); indirectLocalOffset += step.size!; } else { body.push(`setI32(buffer + (${i} * 4), ${valueKey});`); indirectLocalOffset += 4; } body.push(""); } body.push("return buffer;"); let bodyJs = body.join("\r\n"), compiledFunction = null, compiledVariadicFunction = null; try { compiledFunction = _create_named_function("converter_" + converterName, argumentNames, bodyJs, closure); converter.compiled_function = compiledFunction; } catch (exc) { converter.compiled_function = null; console.warn("compiling converter failed for", bodyJs, "with error", exc); throw exc; } argumentNames = ["existingBuffer", "rootBuffer", "method", "args"]; const variadicClosure = { converter: compiledFunction }; body = [ "return converter(", " existingBuffer, rootBuffer, method," ]; for (let i = 0; i < converter.steps.length; i++) { body.push( " args[" + i + ( (i == converter.steps.length - 1) ? "]" : "], " ) ); } body.push(");"); bodyJs = body.join("\r\n"); try { compiledVariadicFunction = _create_named_function("variadic_converter_" + converterName, argumentNames, bodyJs, variadicClosure); converter.compiled_variadic_function = compiledVariadicFunction; } catch (exc) { converter.compiled_variadic_function = null; console.warn("compiling converter failed for", bodyJs, "with error", exc); throw exc; } converter.scratchRootBuffer = null; converter.scratchBuffer = VoidPtrNull; return converter; } function _maybe_produce_signature_warning(converter: Converter) { if (converter.has_warned_about_signature) return; console.warn("MONO_WASM: Deprecated raw return value signature: '" + converter.args_marshal + "'. End the signature with '!' instead of 'm'."); converter.has_warned_about_signature = true; } export function _decide_if_result_is_marshaled(converter: Converter, argc: number): boolean { if (!converter) return true; if ( converter.is_result_possibly_unmarshaled && (argc === converter.result_unmarshaled_if_argc) ) { if (argc < converter.result_unmarshaled_if_argc) throw new Error(`Expected >= ${converter.result_unmarshaled_if_argc} argument(s) but got ${argc} for signature '${converter.args_marshal}'`); _maybe_produce_signature_warning(converter); return false; } else { if (argc < converter.steps.length) throw new Error(`Expected ${converter.steps.length} argument(s) but got ${argc} for signature '${converter.args_marshal}'`); return !converter.is_result_definitely_unmarshaled; } } export function mono_bind_method(method: MonoMethod, this_arg: MonoObject | null, args_marshal: string/*ArgsMarshalString*/, friendly_name: string): Function { if (typeof (args_marshal) !== "string") throw new Error("args_marshal argument invalid, expected string"); this_arg = coerceNull(this_arg); let converter: Converter | null = null; if (typeof (args_marshal) === "string") { converter = _compile_converter_for_marshal_string(args_marshal); } // FIXME const unbox_buffer_size = 8192; const unbox_buffer = Module._malloc(unbox_buffer_size); const token: BoundMethodToken = { friendlyName: friendly_name, method, converter, scratchRootBuffer: null, scratchBuffer: VoidPtrNull, scratchResultRoot: mono_wasm_new_root(), scratchExceptionRoot: mono_wasm_new_root() }; const closure: any = { Module, mono_wasm_new_root, _create_temp_frame, _get_args_root_buffer_for_method_call, _get_buffer_for_method_call, _handle_exception_for_call, _teardown_after_call, mono_wasm_try_unbox_primitive_and_get_type: cwraps.mono_wasm_try_unbox_primitive_and_get_type, _unbox_mono_obj_root_with_known_nonprimitive_type, invoke_method: cwraps.mono_wasm_invoke_method, method, this_arg, token, unbox_buffer, unbox_buffer_size, getI32, getU32, getF32, getF64 }; const converterKey = converter ? "converter_" + converter.name : ""; if (converter) closure[converterKey] = converter; const argumentNames = []; const body = [ "_create_temp_frame();", "let resultRoot = token.scratchResultRoot, exceptionRoot = token.scratchExceptionRoot;", "token.scratchResultRoot = null;", "token.scratchExceptionRoot = null;", "if (resultRoot === null)", " resultRoot = mono_wasm_new_root ();", "if (exceptionRoot === null)", " exceptionRoot = mono_wasm_new_root ();", "" ]; if (converter) { body.push( `let argsRootBuffer = _get_args_root_buffer_for_method_call(${converterKey}, token);`, `let scratchBuffer = _get_buffer_for_method_call(${converterKey}, token);`, `let buffer = ${converterKey}.compiled_function(`, " scratchBuffer, argsRootBuffer, method," ); for (let i = 0; i < converter.steps.length; i++) { const argName = "arg" + i; argumentNames.push(argName); body.push( " " + argName + ( (i == converter.steps.length - 1) ? "" : ", " ) ); } body.push(");"); } else { body.push("let argsRootBuffer = null, buffer = 0;"); } if (converter && converter.is_result_definitely_unmarshaled) { body.push("let is_result_marshaled = false;"); } else if (converter && converter.is_result_possibly_unmarshaled) { body.push(`let is_result_marshaled = arguments.length !== ${converter.result_unmarshaled_if_argc};`); } else { body.push("let is_result_marshaled = true;"); } // We inline a bunch of the invoke and marshaling logic here in order to eliminate the GC pressure normally // created by the unboxing part of the call process. Because unbox_mono_obj(_root) can return non-numeric // types, v8 and spidermonkey allocate and store its result on the heap (in the nursery, to be fair). // For a bound method however, we know the result will always be the same type because C# methods have known // return types. Inlining the invoke and marshaling logic means that even though the bound method has logic // for handling various types, only one path through the method (for its appropriate return type) will ever // be taken, and the JIT will see that the 'result' local and thus the return value of this function are // always of the exact same type. All of the branches related to this end up being predicted and low-cost. // The end result is that bound method invocations don't always allocate, so no more nursery GCs. Yay! -kg body.push( "", "resultRoot.value = invoke_method (method, this_arg, buffer, exceptionRoot.get_address ());", `_handle_exception_for_call (${converterKey}, token, buffer, resultRoot, exceptionRoot, argsRootBuffer);`, "", "let resultPtr = resultRoot.value, result = undefined;" ); if (converter) { if (converter.is_result_possibly_unmarshaled) body.push("if (!is_result_marshaled) "); if (converter.is_result_definitely_unmarshaled || converter.is_result_possibly_unmarshaled) body.push(" result = resultPtr;"); if (!converter.is_result_definitely_unmarshaled) body.push( "if (is_result_marshaled && (resultPtr !== 0)) {", // For the common scenario where the return type is a primitive, we want to try and unbox it directly // into our existing heap allocation and then read it out of the heap. Doing this all in one operation // means that we only need to enter a gc safe region twice (instead of 3+ times with the normal, // slower check-type-and-then-unbox flow which has extra checks since unbox verifies the type). " let resultType = mono_wasm_try_unbox_primitive_and_get_type (resultPtr, unbox_buffer, unbox_buffer_size);", " switch (resultType) {", ` case ${MarshalType.INT}:`, " result = getI32(unbox_buffer); break;", ` case ${MarshalType.POINTER}:`, // FIXME: Is this right? ` case ${MarshalType.UINT32}:`, " result = getU32(unbox_buffer); break;", ` case ${MarshalType.FP32}:`, " result = getF32(unbox_buffer); break;", ` case ${MarshalType.FP64}:`, " result = getF64(unbox_buffer); break;", ` case ${MarshalType.BOOL}:`, " result = getI32(unbox_buffer) !== 0; break;", ` case ${MarshalType.CHAR}:`, " result = String.fromCharCode(getI32(unbox_buffer)); break;", " default:", " result = _unbox_mono_obj_root_with_known_nonprimitive_type (resultRoot, resultType, unbox_buffer); break;", " }", "}" ); } else { throw new Error("No converter"); } if (friendly_name) { const escapeRE = /[^A-Za-z0-9_$]/g; friendly_name = friendly_name.replace(escapeRE, "_"); } let displayName = friendly_name || ("clr_" + method); if (this_arg) displayName += "_this" + this_arg; body.push( `_teardown_after_call (${converterKey}, token, buffer, resultRoot, exceptionRoot, argsRootBuffer);`, "return result;" ); const bodyJs = body.join("\r\n"); const result = _create_named_function(displayName, argumentNames, bodyJs, closure); return result; } /* We currently don't use these types because it makes typeScript compiler very slow. declare const enum ArgsMarshal { Int32 = "i", // int32 Int32Enum = "j", // int32 - Enum with underlying type of int32 Int64 = "l", // int64 Int64Enum = "k", // int64 - Enum with underlying type of int64 Float32 = "f", // float Float64 = "d", // double String = "s", // string Char = "s", // interned string JSObj = "o", // js object will be converted to a C# object (this will box numbers/bool/promises) MONOObj = "m", // raw mono object. Don't use it unless you know what you're doing } // to suppress marshaling of the return value, place '!' at the end of args_marshal, i.e. 'ii!' instead of 'ii' type _ExtraArgsMarshalOperators = "!" | ""; export type ArgsMarshalString = "" | `${ArgsMarshal}${_ExtraArgsMarshalOperators}` | `${ArgsMarshal}${ArgsMarshal}${_ExtraArgsMarshalOperators}` | `${ArgsMarshal}${ArgsMarshal}${ArgsMarshal}${_ExtraArgsMarshalOperators}` | `${ArgsMarshal}${ArgsMarshal}${ArgsMarshal}${ArgsMarshal}${_ExtraArgsMarshalOperators}`; */ type ConverterStepIndirects = "u32" | "i32" | "float" | "double" | "i64" export type Converter = { steps: { convert?: boolean | Function; needs_root?: boolean; needs_unbox?: boolean; indirect?: ConverterStepIndirects; size?: number; }[]; size: number; args_marshal?: string/*ArgsMarshalString*/; is_result_definitely_unmarshaled?: boolean; is_result_possibly_unmarshaled?: boolean; result_unmarshaled_if_argc?: number; needs_root_buffer?: boolean; key?: string; name?: string; needs_root?: boolean; needs_unbox?: boolean; compiled_variadic_function?: Function | null; compiled_function?: Function | null; scratchRootBuffer?: WasmRootBuffer | null; scratchBuffer?: VoidPtr; has_warned_about_signature?: boolean; convert?: Function | null; method?: MonoMethod | null; } export type BoundMethodToken = { friendlyName: string; method: MonoMethod; converter: Converter | null; scratchRootBuffer: WasmRootBuffer | null; scratchBuffer: VoidPtr; scratchResultRoot: WasmRoot<MonoObject>; scratchExceptionRoot: WasmRoot<MonoObject>; }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Text.Json/Common/JsonIgnoreCondition.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Text.Json.Serialization { /// <summary> /// When specified on <see cref="JsonSerializerOptions.DefaultIgnoreCondition"/>, /// determines when properties and fields across the type graph are ignored. /// When specified on <see cref="JsonIgnoreAttribute.Condition"/>, controls whether /// a property or field is ignored during serialization and deserialization. This option /// overrides the setting on <see cref="JsonSerializerOptions.DefaultIgnoreCondition"/>. /// </summary> #if BUILDING_SOURCE_GENERATOR internal #else public #endif enum JsonIgnoreCondition { /// <summary> /// Property is never ignored during serialization or deserialization. /// </summary> Never = 0, /// <summary> /// Property is always ignored during serialization and deserialization. /// </summary> Always = 1, /// <summary> /// If the value is the default, the property is ignored during serialization. /// This is applied to both reference and value-type properties and fields. /// </summary> WhenWritingDefault = 2, /// <summary> /// If the value is <see langword="null"/>, the property is ignored during serialization. /// This is applied only to reference-type properties and fields. /// </summary> WhenWritingNull = 3, } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Text.Json.Serialization { /// <summary> /// When specified on <see cref="JsonSerializerOptions.DefaultIgnoreCondition"/>, /// determines when properties and fields across the type graph are ignored. /// When specified on <see cref="JsonIgnoreAttribute.Condition"/>, controls whether /// a property or field is ignored during serialization and deserialization. This option /// overrides the setting on <see cref="JsonSerializerOptions.DefaultIgnoreCondition"/>. /// </summary> #if BUILDING_SOURCE_GENERATOR internal #else public #endif enum JsonIgnoreCondition { /// <summary> /// Property is never ignored during serialization or deserialization. /// </summary> Never = 0, /// <summary> /// Property is always ignored during serialization and deserialization. /// </summary> Always = 1, /// <summary> /// If the value is the default, the property is ignored during serialization. /// This is applied to both reference and value-type properties and fields. /// </summary> WhenWritingDefault = 2, /// <summary> /// If the value is <see langword="null"/>, the property is ignored during serialization. /// This is applied only to reference-type properties and fields. /// </summary> WhenWritingNull = 3, } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/readytorun/r2rdump/BasicTests/files/Windows_NT.x64.Debug/GcInfoTransitions.xml
<?xml version="1.0" encoding="utf-8"?> <R2RDump> <R2RReader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Filename>GcInfoTransitions.ni.dll</Filename> <IsR2R>true</IsR2R> <Machine>Amd64</Machine> <ImageBase>6891812028416</ImageBase> </R2RReader> <Header> <R2RHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SignatureString>RTR</SignatureString> <Signature>5395538</Signature> <MajorVersion>2</MajorVersion> <MinorVersion>2</MinorVersion> <Flags>3</Flags> </R2RHeader> </Header> <Sections> <Count>9</Count> <Section Index="READYTORUN_SECTION_COMPILER_IDENTIFIER"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_COMPILER_IDENTIFIER" /> <Contents> <CompilerIdentifier>CoreCLR 4.5.30319.0 __BUILDMACHINE__</CompilerIdentifier> </Contents> </Section> <Section Index="READYTORUN_SECTION_IMPORT_SECTIONS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_IMPORT_SECTIONS" /> <Contents> <ImportSection Index="0"> <R2RImportSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <Flags>CORCOMPILE_IMPORT_FLAGS_EAGER</Flags> <Type>CORCOMPILE_IMPORT_TYPE_UNKNOWN</Type> <Entries> <ImportSectionEntry Index="0"> <StartOffset>0</StartOffset> <Section>0</Section> </ImportSectionEntry> </Entries> </R2RImportSection> <ImportSectionEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <StartOffset>0</StartOffset> <Section>0</Section> </ImportSectionEntry> </ImportSection> <ImportSection Index="1"> <R2RImportSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1"> <Flags>CORCOMPILE_IMPORT_FLAGS_PCODE</Flags> <Type>CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH</Type> <Entries> <ImportSectionEntry Index="0"> <StartOffset>0</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> <ImportSectionEntry Index="1"> <StartOffset>8</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> <ImportSectionEntry Index="2"> <StartOffset>16</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> </Entries> </R2RImportSection> <ImportSectionEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <StartOffset>0</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> <ImportSectionEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1"> <StartOffset>8</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> <ImportSectionEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2"> <StartOffset>16</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> </ImportSection> </Contents> </Section> <Section Index="READYTORUN_SECTION_RUNTIME_FUNCTIONS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_RUNTIME_FUNCTIONS" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_METHODDEF_ENTRYPOINTS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_METHODDEF_ENTRYPOINTS" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_DEBUG_INFO"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_DEBUG_INFO" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_DELAYLOAD_METHODCALL_THUNKS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_DELAYLOAD_METHODCALL_THUNKS" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_AVAILABLE_TYPES"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_AVAILABLE_TYPES" /> <Contents> <AvailableType Index="0">GcInfoTransitions.GcInfoTransitions</AvailableType> <AvailableType Index="1">.&lt;Module&gt;</AvailableType> </Contents> </Section> <Section Index="READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_INLINING_INFO"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_INLINING_INFO" /> <Contents /> </Section> </Sections> <Methods Count="3"> <Method Index="0"> <R2RMethod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <Name>abc</Name> <SignatureString>GcInfoTransitions.GcInfoTransitions.abc(String)</SignatureString> <IsGeneric>false</IsGeneric> <DeclaringType>GcInfoTransitions.GcInfoTransitions</DeclaringType> <Token>100663297</Token> <Rid>1</Rid> <EntryPointRuntimeFunctionId>0</EntryPointRuntimeFunctionId> </R2RMethod> <GcInfo> <GcInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>73</Size> <Offset>3512</Offset> <CodeLength>12</CodeLength> <Version>2</Version> <ReturnKind>RT_Scalar</ReturnKind> <ValidRangeStart>0</ValidRangeStart> <ValidRangeEnd>0</ValidRangeEnd> <SecurityObjectStackSlot>-1</SecurityObjectStackSlot> <GSCookieStackSlot>-1</GSCookieStackSlot> <PSPSymStackSlot>-1</PSPSymStackSlot> <GenericsInstContextStackSlot>-1</GenericsInstContextStackSlot> <StackBaseRegister>5</StackBaseRegister> <SizeOfEditAndContinuePreservedArea>4294967295</SizeOfEditAndContinuePreservedArea> <ReversePInvokeFrameStackSlot>-1</ReversePInvokeFrameStackSlot> <SizeOfStackOutgoingAndScratchArea>0</SizeOfStackOutgoingAndScratchArea> <NumSafePoints>0</NumSafePoints> <NumInterruptibleRanges>1</NumInterruptibleRanges> <SafePointOffsets /> <InterruptibleRanges> <InterruptibleRange Index="0"> <StartOffset>8</StartOffset> <StopOffset>10</StopOffset> </InterruptibleRange> </InterruptibleRanges> <SlotTable> <NumRegisters>0</NumRegisters> <NumStackSlots>0</NumStackSlots> <NumUntracked>1</NumUntracked> <NumSlots>1</NumSlots> <GcSlots> <GcSlot Index="0"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>16</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> </GcSlots> </SlotTable> </GcInfo> </GcInfo> <RuntimeFunctions> <RuntimeFunction Index="0"> <MethodRid>1</MethodRid> <RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <Size>12</Size> <CodeOffset>0</CodeOffset> </RuntimeFunction> <UnwindInfo> <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>12</Size> <Version>1</Version> <Flags>3</Flags> <SizeOfProlog>1</SizeOfProlog> <CountOfUnwindCodes>1</CountOfUnwindCodes> <FrameRegister>EAX</FrameRegister> <FrameOffset>0</FrameOffset> <UnwindCode> <UnwindCode Index="0"> <CodeOffset>1</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>5</OpInfo> <OffsetLow>1</OffsetLow> <OffsetHigh>5</OffsetHigh> <FrameOffset>20481</FrameOffset> </UnwindCode> </UnwindCode> <PersonalityRoutineRVA>609157120</PersonalityRoutineRVA> </UnwindInfo> </UnwindInfo> </RuntimeFunction> </RuntimeFunctions> </Method> <Method Index="1"> <R2RMethod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1"> <Name>Main</Name> <SignatureString>GcInfoTransitions.GcInfoTransitions.Main(String[])</SignatureString> <IsGeneric>false</IsGeneric> <DeclaringType>GcInfoTransitions.GcInfoTransitions</DeclaringType> <Token>100663298</Token> <Rid>2</Rid> <EntryPointRuntimeFunctionId>1</EntryPointRuntimeFunctionId> </R2RMethod> <GcInfo> <GcInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>587</Size> <Offset>3540</Offset> <CodeLength>317</CodeLength> <Version>2</Version> <ReturnKind>RT_Scalar</ReturnKind> <ValidRangeStart>0</ValidRangeStart> <ValidRangeEnd>0</ValidRangeEnd> <SecurityObjectStackSlot>-1</SecurityObjectStackSlot> <GSCookieStackSlot>-1</GSCookieStackSlot> <PSPSymStackSlot>-1</PSPSymStackSlot> <GenericsInstContextStackSlot>-1</GenericsInstContextStackSlot> <StackBaseRegister>5</StackBaseRegister> <SizeOfEditAndContinuePreservedArea>4294967295</SizeOfEditAndContinuePreservedArea> <ReversePInvokeFrameStackSlot>-1</ReversePInvokeFrameStackSlot> <SizeOfStackOutgoingAndScratchArea>32</SizeOfStackOutgoingAndScratchArea> <NumSafePoints>0</NumSafePoints> <NumInterruptibleRanges>1</NumInterruptibleRanges> <SafePointOffsets /> <InterruptibleRanges> <InterruptibleRange Index="0"> <StartOffset>35</StartOffset> <StopOffset>309</StopOffset> </InterruptibleRange> </InterruptibleRanges> <SlotTable> <NumRegisters>2</NumRegisters> <NumStackSlots>0</NumStackSlots> <NumUntracked>9</NumUntracked> <NumSlots>11</NumSlots> <GcSlots> <GcSlot Index="0"> <RegisterNumber>0</RegisterNumber> <Flags>GC_SLOT_BASE</Flags> </GcSlot> <GcSlot Index="1"> <RegisterNumber>1</RegisterNumber> <Flags>GC_SLOT_BASE</Flags> </GcSlot> <GcSlot Index="2"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>432</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="3"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>440</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="4"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>448</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="5"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>456</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="6"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>464</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="7"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>472</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="8"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>480</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="9"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>488</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="10"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>528</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> </GcSlots> </SlotTable> </GcInfo> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="38"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="55"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="55"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="63"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="69"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="69"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="72"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="89"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="89"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="97"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="103"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="103"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="106"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="123"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="123"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="131"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="137"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="137"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="140"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="157"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="157"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="165"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="171"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="171"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="174"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="191"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="191"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="199"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="205"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="205"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="208"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="225"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="225"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="233"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="239"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="239"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="242"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="259"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="259"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="267"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="273"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="273"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="276"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="293"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>4</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="293"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>4</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="301"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>4</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="307"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>4</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="307"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>4</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> </GcInfo> <RuntimeFunctions> <RuntimeFunction Index="1"> <MethodRid>2</MethodRid> <RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1"> <Size>317</Size> <CodeOffset>0</CodeOffset> </RuntimeFunction> <UnwindInfo> <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>16</Size> <Version>1</Version> <Flags>3</Flags> <SizeOfProlog>7</SizeOfProlog> <CountOfUnwindCodes>4</CountOfUnwindCodes> <FrameRegister>EAX</FrameRegister> <FrameOffset>0</FrameOffset> <UnwindCode> <UnwindCode Index="0"> <CodeOffset>7</CodeOffset> <UnwindOp>UWOP_ALLOC_SMALL</UnwindOp> <OpInfo>11</OpInfo> <OffsetLow>7</OffsetLow> <OffsetHigh>11</OffsetHigh> <FrameOffset>45575</FrameOffset> </UnwindCode> <UnwindCode Index="1"> <CodeOffset>3</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>6</OpInfo> <OffsetLow>3</OffsetLow> <OffsetHigh>6</OffsetHigh> <FrameOffset>24579</FrameOffset> </UnwindCode> <UnwindCode Index="2"> <CodeOffset>2</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>7</OpInfo> <OffsetLow>2</OffsetLow> <OffsetHigh>7</OffsetHigh> <FrameOffset>28674</FrameOffset> </UnwindCode> <UnwindCode Index="3"> <CodeOffset>1</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>5</OpInfo> <OffsetLow>1</OffsetLow> <OffsetHigh>5</OffsetHigh> <FrameOffset>20481</FrameOffset> </UnwindCode> </UnwindCode> <PersonalityRoutineRVA>9295</PersonalityRoutineRVA> </UnwindInfo> </UnwindInfo> </RuntimeFunction> </RuntimeFunctions> </Method> <Method Index="2"> <R2RMethod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2"> <Name>.ctor</Name> <SignatureString>GcInfoTransitions.GcInfoTransitions..ctor()</SignatureString> <IsGeneric>false</IsGeneric> <DeclaringType>GcInfoTransitions.GcInfoTransitions</DeclaringType> <Token>100663299</Token> <Rid>3</Rid> <EntryPointRuntimeFunctionId>2</EntryPointRuntimeFunctionId> </R2RMethod> <GcInfo> <GcInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>106</Size> <Offset>3628</Offset> <CodeLength>32</CodeLength> <Version>2</Version> <ReturnKind>RT_Scalar</ReturnKind> <ValidRangeStart>0</ValidRangeStart> <ValidRangeEnd>0</ValidRangeEnd> <SecurityObjectStackSlot>-1</SecurityObjectStackSlot> <GSCookieStackSlot>-1</GSCookieStackSlot> <PSPSymStackSlot>-1</PSPSymStackSlot> <GenericsInstContextStackSlot>-1</GenericsInstContextStackSlot> <StackBaseRegister>5</StackBaseRegister> <SizeOfEditAndContinuePreservedArea>4294967295</SizeOfEditAndContinuePreservedArea> <ReversePInvokeFrameStackSlot>-1</ReversePInvokeFrameStackSlot> <SizeOfStackOutgoingAndScratchArea>32</SizeOfStackOutgoingAndScratchArea> <NumSafePoints>0</NumSafePoints> <NumInterruptibleRanges>1</NumInterruptibleRanges> <SafePointOffsets /> <InterruptibleRanges> <InterruptibleRange Index="0"> <StartOffset>14</StartOffset> <StopOffset>26</StopOffset> </InterruptibleRange> </InterruptibleRanges> <SlotTable> <NumRegisters>1</NumRegisters> <NumStackSlots>0</NumStackSlots> <NumUntracked>1</NumUntracked> <NumSlots>2</NumSlots> <GcSlots> <GcSlot Index="0"> <RegisterNumber>1</RegisterNumber> <Flags>GC_SLOT_BASE</Flags> </GcSlot> <GcSlot Index="1"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>16</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> </GcSlots> </SlotTable> </GcInfo> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="18"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="24"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> </GcInfo> <RuntimeFunctions> <RuntimeFunction Index="2"> <MethodRid>3</MethodRid> <RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2"> <Size>32</Size> <CodeOffset>0</CodeOffset> </RuntimeFunction> <UnwindInfo> <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>12</Size> <Version>1</Version> <Flags>3</Flags> <SizeOfProlog>5</SizeOfProlog> <CountOfUnwindCodes>2</CountOfUnwindCodes> <FrameRegister>EAX</FrameRegister> <FrameOffset>0</FrameOffset> <UnwindCode> <UnwindCode Index="0"> <CodeOffset>5</CodeOffset> <UnwindOp>UWOP_ALLOC_SMALL</UnwindOp> <OpInfo>3</OpInfo> <OffsetLow>5</OffsetLow> <OffsetHigh>3</OffsetHigh> <FrameOffset>12805</FrameOffset> </UnwindCode> <UnwindCode Index="1"> <CodeOffset>1</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>5</OpInfo> <OffsetLow>1</OffsetLow> <OffsetHigh>5</OffsetHigh> <FrameOffset>20481</FrameOffset> </UnwindCode> </UnwindCode> <PersonalityRoutineRVA>9295</PersonalityRoutineRVA> </UnwindInfo> </UnwindInfo> </RuntimeFunction> </RuntimeFunctions> </Method> </Methods> </R2RDump>
<?xml version="1.0" encoding="utf-8"?> <R2RDump> <R2RReader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Filename>GcInfoTransitions.ni.dll</Filename> <IsR2R>true</IsR2R> <Machine>Amd64</Machine> <ImageBase>6891812028416</ImageBase> </R2RReader> <Header> <R2RHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SignatureString>RTR</SignatureString> <Signature>5395538</Signature> <MajorVersion>2</MajorVersion> <MinorVersion>2</MinorVersion> <Flags>3</Flags> </R2RHeader> </Header> <Sections> <Count>9</Count> <Section Index="READYTORUN_SECTION_COMPILER_IDENTIFIER"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_COMPILER_IDENTIFIER" /> <Contents> <CompilerIdentifier>CoreCLR 4.5.30319.0 __BUILDMACHINE__</CompilerIdentifier> </Contents> </Section> <Section Index="READYTORUN_SECTION_IMPORT_SECTIONS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_IMPORT_SECTIONS" /> <Contents> <ImportSection Index="0"> <R2RImportSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <Flags>CORCOMPILE_IMPORT_FLAGS_EAGER</Flags> <Type>CORCOMPILE_IMPORT_TYPE_UNKNOWN</Type> <Entries> <ImportSectionEntry Index="0"> <StartOffset>0</StartOffset> <Section>0</Section> </ImportSectionEntry> </Entries> </R2RImportSection> <ImportSectionEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <StartOffset>0</StartOffset> <Section>0</Section> </ImportSectionEntry> </ImportSection> <ImportSection Index="1"> <R2RImportSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1"> <Flags>CORCOMPILE_IMPORT_FLAGS_PCODE</Flags> <Type>CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH</Type> <Entries> <ImportSectionEntry Index="0"> <StartOffset>0</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> <ImportSectionEntry Index="1"> <StartOffset>8</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> <ImportSectionEntry Index="2"> <StartOffset>16</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> </Entries> </R2RImportSection> <ImportSectionEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <StartOffset>0</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> <ImportSectionEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1"> <StartOffset>8</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> <ImportSectionEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2"> <StartOffset>16</StartOffset> <Section>6891812037717</Section> </ImportSectionEntry> </ImportSection> </Contents> </Section> <Section Index="READYTORUN_SECTION_RUNTIME_FUNCTIONS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_RUNTIME_FUNCTIONS" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_METHODDEF_ENTRYPOINTS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_METHODDEF_ENTRYPOINTS" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_DEBUG_INFO"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_DEBUG_INFO" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_DELAYLOAD_METHODCALL_THUNKS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_DELAYLOAD_METHODCALL_THUNKS" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_AVAILABLE_TYPES"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_AVAILABLE_TYPES" /> <Contents> <AvailableType Index="0">GcInfoTransitions.GcInfoTransitions</AvailableType> <AvailableType Index="1">.&lt;Module&gt;</AvailableType> </Contents> </Section> <Section Index="READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS" /> <Contents /> </Section> <Section Index="READYTORUN_SECTION_INLINING_INFO"> <R2RSection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="READYTORUN_SECTION_INLINING_INFO" /> <Contents /> </Section> </Sections> <Methods Count="3"> <Method Index="0"> <R2RMethod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <Name>abc</Name> <SignatureString>GcInfoTransitions.GcInfoTransitions.abc(String)</SignatureString> <IsGeneric>false</IsGeneric> <DeclaringType>GcInfoTransitions.GcInfoTransitions</DeclaringType> <Token>100663297</Token> <Rid>1</Rid> <EntryPointRuntimeFunctionId>0</EntryPointRuntimeFunctionId> </R2RMethod> <GcInfo> <GcInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>73</Size> <Offset>3512</Offset> <CodeLength>12</CodeLength> <Version>2</Version> <ReturnKind>RT_Scalar</ReturnKind> <ValidRangeStart>0</ValidRangeStart> <ValidRangeEnd>0</ValidRangeEnd> <SecurityObjectStackSlot>-1</SecurityObjectStackSlot> <GSCookieStackSlot>-1</GSCookieStackSlot> <PSPSymStackSlot>-1</PSPSymStackSlot> <GenericsInstContextStackSlot>-1</GenericsInstContextStackSlot> <StackBaseRegister>5</StackBaseRegister> <SizeOfEditAndContinuePreservedArea>4294967295</SizeOfEditAndContinuePreservedArea> <ReversePInvokeFrameStackSlot>-1</ReversePInvokeFrameStackSlot> <SizeOfStackOutgoingAndScratchArea>0</SizeOfStackOutgoingAndScratchArea> <NumSafePoints>0</NumSafePoints> <NumInterruptibleRanges>1</NumInterruptibleRanges> <SafePointOffsets /> <InterruptibleRanges> <InterruptibleRange Index="0"> <StartOffset>8</StartOffset> <StopOffset>10</StopOffset> </InterruptibleRange> </InterruptibleRanges> <SlotTable> <NumRegisters>0</NumRegisters> <NumStackSlots>0</NumStackSlots> <NumUntracked>1</NumUntracked> <NumSlots>1</NumSlots> <GcSlots> <GcSlot Index="0"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>16</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> </GcSlots> </SlotTable> </GcInfo> </GcInfo> <RuntimeFunctions> <RuntimeFunction Index="0"> <MethodRid>1</MethodRid> <RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0"> <Size>12</Size> <CodeOffset>0</CodeOffset> </RuntimeFunction> <UnwindInfo> <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>12</Size> <Version>1</Version> <Flags>3</Flags> <SizeOfProlog>1</SizeOfProlog> <CountOfUnwindCodes>1</CountOfUnwindCodes> <FrameRegister>EAX</FrameRegister> <FrameOffset>0</FrameOffset> <UnwindCode> <UnwindCode Index="0"> <CodeOffset>1</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>5</OpInfo> <OffsetLow>1</OffsetLow> <OffsetHigh>5</OffsetHigh> <FrameOffset>20481</FrameOffset> </UnwindCode> </UnwindCode> <PersonalityRoutineRVA>609157120</PersonalityRoutineRVA> </UnwindInfo> </UnwindInfo> </RuntimeFunction> </RuntimeFunctions> </Method> <Method Index="1"> <R2RMethod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1"> <Name>Main</Name> <SignatureString>GcInfoTransitions.GcInfoTransitions.Main(String[])</SignatureString> <IsGeneric>false</IsGeneric> <DeclaringType>GcInfoTransitions.GcInfoTransitions</DeclaringType> <Token>100663298</Token> <Rid>2</Rid> <EntryPointRuntimeFunctionId>1</EntryPointRuntimeFunctionId> </R2RMethod> <GcInfo> <GcInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>587</Size> <Offset>3540</Offset> <CodeLength>317</CodeLength> <Version>2</Version> <ReturnKind>RT_Scalar</ReturnKind> <ValidRangeStart>0</ValidRangeStart> <ValidRangeEnd>0</ValidRangeEnd> <SecurityObjectStackSlot>-1</SecurityObjectStackSlot> <GSCookieStackSlot>-1</GSCookieStackSlot> <PSPSymStackSlot>-1</PSPSymStackSlot> <GenericsInstContextStackSlot>-1</GenericsInstContextStackSlot> <StackBaseRegister>5</StackBaseRegister> <SizeOfEditAndContinuePreservedArea>4294967295</SizeOfEditAndContinuePreservedArea> <ReversePInvokeFrameStackSlot>-1</ReversePInvokeFrameStackSlot> <SizeOfStackOutgoingAndScratchArea>32</SizeOfStackOutgoingAndScratchArea> <NumSafePoints>0</NumSafePoints> <NumInterruptibleRanges>1</NumInterruptibleRanges> <SafePointOffsets /> <InterruptibleRanges> <InterruptibleRange Index="0"> <StartOffset>35</StartOffset> <StopOffset>309</StopOffset> </InterruptibleRange> </InterruptibleRanges> <SlotTable> <NumRegisters>2</NumRegisters> <NumStackSlots>0</NumStackSlots> <NumUntracked>9</NumUntracked> <NumSlots>11</NumSlots> <GcSlots> <GcSlot Index="0"> <RegisterNumber>0</RegisterNumber> <Flags>GC_SLOT_BASE</Flags> </GcSlot> <GcSlot Index="1"> <RegisterNumber>1</RegisterNumber> <Flags>GC_SLOT_BASE</Flags> </GcSlot> <GcSlot Index="2"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>432</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="3"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>440</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="4"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>448</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="5"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>456</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="6"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>464</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="7"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>472</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="8"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>480</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="9"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>488</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> <GcSlot Index="10"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>528</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> </GcSlots> </SlotTable> </GcInfo> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="38"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="55"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="55"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="63"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="69"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="69"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="72"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="89"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="89"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="97"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="103"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="103"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="106"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="123"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="123"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="131"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="137"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="137"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="140"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="157"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>1</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="157"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>1</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="165"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="171"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="171"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="174"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="191"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="191"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="199"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="205"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="205"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="208"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="225"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>2</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="225"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>2</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="233"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="239"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="239"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="242"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="259"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="259"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="267"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="273"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="273"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="276"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>3</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="293"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>4</ChunkId> <SlotState>EAX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="293"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>4</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="301"> <SlotId>1</SlotId> <IsLive>true</IsLive> <ChunkId>4</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="307"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>4</ChunkId> <SlotState>EAX is dead</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="307"> <SlotId>1</SlotId> <IsLive>false</IsLive> <ChunkId>4</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> </GcInfo> <RuntimeFunctions> <RuntimeFunction Index="1"> <MethodRid>2</MethodRid> <RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1"> <Size>317</Size> <CodeOffset>0</CodeOffset> </RuntimeFunction> <UnwindInfo> <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>16</Size> <Version>1</Version> <Flags>3</Flags> <SizeOfProlog>7</SizeOfProlog> <CountOfUnwindCodes>4</CountOfUnwindCodes> <FrameRegister>EAX</FrameRegister> <FrameOffset>0</FrameOffset> <UnwindCode> <UnwindCode Index="0"> <CodeOffset>7</CodeOffset> <UnwindOp>UWOP_ALLOC_SMALL</UnwindOp> <OpInfo>11</OpInfo> <OffsetLow>7</OffsetLow> <OffsetHigh>11</OffsetHigh> <FrameOffset>45575</FrameOffset> </UnwindCode> <UnwindCode Index="1"> <CodeOffset>3</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>6</OpInfo> <OffsetLow>3</OffsetLow> <OffsetHigh>6</OffsetHigh> <FrameOffset>24579</FrameOffset> </UnwindCode> <UnwindCode Index="2"> <CodeOffset>2</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>7</OpInfo> <OffsetLow>2</OffsetLow> <OffsetHigh>7</OffsetHigh> <FrameOffset>28674</FrameOffset> </UnwindCode> <UnwindCode Index="3"> <CodeOffset>1</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>5</OpInfo> <OffsetLow>1</OffsetLow> <OffsetHigh>5</OffsetHigh> <FrameOffset>20481</FrameOffset> </UnwindCode> </UnwindCode> <PersonalityRoutineRVA>9295</PersonalityRoutineRVA> </UnwindInfo> </UnwindInfo> </RuntimeFunction> </RuntimeFunctions> </Method> <Method Index="2"> <R2RMethod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2"> <Name>.ctor</Name> <SignatureString>GcInfoTransitions.GcInfoTransitions..ctor()</SignatureString> <IsGeneric>false</IsGeneric> <DeclaringType>GcInfoTransitions.GcInfoTransitions</DeclaringType> <Token>100663299</Token> <Rid>3</Rid> <EntryPointRuntimeFunctionId>2</EntryPointRuntimeFunctionId> </R2RMethod> <GcInfo> <GcInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>106</Size> <Offset>3628</Offset> <CodeLength>32</CodeLength> <Version>2</Version> <ReturnKind>RT_Scalar</ReturnKind> <ValidRangeStart>0</ValidRangeStart> <ValidRangeEnd>0</ValidRangeEnd> <SecurityObjectStackSlot>-1</SecurityObjectStackSlot> <GSCookieStackSlot>-1</GSCookieStackSlot> <PSPSymStackSlot>-1</PSPSymStackSlot> <GenericsInstContextStackSlot>-1</GenericsInstContextStackSlot> <StackBaseRegister>5</StackBaseRegister> <SizeOfEditAndContinuePreservedArea>4294967295</SizeOfEditAndContinuePreservedArea> <ReversePInvokeFrameStackSlot>-1</ReversePInvokeFrameStackSlot> <SizeOfStackOutgoingAndScratchArea>32</SizeOfStackOutgoingAndScratchArea> <NumSafePoints>0</NumSafePoints> <NumInterruptibleRanges>1</NumInterruptibleRanges> <SafePointOffsets /> <InterruptibleRanges> <InterruptibleRange Index="0"> <StartOffset>14</StartOffset> <StopOffset>26</StopOffset> </InterruptibleRange> </InterruptibleRanges> <SlotTable> <NumRegisters>1</NumRegisters> <NumStackSlots>0</NumStackSlots> <NumUntracked>1</NumUntracked> <NumSlots>2</NumSlots> <GcSlots> <GcSlot Index="0"> <RegisterNumber>1</RegisterNumber> <Flags>GC_SLOT_BASE</Flags> </GcSlot> <GcSlot Index="1"> <RegisterNumber>-1</RegisterNumber> <StackSlot> <SpOffset>16</SpOffset> <Base>GC_FRAMEREG_REL</Base> </StackSlot> <Flags>GC_SLOT_UNTRACKED</Flags> </GcSlot> </GcSlots> </SlotTable> </GcInfo> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="18"> <SlotId>0</SlotId> <IsLive>true</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is live</SlotState> </GcTransition> <GcTransition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="24"> <SlotId>0</SlotId> <IsLive>false</IsLive> <ChunkId>0</ChunkId> <SlotState>ECX is dead</SlotState> </GcTransition> </GcInfo> <RuntimeFunctions> <RuntimeFunction Index="2"> <MethodRid>3</MethodRid> <RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2"> <Size>32</Size> <CodeOffset>0</CodeOffset> </RuntimeFunction> <UnwindInfo> <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Size>12</Size> <Version>1</Version> <Flags>3</Flags> <SizeOfProlog>5</SizeOfProlog> <CountOfUnwindCodes>2</CountOfUnwindCodes> <FrameRegister>EAX</FrameRegister> <FrameOffset>0</FrameOffset> <UnwindCode> <UnwindCode Index="0"> <CodeOffset>5</CodeOffset> <UnwindOp>UWOP_ALLOC_SMALL</UnwindOp> <OpInfo>3</OpInfo> <OffsetLow>5</OffsetLow> <OffsetHigh>3</OffsetHigh> <FrameOffset>12805</FrameOffset> </UnwindCode> <UnwindCode Index="1"> <CodeOffset>1</CodeOffset> <UnwindOp>UWOP_PUSH_NONVOL</UnwindOp> <OpInfo>5</OpInfo> <OffsetLow>1</OffsetLow> <OffsetHigh>5</OffsetHigh> <FrameOffset>20481</FrameOffset> </UnwindCode> </UnwindCode> <PersonalityRoutineRVA>9295</PersonalityRoutineRVA> </UnwindInfo> </UnwindInfo> </RuntimeFunction> </RuntimeFunctions> </Method> </Methods> </R2RDump>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/native/external/zlib-intel/zutil.c
/* zutil.c -- target dependent utility functions for the compression library * Copyright (C) 1995-2017 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zutil.h" #ifndef Z_SOLO # include "gzguts.h" #endif z_const char * const z_errmsg[10] = { (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ (z_const char *)"stream end", /* Z_STREAM_END 1 */ (z_const char *)"", /* Z_OK 0 */ (z_const char *)"file error", /* Z_ERRNO (-1) */ (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ (z_const char *)"" }; const char * ZEXPORT zlibVersion() { return ZLIB_VERSION; } uLong ZEXPORT zlibCompileFlags() { uLong flags; flags = 0; switch ((int)(sizeof(uInt))) { case 2: break; case 4: flags += 1; break; case 8: flags += 2; break; default: flags += 3; } switch ((int)(sizeof(uLong))) { case 2: break; case 4: flags += 1 << 2; break; case 8: flags += 2 << 2; break; default: flags += 3 << 2; } switch ((int)(sizeof(voidpf))) { case 2: break; case 4: flags += 1 << 4; break; case 8: flags += 2 << 4; break; default: flags += 3 << 4; } switch ((int)(sizeof(z_off_t))) { case 2: break; case 4: flags += 1 << 6; break; case 8: flags += 2 << 6; break; default: flags += 3 << 6; } #ifdef ZLIB_DEBUG flags += 1 << 8; #endif #if defined(ASMV) || defined(ASMINF) flags += 1 << 9; #endif #ifdef ZLIB_WINAPI flags += 1 << 10; #endif #ifdef BUILDFIXED flags += 1 << 12; #endif #ifdef DYNAMIC_CRC_TABLE flags += 1 << 13; #endif #ifdef NO_GZCOMPRESS flags += 1L << 16; #endif #ifdef NO_GZIP flags += 1L << 17; #endif #ifdef PKZIP_BUG_WORKAROUND flags += 1L << 20; #endif #ifdef FASTEST flags += 1L << 21; #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifdef NO_vsnprintf flags += 1L << 25; # ifdef HAS_vsprintf_void flags += 1L << 26; # endif # else # ifdef HAS_vsnprintf_void flags += 1L << 26; # endif # endif #else flags += 1L << 24; # ifdef NO_snprintf flags += 1L << 25; # ifdef HAS_sprintf_void flags += 1L << 26; # endif # else # ifdef HAS_snprintf_void flags += 1L << 26; # endif # endif #endif return flags; } #ifdef ZLIB_DEBUG #include <stdlib.h> # ifndef verbose # define verbose 0 # endif int ZLIB_INTERNAL z_verbose = verbose; void ZLIB_INTERNAL z_error (m) char *m; { fprintf(stderr, "%s\n", m); exit(1); } #endif /* exported to allow conversion of error code to string for compress() and * uncompress() */ const char * ZEXPORT zError(err) int err; { return ERR_MSG(err); } #if defined(_WIN32_WCE) && _WIN32_WCE < 0x800 /* The older Microsoft C Run-Time Library for Windows CE doesn't have * errno. We define it as a global variable to simplify porting. * Its value is always 0 and should not be used. */ int errno = 0; #endif #ifndef HAVE_MEMCPY void ZLIB_INTERNAL zmemcpy(dest, source, len) Bytef* dest; const Bytef* source; uInt len; { if (len == 0) return; do { *dest++ = *source++; /* ??? to be unrolled */ } while (--len != 0); } int ZLIB_INTERNAL zmemcmp(s1, s2, len) const Bytef* s1; const Bytef* s2; uInt len; { uInt j; for (j = 0; j < len; j++) { if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; } return 0; } void ZLIB_INTERNAL zmemzero(dest, len) Bytef* dest; uInt len; { if (len == 0) return; do { *dest++ = 0; /* ??? to be unrolled */ } while (--len != 0); } #endif #ifndef Z_SOLO #ifdef SYS16BIT #ifdef __TURBOC__ /* Turbo C in 16-bit mode */ # define MY_ZCALLOC /* Turbo C malloc() does not allow dynamic allocation of 64K bytes * and farmalloc(64K) returns a pointer with an offset of 8, so we * must fix the pointer. Warning: the pointer must be put back to its * original form in order to free it, use zcfree(). */ #define MAX_PTR 10 /* 10*64K = 640K */ local int next_ptr = 0; typedef struct ptr_table_s { voidpf org_ptr; voidpf new_ptr; } ptr_table; local ptr_table table[MAX_PTR]; /* This table is used to remember the original form of pointers * to large buffers (64K). Such pointers are normalized with a zero offset. * Since MSDOS is not a preemptive multitasking OS, this table is not * protected from concurrent access. This hack doesn't work anyway on * a protected system like OS/2. Use Microsoft C instead. */ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) { voidpf buf; ulg bsize = (ulg)items*size; (void)opaque; /* If we allocate less than 65520 bytes, we assume that farmalloc * will return a usable pointer which doesn't have to be normalized. */ if (bsize < 65520L) { buf = farmalloc(bsize); if (*(ush*)&buf != 0) return buf; } else { buf = farmalloc(bsize + 16L); } if (buf == NULL || next_ptr >= MAX_PTR) return NULL; table[next_ptr].org_ptr = buf; /* Normalize the pointer to seg:0 */ *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; *(ush*)&buf = 0; table[next_ptr++].new_ptr = buf; return buf; } void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) { int n; (void)opaque; if (*(ush*)&ptr != 0) { /* object < 64K */ farfree(ptr); return; } /* Find the original pointer */ for (n = 0; n < next_ptr; n++) { if (ptr != table[n].new_ptr) continue; farfree(table[n].org_ptr); while (++n < next_ptr) { table[n-1] = table[n]; } next_ptr--; return; } Assert(0, "zcfree: ptr not found"); } #endif /* __TURBOC__ */ #ifdef M_I86 /* Microsoft C in 16-bit mode */ # define MY_ZCALLOC #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) # define _halloc halloc # define _hfree hfree #endif voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) { (void)opaque; return _halloc((long)items, size); } void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) { (void)opaque; _hfree(ptr); } #endif /* M_I86 */ #endif /* SYS16BIT */ #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC extern voidp malloc OF((uInt size)); extern voidp calloc OF((uInt items, uInt size)); extern void free OF((voidpf ptr)); #endif voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) voidpf opaque; unsigned items; unsigned size; { (void)opaque; return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } void ZLIB_INTERNAL zcfree (opaque, ptr) voidpf opaque; voidpf ptr; { (void)opaque; free(ptr); } #endif /* MY_ZCALLOC */ #endif /* !Z_SOLO */
/* zutil.c -- target dependent utility functions for the compression library * Copyright (C) 1995-2017 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zutil.h" #ifndef Z_SOLO # include "gzguts.h" #endif z_const char * const z_errmsg[10] = { (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ (z_const char *)"stream end", /* Z_STREAM_END 1 */ (z_const char *)"", /* Z_OK 0 */ (z_const char *)"file error", /* Z_ERRNO (-1) */ (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ (z_const char *)"" }; const char * ZEXPORT zlibVersion() { return ZLIB_VERSION; } uLong ZEXPORT zlibCompileFlags() { uLong flags; flags = 0; switch ((int)(sizeof(uInt))) { case 2: break; case 4: flags += 1; break; case 8: flags += 2; break; default: flags += 3; } switch ((int)(sizeof(uLong))) { case 2: break; case 4: flags += 1 << 2; break; case 8: flags += 2 << 2; break; default: flags += 3 << 2; } switch ((int)(sizeof(voidpf))) { case 2: break; case 4: flags += 1 << 4; break; case 8: flags += 2 << 4; break; default: flags += 3 << 4; } switch ((int)(sizeof(z_off_t))) { case 2: break; case 4: flags += 1 << 6; break; case 8: flags += 2 << 6; break; default: flags += 3 << 6; } #ifdef ZLIB_DEBUG flags += 1 << 8; #endif #if defined(ASMV) || defined(ASMINF) flags += 1 << 9; #endif #ifdef ZLIB_WINAPI flags += 1 << 10; #endif #ifdef BUILDFIXED flags += 1 << 12; #endif #ifdef DYNAMIC_CRC_TABLE flags += 1 << 13; #endif #ifdef NO_GZCOMPRESS flags += 1L << 16; #endif #ifdef NO_GZIP flags += 1L << 17; #endif #ifdef PKZIP_BUG_WORKAROUND flags += 1L << 20; #endif #ifdef FASTEST flags += 1L << 21; #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifdef NO_vsnprintf flags += 1L << 25; # ifdef HAS_vsprintf_void flags += 1L << 26; # endif # else # ifdef HAS_vsnprintf_void flags += 1L << 26; # endif # endif #else flags += 1L << 24; # ifdef NO_snprintf flags += 1L << 25; # ifdef HAS_sprintf_void flags += 1L << 26; # endif # else # ifdef HAS_snprintf_void flags += 1L << 26; # endif # endif #endif return flags; } #ifdef ZLIB_DEBUG #include <stdlib.h> # ifndef verbose # define verbose 0 # endif int ZLIB_INTERNAL z_verbose = verbose; void ZLIB_INTERNAL z_error (m) char *m; { fprintf(stderr, "%s\n", m); exit(1); } #endif /* exported to allow conversion of error code to string for compress() and * uncompress() */ const char * ZEXPORT zError(err) int err; { return ERR_MSG(err); } #if defined(_WIN32_WCE) && _WIN32_WCE < 0x800 /* The older Microsoft C Run-Time Library for Windows CE doesn't have * errno. We define it as a global variable to simplify porting. * Its value is always 0 and should not be used. */ int errno = 0; #endif #ifndef HAVE_MEMCPY void ZLIB_INTERNAL zmemcpy(dest, source, len) Bytef* dest; const Bytef* source; uInt len; { if (len == 0) return; do { *dest++ = *source++; /* ??? to be unrolled */ } while (--len != 0); } int ZLIB_INTERNAL zmemcmp(s1, s2, len) const Bytef* s1; const Bytef* s2; uInt len; { uInt j; for (j = 0; j < len; j++) { if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; } return 0; } void ZLIB_INTERNAL zmemzero(dest, len) Bytef* dest; uInt len; { if (len == 0) return; do { *dest++ = 0; /* ??? to be unrolled */ } while (--len != 0); } #endif #ifndef Z_SOLO #ifdef SYS16BIT #ifdef __TURBOC__ /* Turbo C in 16-bit mode */ # define MY_ZCALLOC /* Turbo C malloc() does not allow dynamic allocation of 64K bytes * and farmalloc(64K) returns a pointer with an offset of 8, so we * must fix the pointer. Warning: the pointer must be put back to its * original form in order to free it, use zcfree(). */ #define MAX_PTR 10 /* 10*64K = 640K */ local int next_ptr = 0; typedef struct ptr_table_s { voidpf org_ptr; voidpf new_ptr; } ptr_table; local ptr_table table[MAX_PTR]; /* This table is used to remember the original form of pointers * to large buffers (64K). Such pointers are normalized with a zero offset. * Since MSDOS is not a preemptive multitasking OS, this table is not * protected from concurrent access. This hack doesn't work anyway on * a protected system like OS/2. Use Microsoft C instead. */ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) { voidpf buf; ulg bsize = (ulg)items*size; (void)opaque; /* If we allocate less than 65520 bytes, we assume that farmalloc * will return a usable pointer which doesn't have to be normalized. */ if (bsize < 65520L) { buf = farmalloc(bsize); if (*(ush*)&buf != 0) return buf; } else { buf = farmalloc(bsize + 16L); } if (buf == NULL || next_ptr >= MAX_PTR) return NULL; table[next_ptr].org_ptr = buf; /* Normalize the pointer to seg:0 */ *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; *(ush*)&buf = 0; table[next_ptr++].new_ptr = buf; return buf; } void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) { int n; (void)opaque; if (*(ush*)&ptr != 0) { /* object < 64K */ farfree(ptr); return; } /* Find the original pointer */ for (n = 0; n < next_ptr; n++) { if (ptr != table[n].new_ptr) continue; farfree(table[n].org_ptr); while (++n < next_ptr) { table[n-1] = table[n]; } next_ptr--; return; } Assert(0, "zcfree: ptr not found"); } #endif /* __TURBOC__ */ #ifdef M_I86 /* Microsoft C in 16-bit mode */ # define MY_ZCALLOC #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) # define _halloc halloc # define _hfree hfree #endif voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) { (void)opaque; return _halloc((long)items, size); } void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) { (void)opaque; _hfree(ptr); } #endif /* M_I86 */ #endif /* SYS16BIT */ #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC extern voidp malloc OF((uInt size)); extern voidp calloc OF((uInt items, uInt size)); extern void free OF((voidpf ptr)); #endif voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) voidpf opaque; unsigned items; unsigned size; { (void)opaque; return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } void ZLIB_INTERNAL zcfree (opaque, ptr) voidpf opaque; voidpf ptr; { (void)opaque; free(ptr); } #endif /* MY_ZCALLOC */ #endif /* !Z_SOLO */
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/HardwareIntrinsics/General/Vector256/Dot.Double.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void DotDouble() { var test = new VectorBinaryOpTest__DotDouble(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__DotDouble { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private GCHandle inHandle1; private GCHandle inHandle2; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<Double> _fld1; public Vector256<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__DotDouble testClass) { var result = Vector256.Dot(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector256<Double> _clsVar1; private static Vector256<Double> _clsVar2; private Vector256<Double> _fld1; private Vector256<Double> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__DotDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); } public VectorBinaryOpTest__DotDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector256.Dot( Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector256).GetMethod(nameof(Vector256.Dot), new Type[] { typeof(Vector256<Double>), typeof(Vector256<Double>) }); if (method is null) { method = typeof(Vector256).GetMethod(nameof(Vector256.Dot), 1, new Type[] { typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Double)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (Double)(result)); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector256.Dot( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr); var result = Vector256.Dot(op1, op2); ValidateResult(op1, op2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__DotDouble(); var result = Vector256.Dot(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector256.Dot(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector256.Dot(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<Double> op1, Vector256<Double> op2, Double result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(void* op1, void* op2, Double result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(Double[] left, Double[] right, Double result, [CallerMemberName] string method = "") { bool succeeded = true; Double actualResult = default; Double intermResult = default; for (var i = 0; i < Op1ElementCount; i++) { if ((i % Vector128<Double>.Count) == 0) { actualResult += intermResult; intermResult = default; } intermResult += (Double)(left[i] * right[i]); } actualResult += intermResult; if (actualResult != result) { succeeded = false; } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.Dot)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: {result}"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void DotDouble() { var test = new VectorBinaryOpTest__DotDouble(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__DotDouble { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private GCHandle inHandle1; private GCHandle inHandle2; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<Double> _fld1; public Vector256<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__DotDouble testClass) { var result = Vector256.Dot(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector256<Double> _clsVar1; private static Vector256<Double> _clsVar2; private Vector256<Double> _fld1; private Vector256<Double> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__DotDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); } public VectorBinaryOpTest__DotDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector256.Dot( Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector256).GetMethod(nameof(Vector256.Dot), new Type[] { typeof(Vector256<Double>), typeof(Vector256<Double>) }); if (method is null) { method = typeof(Vector256).GetMethod(nameof(Vector256.Dot), 1, new Type[] { typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Double)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (Double)(result)); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector256.Dot( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<Double>>(_dataTable.inArray2Ptr); var result = Vector256.Dot(op1, op2); ValidateResult(op1, op2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__DotDouble(); var result = Vector256.Dot(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector256.Dot(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector256.Dot(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<Double> op1, Vector256<Double> op2, Double result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(void* op1, void* op2, Double result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<Double>>()); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(Double[] left, Double[] right, Double result, [CallerMemberName] string method = "") { bool succeeded = true; Double actualResult = default; Double intermResult = default; for (var i = 0; i < Op1ElementCount; i++) { if ((i % Vector128<Double>.Count) == 0) { actualResult += intermResult; intermResult = default; } intermResult += (Double)(left[i] * right[i]); } actualResult += intermResult; if (actualResult != result) { succeeded = false; } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.Dot)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: {result}"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Linq.Queryable/tests/LongCountTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Linq.Expressions; using Xunit; namespace System.Linq.Tests { public class LongCountTests : EnumerableBasedTests { [Fact] public void EmptySource() { int[] data = { }; Assert.Equal(0, data.AsQueryable().LongCount()); } [Fact] public void EmptySourceWithPredicate() { int[] data = { }; Assert.Equal(0, data.AsQueryable().LongCount()); } [Fact] public void MultipleElements() { int?[] data = { -10, 4, 9, null, 11 }; Assert.Equal(data.Length, data.AsQueryable().LongCount()); } [Fact] public void PredicateTrueFirstAndLast() { int[] data = { 2, 5, 7, 9, 29, 10 }; Assert.Equal(2, data.AsQueryable().LongCount(i => i % 2 == 0)); } [Fact] public void NullSource() { AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).LongCount()); } [Fact] public void NullSourcePredicateUsed() { AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).LongCount(i => i != 0)); } [Fact] public void NullPredicateUsed() { Expression<Func<int, bool>> predicate = null; AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).AsQueryable().LongCount(predicate)); } [Fact] public void LongCount1() { var count = (new int[] { 0 }).AsQueryable().LongCount(); Assert.Equal(1L, count); } [Fact] public void LongCount2() { var count = (new int[] { 0, 1, 2 }).AsQueryable().LongCount(n => n > 0); Assert.Equal(2L, count); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Linq.Expressions; using Xunit; namespace System.Linq.Tests { public class LongCountTests : EnumerableBasedTests { [Fact] public void EmptySource() { int[] data = { }; Assert.Equal(0, data.AsQueryable().LongCount()); } [Fact] public void EmptySourceWithPredicate() { int[] data = { }; Assert.Equal(0, data.AsQueryable().LongCount()); } [Fact] public void MultipleElements() { int?[] data = { -10, 4, 9, null, 11 }; Assert.Equal(data.Length, data.AsQueryable().LongCount()); } [Fact] public void PredicateTrueFirstAndLast() { int[] data = { 2, 5, 7, 9, 29, 10 }; Assert.Equal(2, data.AsQueryable().LongCount(i => i % 2 == 0)); } [Fact] public void NullSource() { AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).LongCount()); } [Fact] public void NullSourcePredicateUsed() { AssertExtensions.Throws<ArgumentNullException>("source", () => ((IQueryable<int>)null).LongCount(i => i != 0)); } [Fact] public void NullPredicateUsed() { Expression<Func<int, bool>> predicate = null; AssertExtensions.Throws<ArgumentNullException>("predicate", () => Enumerable.Range(0, 3).AsQueryable().LongCount(predicate)); } [Fact] public void LongCount1() { var count = (new int[] { 0 }).AsQueryable().LongCount(); Assert.Equal(1L, count); } [Fact] public void LongCount2() { var count = (new int[] { 0, 1, 2 }).AsQueryable().LongCount(n => n > 0); Assert.Equal(2L, count); } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Runtime/tests/System/Int32Tests.GenericMath.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; using System.Runtime.Versioning; using Xunit; namespace System.Tests { [RequiresPreviewFeaturesAttribute] public class Int32Tests_GenericMath { [Fact] public static void AdditiveIdentityTest() { Assert.Equal((int)0x00000000, AdditiveIdentityHelper<int, int>.AdditiveIdentity); } [Fact] public static void MinValueTest() { Assert.Equal(unchecked((int)0x80000000), MinMaxValueHelper<int>.MinValue); } [Fact] public static void MaxValueTest() { Assert.Equal((int)0x7FFFFFFF, MinMaxValueHelper<int>.MaxValue); } [Fact] public static void MultiplicativeIdentityTest() { Assert.Equal((int)0x00000001, MultiplicativeIdentityHelper<int, int>.MultiplicativeIdentity); } [Fact] public static void NegativeOneTest() { Assert.Equal(unchecked((int)0xFFFFFFFF), SignedNumberHelper<int>.NegativeOne); } [Fact] public static void OneTest() { Assert.Equal((int)0x00000001, NumberHelper<int>.One); } [Fact] public static void ZeroTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Zero); } [Fact] public static void op_AdditionTest() { Assert.Equal((int)0x00000001, AdditionOperatorsHelper<int, int, int>.op_Addition((int)0x00000000, 1)); Assert.Equal((int)0x00000002, AdditionOperatorsHelper<int, int, int>.op_Addition((int)0x00000001, 1)); Assert.Equal(unchecked((int)0x80000000), AdditionOperatorsHelper<int, int, int>.op_Addition((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0x80000001), AdditionOperatorsHelper<int, int, int>.op_Addition(unchecked((int)0x80000000), 1)); Assert.Equal((int)0x00000000, AdditionOperatorsHelper<int, int, int>.op_Addition(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void LeadingZeroCountTest() { Assert.Equal((int)0x00000020, BinaryIntegerHelper<int>.LeadingZeroCount((int)0x00000000)); Assert.Equal((int)0x0000001F, BinaryIntegerHelper<int>.LeadingZeroCount((int)0x00000001)); Assert.Equal((int)0x00000001, BinaryIntegerHelper<int>.LeadingZeroCount((int)0x7FFFFFFF)); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.LeadingZeroCount(unchecked((int)0x80000000))); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.LeadingZeroCount(unchecked((int)0xFFFFFFFF))); } [Fact] public static void PopCountTest() { Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.PopCount((int)0x00000000)); Assert.Equal((int)0x00000001, BinaryIntegerHelper<int>.PopCount((int)0x00000001)); Assert.Equal((int)0x0000001F, BinaryIntegerHelper<int>.PopCount((int)0x7FFFFFFF)); Assert.Equal((int)0x00000001, BinaryIntegerHelper<int>.PopCount(unchecked((int)0x80000000))); Assert.Equal((int)0x00000020, BinaryIntegerHelper<int>.PopCount(unchecked((int)0xFFFFFFFF))); } [Fact] public static void RotateLeftTest() { Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.RotateLeft((int)0x00000000, 1)); Assert.Equal((int)0x00000002, BinaryIntegerHelper<int>.RotateLeft((int)0x00000001, 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), BinaryIntegerHelper<int>.RotateLeft((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x00000001, BinaryIntegerHelper<int>.RotateLeft(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), BinaryIntegerHelper<int>.RotateLeft(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void RotateRightTest() { Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.RotateRight((int)0x00000000, 1)); Assert.Equal(unchecked((int)0x80000000), BinaryIntegerHelper<int>.RotateRight((int)0x00000001, 1)); Assert.Equal(unchecked((int)0xBFFFFFFF), BinaryIntegerHelper<int>.RotateRight((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x40000000, BinaryIntegerHelper<int>.RotateRight(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), BinaryIntegerHelper<int>.RotateRight(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void TrailingZeroCountTest() { Assert.Equal((int)0x00000020, BinaryIntegerHelper<int>.TrailingZeroCount((int)0x00000000)); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.TrailingZeroCount((int)0x00000001)); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.TrailingZeroCount((int)0x7FFFFFFF)); Assert.Equal((int)0x0000001F, BinaryIntegerHelper<int>.TrailingZeroCount(unchecked((int)0x80000000))); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.TrailingZeroCount(unchecked((int)0xFFFFFFFF))); } [Fact] public static void IsPow2Test() { Assert.False(BinaryNumberHelper<int>.IsPow2((int)0x00000000)); Assert.True(BinaryNumberHelper<int>.IsPow2((int)0x00000001)); Assert.False(BinaryNumberHelper<int>.IsPow2((int)0x7FFFFFFF)); Assert.False(BinaryNumberHelper<int>.IsPow2(unchecked((int)0x80000000))); Assert.False(BinaryNumberHelper<int>.IsPow2(unchecked((int)0xFFFFFFFF))); } [Fact] public static void Log2Test() { Assert.Equal((int)0x00000000, BinaryNumberHelper<int>.Log2((int)0x00000000)); Assert.Equal((int)0x00000000, BinaryNumberHelper<int>.Log2((int)0x00000001)); Assert.Equal((int)0x0000001E, BinaryNumberHelper<int>.Log2((int)0x7FFFFFFF)); Assert.Throws<ArgumentOutOfRangeException>(() => BinaryNumberHelper<int>.Log2(unchecked((int)0x80000000))); Assert.Throws<ArgumentOutOfRangeException>(() => BinaryNumberHelper<int>.Log2(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_BitwiseAndTest() { Assert.Equal((int)0x00000000, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd((int)0x00000000, 1)); Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd((int)0x00000001, 1)); Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x00000000, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd(unchecked((int)0x80000000), 1)); Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_BitwiseOrTest() { Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr((int)0x00000000, 1)); Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr((int)0x00000001, 1)); Assert.Equal((int)0x7FFFFFFF, BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0x80000001), BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_ExclusiveOrTest() { Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr((int)0x00000000, 1)); Assert.Equal((int)0x00000000, BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr((int)0x00000001, 1)); Assert.Equal((int)0x7FFFFFFE, BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0x80000001), BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_OnesComplementTest() { Assert.Equal(unchecked((int)0xFFFFFFFF), BitwiseOperatorsHelper<int, int, int>.op_OnesComplement((int)0x00000000)); Assert.Equal(unchecked((int)0xFFFFFFFE), BitwiseOperatorsHelper<int, int, int>.op_OnesComplement((int)0x00000001)); Assert.Equal(unchecked((int)0x80000000), BitwiseOperatorsHelper<int, int, int>.op_OnesComplement((int)0x7FFFFFFF)); Assert.Equal((int)0x7FFFFFFF, BitwiseOperatorsHelper<int, int, int>.op_OnesComplement(unchecked((int)0x80000000))); Assert.Equal((int)0x00000000, BitwiseOperatorsHelper<int, int, int>.op_OnesComplement(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_LessThanTest() { Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThan((int)0x00000000, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_LessThan((int)0x00000001, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_LessThan((int)0x7FFFFFFF, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThan(unchecked((int)0x80000000), 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThan(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_LessThanOrEqualTest() { Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual((int)0x00000000, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual((int)0x00000001, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual((int)0x7FFFFFFF, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual(unchecked((int)0x80000000), 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_GreaterThanTest() { Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThan((int)0x00000000, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThan((int)0x00000001, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_GreaterThan((int)0x7FFFFFFF, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThan(unchecked((int)0x80000000), 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThan(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_GreaterThanOrEqualTest() { Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual((int)0x00000000, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual((int)0x00000001, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual((int)0x7FFFFFFF, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual(unchecked((int)0x80000000), 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_DecrementTest() { Assert.Equal(unchecked((int)0xFFFFFFFF), DecrementOperatorsHelper<int>.op_Decrement((int)0x00000000)); Assert.Equal((int)0x00000000, DecrementOperatorsHelper<int>.op_Decrement((int)0x00000001)); Assert.Equal((int)0x7FFFFFFE, DecrementOperatorsHelper<int>.op_Decrement((int)0x7FFFFFFF)); Assert.Equal((int)0x7FFFFFFF, DecrementOperatorsHelper<int>.op_Decrement(unchecked((int)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFE), DecrementOperatorsHelper<int>.op_Decrement(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_DivisionTest() { Assert.Equal((int)0x00000000, DivisionOperatorsHelper<int, int, int>.op_Division((int)0x00000000, 2)); Assert.Equal((int)0x00000000, DivisionOperatorsHelper<int, int, int>.op_Division((int)0x00000001, 2)); Assert.Equal((int)0x3FFFFFFF, DivisionOperatorsHelper<int, int, int>.op_Division((int)0x7FFFFFFF, 2)); Assert.Equal(unchecked((int)0xC0000000), DivisionOperatorsHelper<int, int, int>.op_Division(unchecked((int)0x80000000), 2)); Assert.Equal((int)0x00000000, DivisionOperatorsHelper<int, int, int>.op_Division(unchecked((int)0xFFFFFFFF), 2)); } [Fact] public static void op_EqualityTest() { Assert.False(EqualityOperatorsHelper<int, int>.op_Equality((int)0x00000000, 1)); Assert.True(EqualityOperatorsHelper<int, int>.op_Equality((int)0x00000001, 1)); Assert.False(EqualityOperatorsHelper<int, int>.op_Equality((int)0x7FFFFFFF, 1)); Assert.False(EqualityOperatorsHelper<int, int>.op_Equality(unchecked((int)0x80000000), 1)); Assert.False(EqualityOperatorsHelper<int, int>.op_Equality(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_InequalityTest() { Assert.True(EqualityOperatorsHelper<int, int>.op_Inequality((int)0x00000000, 1)); Assert.False(EqualityOperatorsHelper<int, int>.op_Inequality((int)0x00000001, 1)); Assert.True(EqualityOperatorsHelper<int, int>.op_Inequality((int)0x7FFFFFFF, 1)); Assert.True(EqualityOperatorsHelper<int, int>.op_Inequality(unchecked((int)0x80000000), 1)); Assert.True(EqualityOperatorsHelper<int, int>.op_Inequality(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_IncrementTest() { Assert.Equal((int)0x00000001, IncrementOperatorsHelper<int>.op_Increment((int)0x00000000)); Assert.Equal((int)0x00000002, IncrementOperatorsHelper<int>.op_Increment((int)0x00000001)); Assert.Equal(unchecked((int)0x80000000), IncrementOperatorsHelper<int>.op_Increment((int)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000001), IncrementOperatorsHelper<int>.op_Increment(unchecked((int)0x80000000))); Assert.Equal((int)0x00000000, IncrementOperatorsHelper<int>.op_Increment(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_ModulusTest() { Assert.Equal((int)0x00000000, ModulusOperatorsHelper<int, int, int>.op_Modulus((int)0x00000000, 2)); Assert.Equal((int)0x00000001, ModulusOperatorsHelper<int, int, int>.op_Modulus((int)0x00000001, 2)); Assert.Equal((int)0x00000001, ModulusOperatorsHelper<int, int, int>.op_Modulus((int)0x7FFFFFFF, 2)); Assert.Equal((int)0x00000000, ModulusOperatorsHelper<int, int, int>.op_Modulus(unchecked((int)0x80000000), 2)); Assert.Equal(unchecked((int)0xFFFFFFFF), ModulusOperatorsHelper<int, int, int>.op_Modulus(unchecked((int)0xFFFFFFFF), 2)); } [Fact] public static void op_MultiplyTest() { Assert.Equal((int)0x00000000, MultiplyOperatorsHelper<int, int, int>.op_Multiply((int)0x00000000, 2)); Assert.Equal((int)0x00000002, MultiplyOperatorsHelper<int, int, int>.op_Multiply((int)0x00000001, 2)); Assert.Equal(unchecked((int)0xFFFFFFFE), MultiplyOperatorsHelper<int, int, int>.op_Multiply((int)0x7FFFFFFF, 2)); Assert.Equal((int)0x00000000, MultiplyOperatorsHelper<int, int, int>.op_Multiply(unchecked((int)0x80000000), 2)); Assert.Equal(unchecked((int)0xFFFFFFFE), MultiplyOperatorsHelper<int, int, int>.op_Multiply(unchecked((int)0xFFFFFFFF), 2)); } [Fact] public static void AbsTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Abs((int)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Abs((int)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Abs((int)0x7FFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Abs(unchecked((int)0x80000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.Abs(unchecked((int)0xFFFFFFFF))); } [Fact] public static void ClampTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Clamp((int)0x00000000, unchecked((int)0xFFFFFFC0), 0x003F)); Assert.Equal((int)0x00000001, NumberHelper<int>.Clamp((int)0x00000001, unchecked((int)0xFFFFFFC0), 0x003F)); Assert.Equal((int)0x0000003F, NumberHelper<int>.Clamp((int)0x7FFFFFFF, unchecked((int)0xFFFFFFC0), 0x003F)); Assert.Equal(unchecked((int)0xFFFFFFC0), NumberHelper<int>.Clamp(unchecked((int)0x80000000), unchecked((int)0xFFFFFFC0), 0x003F)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Clamp(unchecked((int)0xFFFFFFFF), unchecked((int)0xFFFFFFC0), 0x003F)); } [Fact] public static void CreateFromByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<byte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<byte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.Create<byte>(0x7F)); Assert.Equal((int)0x00000080, NumberHelper<int>.Create<byte>(0x80)); Assert.Equal((int)0x000000FF, NumberHelper<int>.Create<byte>(0xFF)); } [Fact] public static void CreateFromCharTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<char>((char)0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<char>((char)0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.Create<char>((char)0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.Create<char>((char)0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.Create<char>((char)0xFFFF)); } [Fact] public static void CreateFromInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<short>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<short>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.Create<short>(0x7FFF)); Assert.Equal(unchecked((int)0xFFFF8000), NumberHelper<int>.Create<short>(unchecked((short)0x8000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<short>(unchecked((short)0xFFFF))); } [Fact] public static void CreateFromInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<int>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<int>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Create<int>(0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.Create<int>(unchecked(unchecked((int)0x80000000)))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<int>(unchecked(unchecked((int)0xFFFFFFFF)))); } [Fact] public static void CreateFromInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<long>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<long>(0x0000000000000001)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<long>(0x7FFFFFFFFFFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<long>(unchecked((long)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<long>(unchecked((long)0xFFFFFFFFFFFFFFFF))); } [Fact] public static void CreateFromIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<nint>(unchecked((nint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<nint>(unchecked((nint)0x0000000000000001))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nint>(unchecked((nint)0x7FFFFFFFFFFFFFFF))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nint>(unchecked((nint)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<nint>(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<nint>((nint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<nint>((nint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Create<nint>((nint)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.Create<nint>(unchecked((nint)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<nint>(unchecked((nint)0xFFFFFFFF))); } } [Fact] public static void CreateFromSByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<sbyte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<sbyte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.Create<sbyte>(0x7F)); Assert.Equal(unchecked((int)0xFFFFFF80), NumberHelper<int>.Create<sbyte>(unchecked((sbyte)0x80))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<sbyte>(unchecked((sbyte)0xFF))); } [Fact] public static void CreateFromUInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<ushort>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<ushort>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.Create<ushort>(0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.Create<ushort>(0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.Create<ushort>(0xFFFF)); } [Fact] public static void CreateFromUInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<uint>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<uint>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Create<uint>(0x7FFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<uint>(0x80000000)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<uint>(0xFFFFFFFF)); } [Fact] public static void CreateFromUInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<ulong>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<ulong>(0x0000000000000001)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<ulong>(0x7FFFFFFFFFFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<ulong>(0x8000000000000000)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<ulong>(0xFFFFFFFFFFFFFFFF)); } [Fact] public static void CreateFromUIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<nuint>(unchecked((nuint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<nuint>(unchecked((nuint)0x0000000000000001))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>(unchecked((nuint)0x8000000000000000))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<nuint>((nuint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<nuint>((nuint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Create<nuint>((nuint)0x7FFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>((nuint)0x80000000)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>((nuint)0xFFFFFFFF)); } } [Fact] public static void CreateSaturatingFromByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<byte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<byte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.CreateSaturating<byte>(0x7F)); Assert.Equal((int)0x00000080, NumberHelper<int>.CreateSaturating<byte>(0x80)); Assert.Equal((int)0x000000FF, NumberHelper<int>.CreateSaturating<byte>(0xFF)); } [Fact] public static void CreateSaturatingFromCharTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<char>((char)0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<char>((char)0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateSaturating<char>((char)0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.CreateSaturating<char>((char)0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.CreateSaturating<char>((char)0xFFFF)); } [Fact] public static void CreateSaturatingFromInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<short>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<short>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateSaturating<short>(0x7FFF)); Assert.Equal(unchecked((int)0xFFFF8000), NumberHelper<int>.CreateSaturating<short>(unchecked((short)0x8000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<short>(unchecked((short)0xFFFF))); } [Fact] public static void CreateSaturatingFromInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<int>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<int>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<int>(0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateSaturating<int>(unchecked(unchecked((int)0x80000000)))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<int>(unchecked(unchecked((int)0xFFFFFFFF)))); } [Fact] public static void CreateSaturatingFromInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<long>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<long>(0x0000000000000001)); Assert.Equal(unchecked((int)0x7FFFFFFF), NumberHelper<int>.CreateSaturating<long>(0x7FFFFFFFFFFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateSaturating<long>(unchecked((long)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<long>(unchecked((long)0xFFFFFFFFFFFFFFFF))); } [Fact] public static void CreateSaturatingFromIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x0000000000000001))); Assert.Equal(unchecked((int)0x7FFFFFFF), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x7FFFFFFFFFFFFFFF))); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<nint>((nint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<nint>((nint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nint>((nint)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0xFFFFFFFF))); } } [Fact] public static void CreateSaturatingFromSByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<sbyte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<sbyte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.CreateSaturating<sbyte>(0x7F)); Assert.Equal(unchecked((int)0xFFFFFF80), NumberHelper<int>.CreateSaturating<sbyte>(unchecked((sbyte)0x80))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<sbyte>(unchecked((sbyte)0xFF))); } [Fact] public static void CreateSaturatingFromUInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<ushort>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<ushort>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateSaturating<ushort>(0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.CreateSaturating<ushort>(0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.CreateSaturating<ushort>(0xFFFF)); } [Fact] public static void CreateSaturatingFromUInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<uint>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<uint>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<uint>(0x7FFFFFFF)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<uint>(0x80000000)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<uint>(0xFFFFFFFF)); } [Fact] public static void CreateSaturatingFromUInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<ulong>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<ulong>(0x0000000000000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<ulong>(0x7FFFFFFFFFFFFFFF)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<ulong>(0x8000000000000000)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<ulong>(0xFFFFFFFFFFFFFFFF)); } [Fact] public static void CreateSaturatingFromUIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0x0000000000000001))); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0x8000000000000000))); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<nuint>((nuint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<nuint>((nuint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>((nuint)0x7FFFFFFF)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>((nuint)0x80000000)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>((nuint)0xFFFFFFFF)); } } [Fact] public static void CreateTruncatingFromByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<byte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<byte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.CreateTruncating<byte>(0x7F)); Assert.Equal((int)0x00000080, NumberHelper<int>.CreateTruncating<byte>(0x80)); Assert.Equal((int)0x000000FF, NumberHelper<int>.CreateTruncating<byte>(0xFF)); } [Fact] public static void CreateTruncatingFromCharTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<char>((char)0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<char>((char)0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateTruncating<char>((char)0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.CreateTruncating<char>((char)0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.CreateTruncating<char>((char)0xFFFF)); } [Fact] public static void CreateTruncatingFromInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<short>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<short>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateTruncating<short>(0x7FFF)); Assert.Equal(unchecked((int)0xFFFF8000), NumberHelper<int>.CreateTruncating<short>(unchecked((short)0x8000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<short>(unchecked((short)0xFFFF))); } [Fact] public static void CreateTruncatingFromInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<int>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<int>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateTruncating<int>(0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateTruncating<int>(unchecked(unchecked((int)0x80000000)))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<int>(unchecked(unchecked((int)0xFFFFFFFF)))); } [Fact] public static void CreateTruncatingFromInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<long>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<long>(0x0000000000000001)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<long>(0x7FFFFFFFFFFFFFFF)); Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<long>(unchecked((long)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<long>(unchecked((long)0xFFFFFFFFFFFFFFFF))); } [Fact] public static void CreateTruncatingFromIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x0000000000000001))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x7FFFFFFFFFFFFFFF))); Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nint>((nint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<nint>((nint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateTruncating<nint>((nint)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0xFFFFFFFF))); } } [Fact] public static void CreateTruncatingFromSByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<sbyte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<sbyte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.CreateTruncating<sbyte>(0x7F)); Assert.Equal(unchecked((int)0xFFFFFF80), NumberHelper<int>.CreateTruncating<sbyte>(unchecked((sbyte)0x80))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<sbyte>(unchecked((sbyte)0xFF))); } [Fact] public static void CreateTruncatingFromUInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<ushort>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<ushort>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateTruncating<ushort>(0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.CreateTruncating<ushort>(0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.CreateTruncating<ushort>(0xFFFF)); } [Fact] public static void CreateTruncatingFromUInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<uint>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<uint>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateTruncating<uint>(0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateTruncating<uint>(0x80000000)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<uint>(0xFFFFFFFF)); } [Fact] public static void CreateTruncatingFromUInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<ulong>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<ulong>(0x0000000000000001)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<ulong>(0x7FFFFFFFFFFFFFFF)); Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<ulong>(0x8000000000000000)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<ulong>(0xFFFFFFFFFFFFFFFF)); } [Fact] public static void CreateTruncatingFromUIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0x0000000000000001))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nuint>((nuint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<nuint>((nuint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateTruncating<nuint>((nuint)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateTruncating<nuint>((nuint)0x80000000)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nuint>((nuint)0xFFFFFFFF)); } } [Fact] public static void DivRemTest() { Assert.Equal(((int)0x00000000, (int)0x00000000), NumberHelper<int>.DivRem((int)0x00000000, 2)); Assert.Equal(((int)0x00000000, (int)0x00000001), NumberHelper<int>.DivRem((int)0x00000001, 2)); Assert.Equal(((int)0x3FFFFFFF, (int)0x00000001), NumberHelper<int>.DivRem((int)0x7FFFFFFF, 2)); Assert.Equal((unchecked((int)0xC0000000), (int)0x00000000), NumberHelper<int>.DivRem(unchecked((int)0x80000000), 2)); Assert.Equal(((int)0x00000000, unchecked((int)0xFFFFFFFF)), NumberHelper<int>.DivRem(unchecked((int)0xFFFFFFFF), 2)); } [Fact] public static void MaxTest() { Assert.Equal((int)0x00000001, NumberHelper<int>.Max((int)0x00000000, 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Max((int)0x00000001, 1)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Max((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Max(unchecked((int)0x80000000), 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Max(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void MinTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Min((int)0x00000000, 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Min((int)0x00000001, 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Min((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.Min(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Min(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void SignTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Sign((int)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Sign((int)0x00000001)); Assert.Equal((int)0x00000001, NumberHelper<int>.Sign((int)0x7FFFFFFF)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Sign(unchecked((int)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Sign(unchecked((int)0xFFFFFFFF))); } [Fact] public static void TryCreateFromByteTest() { int result; Assert.True(NumberHelper<int>.TryCreate<byte>(0x00, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<byte>(0x01, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<byte>(0x7F, out result)); Assert.Equal((int)0x0000007F, result); Assert.True(NumberHelper<int>.TryCreate<byte>(0x80, out result)); Assert.Equal((int)0x00000080, result); Assert.True(NumberHelper<int>.TryCreate<byte>(0xFF, out result)); Assert.Equal((int)0x000000FF, result); } [Fact] public static void TryCreateFromCharTest() { int result; Assert.True(NumberHelper<int>.TryCreate<char>((char)0x0000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<char>((char)0x0001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<char>((char)0x7FFF, out result)); Assert.Equal((int)0x00007FFF, result); Assert.True(NumberHelper<int>.TryCreate<char>((char)0x8000, out result)); Assert.Equal((int)0x00008000, result); Assert.True(NumberHelper<int>.TryCreate<char>((char)0xFFFF, out result)); Assert.Equal((int)0x0000FFFF, result); } [Fact] public static void TryCreateFromInt16Test() { int result; Assert.True(NumberHelper<int>.TryCreate<short>(0x0000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<short>(0x0001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<short>(0x7FFF, out result)); Assert.Equal((int)0x00007FFF, result); Assert.True(NumberHelper<int>.TryCreate<short>(unchecked((short)0x8000), out result)); Assert.Equal(unchecked((int)0xFFFF8000), result); Assert.True(NumberHelper<int>.TryCreate<short>(unchecked((short)0xFFFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } [Fact] public static void TryCreateFromInt32Test() { int result; Assert.True(NumberHelper<int>.TryCreate<int>(0x00000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<int>(0x00000001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<int>(0x7FFFFFFF, out result)); Assert.Equal((int)0x7FFFFFFF, result); Assert.True(NumberHelper<int>.TryCreate<int>(unchecked(unchecked((int)0x80000000)), out result)); Assert.Equal(unchecked((int)0x80000000), result); Assert.True(NumberHelper<int>.TryCreate<int>(unchecked(unchecked((int)0xFFFFFFFF)), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } [Fact] public static void TryCreateFromInt64Test() { int result; Assert.True(NumberHelper<int>.TryCreate<long>(0x0000000000000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<long>(0x0000000000000001, out result)); Assert.Equal((int)0x00000001, result); Assert.False(NumberHelper<int>.TryCreate<long>(0x7FFFFFFFFFFFFFFF, out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<long>(unchecked((long)0x8000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<long>(unchecked((long)0xFFFFFFFFFFFFFFFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } [Fact] public static void TryCreateFromIntPtrTest() { int result; if (Environment.Is64BitProcess) { Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x0000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x0000000000000001), out result)); Assert.Equal((int)0x00000001, result); Assert.False(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x7FFFFFFFFFFFFFFF), out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x8000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0xFFFFFFFFFFFFFFFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } else { Assert.True(NumberHelper<int>.TryCreate<nint>((nint)0x00000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nint>((nint)0x00000001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<nint>((nint)0x7FFFFFFF, out result)); Assert.Equal((int)0x7FFFFFFF, result); Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x80000000), out result)); Assert.Equal(unchecked((int)0x80000000), result); Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0xFFFFFFFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } } [Fact] public static void TryCreateFromSByteTest() { int result; Assert.True(NumberHelper<int>.TryCreate<sbyte>(0x00, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<sbyte>(0x01, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<sbyte>(0x7F, out result)); Assert.Equal((int)0x0000007F, result); Assert.True(NumberHelper<int>.TryCreate<sbyte>(unchecked((sbyte)0x80), out result)); Assert.Equal(unchecked((int)0xFFFFFF80), result); Assert.True(NumberHelper<int>.TryCreate<sbyte>(unchecked((sbyte)0xFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } [Fact] public static void TryCreateFromUInt16Test() { int result; Assert.True(NumberHelper<int>.TryCreate<ushort>(0x0000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<ushort>(0x0001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<ushort>(0x7FFF, out result)); Assert.Equal((int)0x00007FFF, result); Assert.True(NumberHelper<int>.TryCreate<ushort>(0x8000, out result)); Assert.Equal((int)0x00008000, result); Assert.True(NumberHelper<int>.TryCreate<ushort>(0xFFFF, out result)); Assert.Equal((int)0x0000FFFF, result); } [Fact] public static void TryCreateFromUInt32Test() { int result; Assert.True(NumberHelper<int>.TryCreate<uint>(0x00000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<uint>(0x00000001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<uint>(0x7FFFFFFF, out result)); Assert.Equal((int)0x7FFFFFFF, result); Assert.False(NumberHelper<int>.TryCreate<uint>(0x80000000, out result)); Assert.Equal(unchecked((int)0x00000000), result); Assert.False(NumberHelper<int>.TryCreate<uint>(0xFFFFFFFF, out result)); Assert.Equal(unchecked((int)0x00000000), result); } [Fact] public static void TryCreateFromUInt64Test() { int result; Assert.True(NumberHelper<int>.TryCreate<ulong>(0x0000000000000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<ulong>(0x0000000000000001, out result)); Assert.Equal((int)0x00000001, result); Assert.False(NumberHelper<int>.TryCreate<ulong>(0x7FFFFFFFFFFFFFFF, out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<ulong>(0x8000000000000000, out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<ulong>(0xFFFFFFFFFFFFFFFF, out result)); Assert.Equal((int)0x00000000, result); } [Fact] public static void TryCreateFromUIntPtrTest() { int result; if (Environment.Is64BitProcess) { Assert.True(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x0000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x0000000000000001), out result)); Assert.Equal((int)0x00000001, result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x7FFFFFFFFFFFFFFF), out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x8000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0xFFFFFFFFFFFFFFFF), out result)); Assert.Equal((int)0x00000000, result); } else { Assert.True(NumberHelper<int>.TryCreate<nuint>((nuint)0x00000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nuint>((nuint)0x00000001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<nuint>((nuint)0x7FFFFFFF, out result)); Assert.Equal((int)0x7FFFFFFF, result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x80000000), out result)); Assert.Equal(unchecked((int)0x00000000), result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0xFFFFFFFF), out result)); Assert.Equal(unchecked((int)0x00000000), result); } } [Fact] public static void op_LeftShiftTest() { Assert.Equal((int)0x00000000, ShiftOperatorsHelper<int, int>.op_LeftShift((int)0x00000000, 1)); Assert.Equal((int)0x00000002, ShiftOperatorsHelper<int, int>.op_LeftShift((int)0x00000001, 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), ShiftOperatorsHelper<int, int>.op_LeftShift((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x00000000, ShiftOperatorsHelper<int, int>.op_LeftShift(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), ShiftOperatorsHelper<int, int>.op_LeftShift(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_RightShiftTest() { Assert.Equal((int)0x00000000, ShiftOperatorsHelper<int, int>.op_RightShift((int)0x00000000, 1)); Assert.Equal((int)0x00000000, ShiftOperatorsHelper<int, int>.op_RightShift((int)0x00000001, 1)); Assert.Equal((int)0x3FFFFFFF, ShiftOperatorsHelper<int, int>.op_RightShift((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0xC0000000), ShiftOperatorsHelper<int, int>.op_RightShift(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), ShiftOperatorsHelper<int, int>.op_RightShift(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_SubtractionTest() { Assert.Equal(unchecked((int)0xFFFFFFFF), SubtractionOperatorsHelper<int, int, int>.op_Subtraction((int)0x00000000, 1)); Assert.Equal((int)0x00000000, SubtractionOperatorsHelper<int, int, int>.op_Subtraction((int)0x00000001, 1)); Assert.Equal((int)0x7FFFFFFE, SubtractionOperatorsHelper<int, int, int>.op_Subtraction((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x7FFFFFFF, SubtractionOperatorsHelper<int, int, int>.op_Subtraction(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), SubtractionOperatorsHelper<int, int, int>.op_Subtraction(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_UnaryNegationTest() { Assert.Equal((int)0x00000000, UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation((int)0x00000000)); Assert.Equal(unchecked((int)0xFFFFFFFF), UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation((int)0x00000001)); Assert.Equal(unchecked((int)0x80000001), UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation((int)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation(unchecked((int)0x80000000))); Assert.Equal((int)0x00000001, UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_UnaryPlusTest() { Assert.Equal((int)0x00000000, UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus((int)0x00000000)); Assert.Equal((int)0x00000001, UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus((int)0x00000001)); Assert.Equal((int)0x7FFFFFFF, UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus((int)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus(unchecked((int)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus(unchecked((int)0xFFFFFFFF))); } [Theory] [MemberData(nameof(Int32Tests.Parse_Valid_TestData), MemberType = typeof(Int32Tests))] public static void ParseValidStringTest(string value, NumberStyles style, IFormatProvider provider, int expected) { int result; // Default style and provider if ((style == NumberStyles.Integer) && (provider is null)) { Assert.True(ParseableHelper<int>.TryParse(value, provider, out result)); Assert.Equal(expected, result); Assert.Equal(expected, ParseableHelper<int>.Parse(value, provider)); } // Default provider if (provider is null) { Assert.Equal(expected, NumberHelper<int>.Parse(value, style, provider)); // Substitute default NumberFormatInfo Assert.True(NumberHelper<int>.TryParse(value, style, new NumberFormatInfo(), out result)); Assert.Equal(expected, result); Assert.Equal(expected, NumberHelper<int>.Parse(value, style, new NumberFormatInfo())); } // Default style if (style == NumberStyles.Integer) { Assert.Equal(expected, ParseableHelper<int>.Parse(value, provider)); } // Full overloads Assert.True(NumberHelper<int>.TryParse(value, style, provider, out result)); Assert.Equal(expected, result); Assert.Equal(expected, NumberHelper<int>.Parse(value, style, provider)); } [Theory] [MemberData(nameof(Int32Tests.Parse_Invalid_TestData), MemberType = typeof(Int32Tests))] public static void ParseInvalidStringTest(string value, NumberStyles style, IFormatProvider provider, Type exceptionType) { int result; // Default style and provider if ((style == NumberStyles.Integer) && (provider is null)) { Assert.False(ParseableHelper<int>.TryParse(value, provider, out result)); Assert.Equal(default(int), result); Assert.Throws(exceptionType, () => ParseableHelper<int>.Parse(value, provider)); } // Default provider if (provider is null) { Assert.Throws(exceptionType, () => NumberHelper<int>.Parse(value, style, provider)); // Substitute default NumberFormatInfo Assert.False(NumberHelper<int>.TryParse(value, style, new NumberFormatInfo(), out result)); Assert.Equal(default(int), result); Assert.Throws(exceptionType, () => NumberHelper<int>.Parse(value, style, new NumberFormatInfo())); } // Default style if (style == NumberStyles.Integer) { Assert.Throws(exceptionType, () => ParseableHelper<int>.Parse(value, provider)); } // Full overloads Assert.False(NumberHelper<int>.TryParse(value, style, provider, out result)); Assert.Equal(default(int), result); Assert.Throws(exceptionType, () => NumberHelper<int>.Parse(value, style, provider)); } [Theory] [MemberData(nameof(Int32Tests.Parse_ValidWithOffsetCount_TestData), MemberType = typeof(Int32Tests))] public static void ParseValidSpanTest(string value, int offset, int count, NumberStyles style, IFormatProvider provider, int expected) { int result; // Default style and provider if ((style == NumberStyles.Integer) && (provider is null)) { Assert.True(SpanParseableHelper<int>.TryParse(value.AsSpan(offset, count), provider, out result)); Assert.Equal(expected, result); } Assert.Equal(expected, NumberHelper<int>.Parse(value.AsSpan(offset, count), style, provider)); Assert.True(NumberHelper<int>.TryParse(value.AsSpan(offset, count), style, provider, out result)); Assert.Equal(expected, result); } [Theory] [MemberData(nameof(Int32Tests.Parse_Invalid_TestData), MemberType = typeof(Int32Tests))] public static void ParseInvalidSpanTest(string value, NumberStyles style, IFormatProvider provider, Type exceptionType) { if (value is null) { return; } int result; // Default style and provider if ((style == NumberStyles.Integer) && (provider is null)) { Assert.False(SpanParseableHelper<int>.TryParse(value.AsSpan(), provider, out result)); Assert.Equal(default(int), result); } Assert.Throws(exceptionType, () => NumberHelper<int>.Parse(value.AsSpan(), style, provider)); Assert.False(NumberHelper<int>.TryParse(value.AsSpan(), style, provider, out result)); Assert.Equal(default(int), result); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; using System.Runtime.Versioning; using Xunit; namespace System.Tests { [RequiresPreviewFeaturesAttribute] public class Int32Tests_GenericMath { [Fact] public static void AdditiveIdentityTest() { Assert.Equal((int)0x00000000, AdditiveIdentityHelper<int, int>.AdditiveIdentity); } [Fact] public static void MinValueTest() { Assert.Equal(unchecked((int)0x80000000), MinMaxValueHelper<int>.MinValue); } [Fact] public static void MaxValueTest() { Assert.Equal((int)0x7FFFFFFF, MinMaxValueHelper<int>.MaxValue); } [Fact] public static void MultiplicativeIdentityTest() { Assert.Equal((int)0x00000001, MultiplicativeIdentityHelper<int, int>.MultiplicativeIdentity); } [Fact] public static void NegativeOneTest() { Assert.Equal(unchecked((int)0xFFFFFFFF), SignedNumberHelper<int>.NegativeOne); } [Fact] public static void OneTest() { Assert.Equal((int)0x00000001, NumberHelper<int>.One); } [Fact] public static void ZeroTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Zero); } [Fact] public static void op_AdditionTest() { Assert.Equal((int)0x00000001, AdditionOperatorsHelper<int, int, int>.op_Addition((int)0x00000000, 1)); Assert.Equal((int)0x00000002, AdditionOperatorsHelper<int, int, int>.op_Addition((int)0x00000001, 1)); Assert.Equal(unchecked((int)0x80000000), AdditionOperatorsHelper<int, int, int>.op_Addition((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0x80000001), AdditionOperatorsHelper<int, int, int>.op_Addition(unchecked((int)0x80000000), 1)); Assert.Equal((int)0x00000000, AdditionOperatorsHelper<int, int, int>.op_Addition(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void LeadingZeroCountTest() { Assert.Equal((int)0x00000020, BinaryIntegerHelper<int>.LeadingZeroCount((int)0x00000000)); Assert.Equal((int)0x0000001F, BinaryIntegerHelper<int>.LeadingZeroCount((int)0x00000001)); Assert.Equal((int)0x00000001, BinaryIntegerHelper<int>.LeadingZeroCount((int)0x7FFFFFFF)); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.LeadingZeroCount(unchecked((int)0x80000000))); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.LeadingZeroCount(unchecked((int)0xFFFFFFFF))); } [Fact] public static void PopCountTest() { Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.PopCount((int)0x00000000)); Assert.Equal((int)0x00000001, BinaryIntegerHelper<int>.PopCount((int)0x00000001)); Assert.Equal((int)0x0000001F, BinaryIntegerHelper<int>.PopCount((int)0x7FFFFFFF)); Assert.Equal((int)0x00000001, BinaryIntegerHelper<int>.PopCount(unchecked((int)0x80000000))); Assert.Equal((int)0x00000020, BinaryIntegerHelper<int>.PopCount(unchecked((int)0xFFFFFFFF))); } [Fact] public static void RotateLeftTest() { Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.RotateLeft((int)0x00000000, 1)); Assert.Equal((int)0x00000002, BinaryIntegerHelper<int>.RotateLeft((int)0x00000001, 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), BinaryIntegerHelper<int>.RotateLeft((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x00000001, BinaryIntegerHelper<int>.RotateLeft(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), BinaryIntegerHelper<int>.RotateLeft(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void RotateRightTest() { Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.RotateRight((int)0x00000000, 1)); Assert.Equal(unchecked((int)0x80000000), BinaryIntegerHelper<int>.RotateRight((int)0x00000001, 1)); Assert.Equal(unchecked((int)0xBFFFFFFF), BinaryIntegerHelper<int>.RotateRight((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x40000000, BinaryIntegerHelper<int>.RotateRight(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), BinaryIntegerHelper<int>.RotateRight(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void TrailingZeroCountTest() { Assert.Equal((int)0x00000020, BinaryIntegerHelper<int>.TrailingZeroCount((int)0x00000000)); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.TrailingZeroCount((int)0x00000001)); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.TrailingZeroCount((int)0x7FFFFFFF)); Assert.Equal((int)0x0000001F, BinaryIntegerHelper<int>.TrailingZeroCount(unchecked((int)0x80000000))); Assert.Equal((int)0x00000000, BinaryIntegerHelper<int>.TrailingZeroCount(unchecked((int)0xFFFFFFFF))); } [Fact] public static void IsPow2Test() { Assert.False(BinaryNumberHelper<int>.IsPow2((int)0x00000000)); Assert.True(BinaryNumberHelper<int>.IsPow2((int)0x00000001)); Assert.False(BinaryNumberHelper<int>.IsPow2((int)0x7FFFFFFF)); Assert.False(BinaryNumberHelper<int>.IsPow2(unchecked((int)0x80000000))); Assert.False(BinaryNumberHelper<int>.IsPow2(unchecked((int)0xFFFFFFFF))); } [Fact] public static void Log2Test() { Assert.Equal((int)0x00000000, BinaryNumberHelper<int>.Log2((int)0x00000000)); Assert.Equal((int)0x00000000, BinaryNumberHelper<int>.Log2((int)0x00000001)); Assert.Equal((int)0x0000001E, BinaryNumberHelper<int>.Log2((int)0x7FFFFFFF)); Assert.Throws<ArgumentOutOfRangeException>(() => BinaryNumberHelper<int>.Log2(unchecked((int)0x80000000))); Assert.Throws<ArgumentOutOfRangeException>(() => BinaryNumberHelper<int>.Log2(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_BitwiseAndTest() { Assert.Equal((int)0x00000000, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd((int)0x00000000, 1)); Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd((int)0x00000001, 1)); Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x00000000, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd(unchecked((int)0x80000000), 1)); Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseAnd(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_BitwiseOrTest() { Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr((int)0x00000000, 1)); Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr((int)0x00000001, 1)); Assert.Equal((int)0x7FFFFFFF, BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0x80000001), BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), BitwiseOperatorsHelper<int, int, int>.op_BitwiseOr(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_ExclusiveOrTest() { Assert.Equal((int)0x00000001, BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr((int)0x00000000, 1)); Assert.Equal((int)0x00000000, BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr((int)0x00000001, 1)); Assert.Equal((int)0x7FFFFFFE, BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0x80000001), BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), BitwiseOperatorsHelper<int, int, int>.op_ExclusiveOr(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_OnesComplementTest() { Assert.Equal(unchecked((int)0xFFFFFFFF), BitwiseOperatorsHelper<int, int, int>.op_OnesComplement((int)0x00000000)); Assert.Equal(unchecked((int)0xFFFFFFFE), BitwiseOperatorsHelper<int, int, int>.op_OnesComplement((int)0x00000001)); Assert.Equal(unchecked((int)0x80000000), BitwiseOperatorsHelper<int, int, int>.op_OnesComplement((int)0x7FFFFFFF)); Assert.Equal((int)0x7FFFFFFF, BitwiseOperatorsHelper<int, int, int>.op_OnesComplement(unchecked((int)0x80000000))); Assert.Equal((int)0x00000000, BitwiseOperatorsHelper<int, int, int>.op_OnesComplement(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_LessThanTest() { Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThan((int)0x00000000, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_LessThan((int)0x00000001, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_LessThan((int)0x7FFFFFFF, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThan(unchecked((int)0x80000000), 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThan(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_LessThanOrEqualTest() { Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual((int)0x00000000, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual((int)0x00000001, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual((int)0x7FFFFFFF, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual(unchecked((int)0x80000000), 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_LessThanOrEqual(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_GreaterThanTest() { Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThan((int)0x00000000, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThan((int)0x00000001, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_GreaterThan((int)0x7FFFFFFF, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThan(unchecked((int)0x80000000), 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThan(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_GreaterThanOrEqualTest() { Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual((int)0x00000000, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual((int)0x00000001, 1)); Assert.True(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual((int)0x7FFFFFFF, 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual(unchecked((int)0x80000000), 1)); Assert.False(ComparisonOperatorsHelper<int, int>.op_GreaterThanOrEqual(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_DecrementTest() { Assert.Equal(unchecked((int)0xFFFFFFFF), DecrementOperatorsHelper<int>.op_Decrement((int)0x00000000)); Assert.Equal((int)0x00000000, DecrementOperatorsHelper<int>.op_Decrement((int)0x00000001)); Assert.Equal((int)0x7FFFFFFE, DecrementOperatorsHelper<int>.op_Decrement((int)0x7FFFFFFF)); Assert.Equal((int)0x7FFFFFFF, DecrementOperatorsHelper<int>.op_Decrement(unchecked((int)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFE), DecrementOperatorsHelper<int>.op_Decrement(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_DivisionTest() { Assert.Equal((int)0x00000000, DivisionOperatorsHelper<int, int, int>.op_Division((int)0x00000000, 2)); Assert.Equal((int)0x00000000, DivisionOperatorsHelper<int, int, int>.op_Division((int)0x00000001, 2)); Assert.Equal((int)0x3FFFFFFF, DivisionOperatorsHelper<int, int, int>.op_Division((int)0x7FFFFFFF, 2)); Assert.Equal(unchecked((int)0xC0000000), DivisionOperatorsHelper<int, int, int>.op_Division(unchecked((int)0x80000000), 2)); Assert.Equal((int)0x00000000, DivisionOperatorsHelper<int, int, int>.op_Division(unchecked((int)0xFFFFFFFF), 2)); } [Fact] public static void op_EqualityTest() { Assert.False(EqualityOperatorsHelper<int, int>.op_Equality((int)0x00000000, 1)); Assert.True(EqualityOperatorsHelper<int, int>.op_Equality((int)0x00000001, 1)); Assert.False(EqualityOperatorsHelper<int, int>.op_Equality((int)0x7FFFFFFF, 1)); Assert.False(EqualityOperatorsHelper<int, int>.op_Equality(unchecked((int)0x80000000), 1)); Assert.False(EqualityOperatorsHelper<int, int>.op_Equality(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_InequalityTest() { Assert.True(EqualityOperatorsHelper<int, int>.op_Inequality((int)0x00000000, 1)); Assert.False(EqualityOperatorsHelper<int, int>.op_Inequality((int)0x00000001, 1)); Assert.True(EqualityOperatorsHelper<int, int>.op_Inequality((int)0x7FFFFFFF, 1)); Assert.True(EqualityOperatorsHelper<int, int>.op_Inequality(unchecked((int)0x80000000), 1)); Assert.True(EqualityOperatorsHelper<int, int>.op_Inequality(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_IncrementTest() { Assert.Equal((int)0x00000001, IncrementOperatorsHelper<int>.op_Increment((int)0x00000000)); Assert.Equal((int)0x00000002, IncrementOperatorsHelper<int>.op_Increment((int)0x00000001)); Assert.Equal(unchecked((int)0x80000000), IncrementOperatorsHelper<int>.op_Increment((int)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000001), IncrementOperatorsHelper<int>.op_Increment(unchecked((int)0x80000000))); Assert.Equal((int)0x00000000, IncrementOperatorsHelper<int>.op_Increment(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_ModulusTest() { Assert.Equal((int)0x00000000, ModulusOperatorsHelper<int, int, int>.op_Modulus((int)0x00000000, 2)); Assert.Equal((int)0x00000001, ModulusOperatorsHelper<int, int, int>.op_Modulus((int)0x00000001, 2)); Assert.Equal((int)0x00000001, ModulusOperatorsHelper<int, int, int>.op_Modulus((int)0x7FFFFFFF, 2)); Assert.Equal((int)0x00000000, ModulusOperatorsHelper<int, int, int>.op_Modulus(unchecked((int)0x80000000), 2)); Assert.Equal(unchecked((int)0xFFFFFFFF), ModulusOperatorsHelper<int, int, int>.op_Modulus(unchecked((int)0xFFFFFFFF), 2)); } [Fact] public static void op_MultiplyTest() { Assert.Equal((int)0x00000000, MultiplyOperatorsHelper<int, int, int>.op_Multiply((int)0x00000000, 2)); Assert.Equal((int)0x00000002, MultiplyOperatorsHelper<int, int, int>.op_Multiply((int)0x00000001, 2)); Assert.Equal(unchecked((int)0xFFFFFFFE), MultiplyOperatorsHelper<int, int, int>.op_Multiply((int)0x7FFFFFFF, 2)); Assert.Equal((int)0x00000000, MultiplyOperatorsHelper<int, int, int>.op_Multiply(unchecked((int)0x80000000), 2)); Assert.Equal(unchecked((int)0xFFFFFFFE), MultiplyOperatorsHelper<int, int, int>.op_Multiply(unchecked((int)0xFFFFFFFF), 2)); } [Fact] public static void AbsTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Abs((int)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Abs((int)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Abs((int)0x7FFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Abs(unchecked((int)0x80000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.Abs(unchecked((int)0xFFFFFFFF))); } [Fact] public static void ClampTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Clamp((int)0x00000000, unchecked((int)0xFFFFFFC0), 0x003F)); Assert.Equal((int)0x00000001, NumberHelper<int>.Clamp((int)0x00000001, unchecked((int)0xFFFFFFC0), 0x003F)); Assert.Equal((int)0x0000003F, NumberHelper<int>.Clamp((int)0x7FFFFFFF, unchecked((int)0xFFFFFFC0), 0x003F)); Assert.Equal(unchecked((int)0xFFFFFFC0), NumberHelper<int>.Clamp(unchecked((int)0x80000000), unchecked((int)0xFFFFFFC0), 0x003F)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Clamp(unchecked((int)0xFFFFFFFF), unchecked((int)0xFFFFFFC0), 0x003F)); } [Fact] public static void CreateFromByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<byte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<byte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.Create<byte>(0x7F)); Assert.Equal((int)0x00000080, NumberHelper<int>.Create<byte>(0x80)); Assert.Equal((int)0x000000FF, NumberHelper<int>.Create<byte>(0xFF)); } [Fact] public static void CreateFromCharTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<char>((char)0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<char>((char)0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.Create<char>((char)0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.Create<char>((char)0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.Create<char>((char)0xFFFF)); } [Fact] public static void CreateFromInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<short>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<short>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.Create<short>(0x7FFF)); Assert.Equal(unchecked((int)0xFFFF8000), NumberHelper<int>.Create<short>(unchecked((short)0x8000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<short>(unchecked((short)0xFFFF))); } [Fact] public static void CreateFromInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<int>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<int>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Create<int>(0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.Create<int>(unchecked(unchecked((int)0x80000000)))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<int>(unchecked(unchecked((int)0xFFFFFFFF)))); } [Fact] public static void CreateFromInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<long>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<long>(0x0000000000000001)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<long>(0x7FFFFFFFFFFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<long>(unchecked((long)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<long>(unchecked((long)0xFFFFFFFFFFFFFFFF))); } [Fact] public static void CreateFromIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<nint>(unchecked((nint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<nint>(unchecked((nint)0x0000000000000001))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nint>(unchecked((nint)0x7FFFFFFFFFFFFFFF))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nint>(unchecked((nint)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<nint>(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<nint>((nint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<nint>((nint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Create<nint>((nint)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.Create<nint>(unchecked((nint)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<nint>(unchecked((nint)0xFFFFFFFF))); } } [Fact] public static void CreateFromSByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<sbyte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<sbyte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.Create<sbyte>(0x7F)); Assert.Equal(unchecked((int)0xFFFFFF80), NumberHelper<int>.Create<sbyte>(unchecked((sbyte)0x80))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Create<sbyte>(unchecked((sbyte)0xFF))); } [Fact] public static void CreateFromUInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<ushort>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<ushort>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.Create<ushort>(0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.Create<ushort>(0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.Create<ushort>(0xFFFF)); } [Fact] public static void CreateFromUInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<uint>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<uint>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Create<uint>(0x7FFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<uint>(0x80000000)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<uint>(0xFFFFFFFF)); } [Fact] public static void CreateFromUInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<ulong>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<ulong>(0x0000000000000001)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<ulong>(0x7FFFFFFFFFFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<ulong>(0x8000000000000000)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<ulong>(0xFFFFFFFFFFFFFFFF)); } [Fact] public static void CreateFromUIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<nuint>(unchecked((nuint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<nuint>(unchecked((nuint)0x0000000000000001))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>(unchecked((nuint)0x8000000000000000))); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.Create<nuint>((nuint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Create<nuint>((nuint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Create<nuint>((nuint)0x7FFFFFFF)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>((nuint)0x80000000)); Assert.Throws<OverflowException>(() => NumberHelper<int>.Create<nuint>((nuint)0xFFFFFFFF)); } } [Fact] public static void CreateSaturatingFromByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<byte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<byte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.CreateSaturating<byte>(0x7F)); Assert.Equal((int)0x00000080, NumberHelper<int>.CreateSaturating<byte>(0x80)); Assert.Equal((int)0x000000FF, NumberHelper<int>.CreateSaturating<byte>(0xFF)); } [Fact] public static void CreateSaturatingFromCharTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<char>((char)0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<char>((char)0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateSaturating<char>((char)0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.CreateSaturating<char>((char)0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.CreateSaturating<char>((char)0xFFFF)); } [Fact] public static void CreateSaturatingFromInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<short>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<short>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateSaturating<short>(0x7FFF)); Assert.Equal(unchecked((int)0xFFFF8000), NumberHelper<int>.CreateSaturating<short>(unchecked((short)0x8000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<short>(unchecked((short)0xFFFF))); } [Fact] public static void CreateSaturatingFromInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<int>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<int>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<int>(0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateSaturating<int>(unchecked(unchecked((int)0x80000000)))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<int>(unchecked(unchecked((int)0xFFFFFFFF)))); } [Fact] public static void CreateSaturatingFromInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<long>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<long>(0x0000000000000001)); Assert.Equal(unchecked((int)0x7FFFFFFF), NumberHelper<int>.CreateSaturating<long>(0x7FFFFFFFFFFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateSaturating<long>(unchecked((long)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<long>(unchecked((long)0xFFFFFFFFFFFFFFFF))); } [Fact] public static void CreateSaturatingFromIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x0000000000000001))); Assert.Equal(unchecked((int)0x7FFFFFFF), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x7FFFFFFFFFFFFFFF))); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<nint>((nint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<nint>((nint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nint>((nint)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<nint>(unchecked((nint)0xFFFFFFFF))); } } [Fact] public static void CreateSaturatingFromSByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<sbyte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<sbyte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.CreateSaturating<sbyte>(0x7F)); Assert.Equal(unchecked((int)0xFFFFFF80), NumberHelper<int>.CreateSaturating<sbyte>(unchecked((sbyte)0x80))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateSaturating<sbyte>(unchecked((sbyte)0xFF))); } [Fact] public static void CreateSaturatingFromUInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<ushort>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<ushort>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateSaturating<ushort>(0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.CreateSaturating<ushort>(0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.CreateSaturating<ushort>(0xFFFF)); } [Fact] public static void CreateSaturatingFromUInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<uint>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<uint>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<uint>(0x7FFFFFFF)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<uint>(0x80000000)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<uint>(0xFFFFFFFF)); } [Fact] public static void CreateSaturatingFromUInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<ulong>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<ulong>(0x0000000000000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<ulong>(0x7FFFFFFFFFFFFFFF)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<ulong>(0x8000000000000000)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<ulong>(0xFFFFFFFFFFFFFFFF)); } [Fact] public static void CreateSaturatingFromUIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0x0000000000000001))); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0x8000000000000000))); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateSaturating<nuint>((nuint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateSaturating<nuint>((nuint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>((nuint)0x7FFFFFFF)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>((nuint)0x80000000)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateSaturating<nuint>((nuint)0xFFFFFFFF)); } } [Fact] public static void CreateTruncatingFromByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<byte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<byte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.CreateTruncating<byte>(0x7F)); Assert.Equal((int)0x00000080, NumberHelper<int>.CreateTruncating<byte>(0x80)); Assert.Equal((int)0x000000FF, NumberHelper<int>.CreateTruncating<byte>(0xFF)); } [Fact] public static void CreateTruncatingFromCharTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<char>((char)0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<char>((char)0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateTruncating<char>((char)0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.CreateTruncating<char>((char)0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.CreateTruncating<char>((char)0xFFFF)); } [Fact] public static void CreateTruncatingFromInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<short>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<short>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateTruncating<short>(0x7FFF)); Assert.Equal(unchecked((int)0xFFFF8000), NumberHelper<int>.CreateTruncating<short>(unchecked((short)0x8000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<short>(unchecked((short)0xFFFF))); } [Fact] public static void CreateTruncatingFromInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<int>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<int>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateTruncating<int>(0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateTruncating<int>(unchecked(unchecked((int)0x80000000)))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<int>(unchecked(unchecked((int)0xFFFFFFFF)))); } [Fact] public static void CreateTruncatingFromInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<long>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<long>(0x0000000000000001)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<long>(0x7FFFFFFFFFFFFFFF)); Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<long>(unchecked((long)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<long>(unchecked((long)0xFFFFFFFFFFFFFFFF))); } [Fact] public static void CreateTruncatingFromIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x0000000000000001))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x7FFFFFFFFFFFFFFF))); Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nint>((nint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<nint>((nint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateTruncating<nint>((nint)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nint>(unchecked((nint)0xFFFFFFFF))); } } [Fact] public static void CreateTruncatingFromSByteTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<sbyte>(0x00)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<sbyte>(0x01)); Assert.Equal((int)0x0000007F, NumberHelper<int>.CreateTruncating<sbyte>(0x7F)); Assert.Equal(unchecked((int)0xFFFFFF80), NumberHelper<int>.CreateTruncating<sbyte>(unchecked((sbyte)0x80))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<sbyte>(unchecked((sbyte)0xFF))); } [Fact] public static void CreateTruncatingFromUInt16Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<ushort>(0x0000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<ushort>(0x0001)); Assert.Equal((int)0x00007FFF, NumberHelper<int>.CreateTruncating<ushort>(0x7FFF)); Assert.Equal((int)0x00008000, NumberHelper<int>.CreateTruncating<ushort>(0x8000)); Assert.Equal((int)0x0000FFFF, NumberHelper<int>.CreateTruncating<ushort>(0xFFFF)); } [Fact] public static void CreateTruncatingFromUInt32Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<uint>(0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<uint>(0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateTruncating<uint>(0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateTruncating<uint>(0x80000000)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<uint>(0xFFFFFFFF)); } [Fact] public static void CreateTruncatingFromUInt64Test() { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<ulong>(0x0000000000000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<ulong>(0x0000000000000001)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<ulong>(0x7FFFFFFFFFFFFFFF)); Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<ulong>(0x8000000000000000)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<ulong>(0xFFFFFFFFFFFFFFFF)); } [Fact] public static void CreateTruncatingFromUIntPtrTest() { if (Environment.Is64BitProcess) { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0x0000000000000000))); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0x0000000000000001))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0x7FFFFFFFFFFFFFFF))); Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0x8000000000000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nuint>(unchecked((nuint)0xFFFFFFFFFFFFFFFF))); } else { Assert.Equal((int)0x00000000, NumberHelper<int>.CreateTruncating<nuint>((nuint)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.CreateTruncating<nuint>((nuint)0x00000001)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.CreateTruncating<nuint>((nuint)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.CreateTruncating<nuint>((nuint)0x80000000)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.CreateTruncating<nuint>((nuint)0xFFFFFFFF)); } } [Fact] public static void DivRemTest() { Assert.Equal(((int)0x00000000, (int)0x00000000), NumberHelper<int>.DivRem((int)0x00000000, 2)); Assert.Equal(((int)0x00000000, (int)0x00000001), NumberHelper<int>.DivRem((int)0x00000001, 2)); Assert.Equal(((int)0x3FFFFFFF, (int)0x00000001), NumberHelper<int>.DivRem((int)0x7FFFFFFF, 2)); Assert.Equal((unchecked((int)0xC0000000), (int)0x00000000), NumberHelper<int>.DivRem(unchecked((int)0x80000000), 2)); Assert.Equal(((int)0x00000000, unchecked((int)0xFFFFFFFF)), NumberHelper<int>.DivRem(unchecked((int)0xFFFFFFFF), 2)); } [Fact] public static void MaxTest() { Assert.Equal((int)0x00000001, NumberHelper<int>.Max((int)0x00000000, 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Max((int)0x00000001, 1)); Assert.Equal((int)0x7FFFFFFF, NumberHelper<int>.Max((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Max(unchecked((int)0x80000000), 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Max(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void MinTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Min((int)0x00000000, 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Min((int)0x00000001, 1)); Assert.Equal((int)0x00000001, NumberHelper<int>.Min((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0x80000000), NumberHelper<int>.Min(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Min(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void SignTest() { Assert.Equal((int)0x00000000, NumberHelper<int>.Sign((int)0x00000000)); Assert.Equal((int)0x00000001, NumberHelper<int>.Sign((int)0x00000001)); Assert.Equal((int)0x00000001, NumberHelper<int>.Sign((int)0x7FFFFFFF)); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Sign(unchecked((int)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), NumberHelper<int>.Sign(unchecked((int)0xFFFFFFFF))); } [Fact] public static void TryCreateFromByteTest() { int result; Assert.True(NumberHelper<int>.TryCreate<byte>(0x00, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<byte>(0x01, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<byte>(0x7F, out result)); Assert.Equal((int)0x0000007F, result); Assert.True(NumberHelper<int>.TryCreate<byte>(0x80, out result)); Assert.Equal((int)0x00000080, result); Assert.True(NumberHelper<int>.TryCreate<byte>(0xFF, out result)); Assert.Equal((int)0x000000FF, result); } [Fact] public static void TryCreateFromCharTest() { int result; Assert.True(NumberHelper<int>.TryCreate<char>((char)0x0000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<char>((char)0x0001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<char>((char)0x7FFF, out result)); Assert.Equal((int)0x00007FFF, result); Assert.True(NumberHelper<int>.TryCreate<char>((char)0x8000, out result)); Assert.Equal((int)0x00008000, result); Assert.True(NumberHelper<int>.TryCreate<char>((char)0xFFFF, out result)); Assert.Equal((int)0x0000FFFF, result); } [Fact] public static void TryCreateFromInt16Test() { int result; Assert.True(NumberHelper<int>.TryCreate<short>(0x0000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<short>(0x0001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<short>(0x7FFF, out result)); Assert.Equal((int)0x00007FFF, result); Assert.True(NumberHelper<int>.TryCreate<short>(unchecked((short)0x8000), out result)); Assert.Equal(unchecked((int)0xFFFF8000), result); Assert.True(NumberHelper<int>.TryCreate<short>(unchecked((short)0xFFFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } [Fact] public static void TryCreateFromInt32Test() { int result; Assert.True(NumberHelper<int>.TryCreate<int>(0x00000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<int>(0x00000001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<int>(0x7FFFFFFF, out result)); Assert.Equal((int)0x7FFFFFFF, result); Assert.True(NumberHelper<int>.TryCreate<int>(unchecked(unchecked((int)0x80000000)), out result)); Assert.Equal(unchecked((int)0x80000000), result); Assert.True(NumberHelper<int>.TryCreate<int>(unchecked(unchecked((int)0xFFFFFFFF)), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } [Fact] public static void TryCreateFromInt64Test() { int result; Assert.True(NumberHelper<int>.TryCreate<long>(0x0000000000000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<long>(0x0000000000000001, out result)); Assert.Equal((int)0x00000001, result); Assert.False(NumberHelper<int>.TryCreate<long>(0x7FFFFFFFFFFFFFFF, out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<long>(unchecked((long)0x8000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<long>(unchecked((long)0xFFFFFFFFFFFFFFFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } [Fact] public static void TryCreateFromIntPtrTest() { int result; if (Environment.Is64BitProcess) { Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x0000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x0000000000000001), out result)); Assert.Equal((int)0x00000001, result); Assert.False(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x7FFFFFFFFFFFFFFF), out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x8000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0xFFFFFFFFFFFFFFFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } else { Assert.True(NumberHelper<int>.TryCreate<nint>((nint)0x00000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nint>((nint)0x00000001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<nint>((nint)0x7FFFFFFF, out result)); Assert.Equal((int)0x7FFFFFFF, result); Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0x80000000), out result)); Assert.Equal(unchecked((int)0x80000000), result); Assert.True(NumberHelper<int>.TryCreate<nint>(unchecked((nint)0xFFFFFFFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } } [Fact] public static void TryCreateFromSByteTest() { int result; Assert.True(NumberHelper<int>.TryCreate<sbyte>(0x00, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<sbyte>(0x01, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<sbyte>(0x7F, out result)); Assert.Equal((int)0x0000007F, result); Assert.True(NumberHelper<int>.TryCreate<sbyte>(unchecked((sbyte)0x80), out result)); Assert.Equal(unchecked((int)0xFFFFFF80), result); Assert.True(NumberHelper<int>.TryCreate<sbyte>(unchecked((sbyte)0xFF), out result)); Assert.Equal(unchecked((int)0xFFFFFFFF), result); } [Fact] public static void TryCreateFromUInt16Test() { int result; Assert.True(NumberHelper<int>.TryCreate<ushort>(0x0000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<ushort>(0x0001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<ushort>(0x7FFF, out result)); Assert.Equal((int)0x00007FFF, result); Assert.True(NumberHelper<int>.TryCreate<ushort>(0x8000, out result)); Assert.Equal((int)0x00008000, result); Assert.True(NumberHelper<int>.TryCreate<ushort>(0xFFFF, out result)); Assert.Equal((int)0x0000FFFF, result); } [Fact] public static void TryCreateFromUInt32Test() { int result; Assert.True(NumberHelper<int>.TryCreate<uint>(0x00000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<uint>(0x00000001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<uint>(0x7FFFFFFF, out result)); Assert.Equal((int)0x7FFFFFFF, result); Assert.False(NumberHelper<int>.TryCreate<uint>(0x80000000, out result)); Assert.Equal(unchecked((int)0x00000000), result); Assert.False(NumberHelper<int>.TryCreate<uint>(0xFFFFFFFF, out result)); Assert.Equal(unchecked((int)0x00000000), result); } [Fact] public static void TryCreateFromUInt64Test() { int result; Assert.True(NumberHelper<int>.TryCreate<ulong>(0x0000000000000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<ulong>(0x0000000000000001, out result)); Assert.Equal((int)0x00000001, result); Assert.False(NumberHelper<int>.TryCreate<ulong>(0x7FFFFFFFFFFFFFFF, out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<ulong>(0x8000000000000000, out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<ulong>(0xFFFFFFFFFFFFFFFF, out result)); Assert.Equal((int)0x00000000, result); } [Fact] public static void TryCreateFromUIntPtrTest() { int result; if (Environment.Is64BitProcess) { Assert.True(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x0000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x0000000000000001), out result)); Assert.Equal((int)0x00000001, result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x7FFFFFFFFFFFFFFF), out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x8000000000000000), out result)); Assert.Equal((int)0x00000000, result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0xFFFFFFFFFFFFFFFF), out result)); Assert.Equal((int)0x00000000, result); } else { Assert.True(NumberHelper<int>.TryCreate<nuint>((nuint)0x00000000, out result)); Assert.Equal((int)0x00000000, result); Assert.True(NumberHelper<int>.TryCreate<nuint>((nuint)0x00000001, out result)); Assert.Equal((int)0x00000001, result); Assert.True(NumberHelper<int>.TryCreate<nuint>((nuint)0x7FFFFFFF, out result)); Assert.Equal((int)0x7FFFFFFF, result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0x80000000), out result)); Assert.Equal(unchecked((int)0x00000000), result); Assert.False(NumberHelper<int>.TryCreate<nuint>(unchecked((nuint)0xFFFFFFFF), out result)); Assert.Equal(unchecked((int)0x00000000), result); } } [Fact] public static void op_LeftShiftTest() { Assert.Equal((int)0x00000000, ShiftOperatorsHelper<int, int>.op_LeftShift((int)0x00000000, 1)); Assert.Equal((int)0x00000002, ShiftOperatorsHelper<int, int>.op_LeftShift((int)0x00000001, 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), ShiftOperatorsHelper<int, int>.op_LeftShift((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x00000000, ShiftOperatorsHelper<int, int>.op_LeftShift(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), ShiftOperatorsHelper<int, int>.op_LeftShift(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_RightShiftTest() { Assert.Equal((int)0x00000000, ShiftOperatorsHelper<int, int>.op_RightShift((int)0x00000000, 1)); Assert.Equal((int)0x00000000, ShiftOperatorsHelper<int, int>.op_RightShift((int)0x00000001, 1)); Assert.Equal((int)0x3FFFFFFF, ShiftOperatorsHelper<int, int>.op_RightShift((int)0x7FFFFFFF, 1)); Assert.Equal(unchecked((int)0xC0000000), ShiftOperatorsHelper<int, int>.op_RightShift(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFF), ShiftOperatorsHelper<int, int>.op_RightShift(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_SubtractionTest() { Assert.Equal(unchecked((int)0xFFFFFFFF), SubtractionOperatorsHelper<int, int, int>.op_Subtraction((int)0x00000000, 1)); Assert.Equal((int)0x00000000, SubtractionOperatorsHelper<int, int, int>.op_Subtraction((int)0x00000001, 1)); Assert.Equal((int)0x7FFFFFFE, SubtractionOperatorsHelper<int, int, int>.op_Subtraction((int)0x7FFFFFFF, 1)); Assert.Equal((int)0x7FFFFFFF, SubtractionOperatorsHelper<int, int, int>.op_Subtraction(unchecked((int)0x80000000), 1)); Assert.Equal(unchecked((int)0xFFFFFFFE), SubtractionOperatorsHelper<int, int, int>.op_Subtraction(unchecked((int)0xFFFFFFFF), 1)); } [Fact] public static void op_UnaryNegationTest() { Assert.Equal((int)0x00000000, UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation((int)0x00000000)); Assert.Equal(unchecked((int)0xFFFFFFFF), UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation((int)0x00000001)); Assert.Equal(unchecked((int)0x80000001), UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation((int)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation(unchecked((int)0x80000000))); Assert.Equal((int)0x00000001, UnaryNegationOperatorsHelper<int, int>.op_UnaryNegation(unchecked((int)0xFFFFFFFF))); } [Fact] public static void op_UnaryPlusTest() { Assert.Equal((int)0x00000000, UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus((int)0x00000000)); Assert.Equal((int)0x00000001, UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus((int)0x00000001)); Assert.Equal((int)0x7FFFFFFF, UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus((int)0x7FFFFFFF)); Assert.Equal(unchecked((int)0x80000000), UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus(unchecked((int)0x80000000))); Assert.Equal(unchecked((int)0xFFFFFFFF), UnaryPlusOperatorsHelper<int, int>.op_UnaryPlus(unchecked((int)0xFFFFFFFF))); } [Theory] [MemberData(nameof(Int32Tests.Parse_Valid_TestData), MemberType = typeof(Int32Tests))] public static void ParseValidStringTest(string value, NumberStyles style, IFormatProvider provider, int expected) { int result; // Default style and provider if ((style == NumberStyles.Integer) && (provider is null)) { Assert.True(ParseableHelper<int>.TryParse(value, provider, out result)); Assert.Equal(expected, result); Assert.Equal(expected, ParseableHelper<int>.Parse(value, provider)); } // Default provider if (provider is null) { Assert.Equal(expected, NumberHelper<int>.Parse(value, style, provider)); // Substitute default NumberFormatInfo Assert.True(NumberHelper<int>.TryParse(value, style, new NumberFormatInfo(), out result)); Assert.Equal(expected, result); Assert.Equal(expected, NumberHelper<int>.Parse(value, style, new NumberFormatInfo())); } // Default style if (style == NumberStyles.Integer) { Assert.Equal(expected, ParseableHelper<int>.Parse(value, provider)); } // Full overloads Assert.True(NumberHelper<int>.TryParse(value, style, provider, out result)); Assert.Equal(expected, result); Assert.Equal(expected, NumberHelper<int>.Parse(value, style, provider)); } [Theory] [MemberData(nameof(Int32Tests.Parse_Invalid_TestData), MemberType = typeof(Int32Tests))] public static void ParseInvalidStringTest(string value, NumberStyles style, IFormatProvider provider, Type exceptionType) { int result; // Default style and provider if ((style == NumberStyles.Integer) && (provider is null)) { Assert.False(ParseableHelper<int>.TryParse(value, provider, out result)); Assert.Equal(default(int), result); Assert.Throws(exceptionType, () => ParseableHelper<int>.Parse(value, provider)); } // Default provider if (provider is null) { Assert.Throws(exceptionType, () => NumberHelper<int>.Parse(value, style, provider)); // Substitute default NumberFormatInfo Assert.False(NumberHelper<int>.TryParse(value, style, new NumberFormatInfo(), out result)); Assert.Equal(default(int), result); Assert.Throws(exceptionType, () => NumberHelper<int>.Parse(value, style, new NumberFormatInfo())); } // Default style if (style == NumberStyles.Integer) { Assert.Throws(exceptionType, () => ParseableHelper<int>.Parse(value, provider)); } // Full overloads Assert.False(NumberHelper<int>.TryParse(value, style, provider, out result)); Assert.Equal(default(int), result); Assert.Throws(exceptionType, () => NumberHelper<int>.Parse(value, style, provider)); } [Theory] [MemberData(nameof(Int32Tests.Parse_ValidWithOffsetCount_TestData), MemberType = typeof(Int32Tests))] public static void ParseValidSpanTest(string value, int offset, int count, NumberStyles style, IFormatProvider provider, int expected) { int result; // Default style and provider if ((style == NumberStyles.Integer) && (provider is null)) { Assert.True(SpanParseableHelper<int>.TryParse(value.AsSpan(offset, count), provider, out result)); Assert.Equal(expected, result); } Assert.Equal(expected, NumberHelper<int>.Parse(value.AsSpan(offset, count), style, provider)); Assert.True(NumberHelper<int>.TryParse(value.AsSpan(offset, count), style, provider, out result)); Assert.Equal(expected, result); } [Theory] [MemberData(nameof(Int32Tests.Parse_Invalid_TestData), MemberType = typeof(Int32Tests))] public static void ParseInvalidSpanTest(string value, NumberStyles style, IFormatProvider provider, Type exceptionType) { if (value is null) { return; } int result; // Default style and provider if ((style == NumberStyles.Integer) && (provider is null)) { Assert.False(SpanParseableHelper<int>.TryParse(value.AsSpan(), provider, out result)); Assert.Equal(default(int), result); } Assert.Throws(exceptionType, () => NumberHelper<int>.Parse(value.AsSpan(), style, provider)); Assert.False(NumberHelper<int>.TryParse(value.AsSpan(), style, provider, out result)); Assert.Equal(default(int), result); } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/Common/src/Interop/Windows/Crypt32/Interop.PfxCertStoreFlags.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; internal static partial class Interop { internal static partial class Crypt32 { [Flags] internal enum PfxCertStoreFlags : int { CRYPT_EXPORTABLE = 0x00000001, CRYPT_USER_PROTECTED = 0x00000002, CRYPT_MACHINE_KEYSET = 0x00000020, CRYPT_USER_KEYSET = 0x00001000, PKCS12_PREFER_CNG_KSP = 0x00000100, PKCS12_ALWAYS_CNG_KSP = 0x00000200, PKCS12_ALLOW_OVERWRITE_KEY = 0x00004000, PKCS12_NO_PERSIST_KEY = 0x00008000, PKCS12_INCLUDE_EXTENDED_PROPERTIES = 0x00000010, None = 0x00000000, } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; internal static partial class Interop { internal static partial class Crypt32 { [Flags] internal enum PfxCertStoreFlags : int { CRYPT_EXPORTABLE = 0x00000001, CRYPT_USER_PROTECTED = 0x00000002, CRYPT_MACHINE_KEYSET = 0x00000020, CRYPT_USER_KEYSET = 0x00001000, PKCS12_PREFER_CNG_KSP = 0x00000100, PKCS12_ALWAYS_CNG_KSP = 0x00000200, PKCS12_ALLOW_OVERWRITE_KEY = 0x00004000, PKCS12_NO_PERSIST_KEY = 0x00008000, PKCS12_INCLUDE_EXTENDED_PROPERTIES = 0x00000010, None = 0x00000000, } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Private.CoreLib/src/System/SpanHelpers.BinarySearch.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { internal static partial class SpanHelpers { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T, TComparable>( this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T> { if (comparable == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparable); return BinarySearch(ref MemoryMarshal.GetReference(span), span.Length, comparable); } public static int BinarySearch<T, TComparable>( ref T spanStart, int length, TComparable comparable) where TComparable : IComparable<T> { int lo = 0; int hi = length - 1; // If length == 0, hi == -1, and loop will not be entered while (lo <= hi) { // PERF: `lo` or `hi` will never be negative inside the loop, // so computing median using uints is safe since we know // `length <= int.MaxValue`, and indices are >= 0 // and thus cannot overflow an uint. // Saves one subtraction per loop compared to // `int i = lo + ((hi - lo) >> 1);` int i = (int)(((uint)hi + (uint)lo) >> 1); int c = comparable.CompareTo(Unsafe.Add(ref spanStart, i)); if (c == 0) { return i; } else if (c > 0) { lo = i + 1; } else { hi = i - 1; } } // If none found, then a negative number that is the bitwise complement // of the index of the next element that is larger than or, if there is // no larger element, the bitwise complement of `length`, which // is `lo` at this point. return ~lo; } // Helper to allow sharing all code via IComparable<T> inlineable internal readonly struct ComparerComparable<T, TComparer> : IComparable<T> where TComparer : IComparer<T> { private readonly T _value; private readonly TComparer _comparer; public ComparerComparable(T value, TComparer comparer) { _value = value; _comparer = comparer; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(T? other) => _comparer.Compare(_value, other); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { internal static partial class SpanHelpers { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T, TComparable>( this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T> { if (comparable == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparable); return BinarySearch(ref MemoryMarshal.GetReference(span), span.Length, comparable); } public static int BinarySearch<T, TComparable>( ref T spanStart, int length, TComparable comparable) where TComparable : IComparable<T> { int lo = 0; int hi = length - 1; // If length == 0, hi == -1, and loop will not be entered while (lo <= hi) { // PERF: `lo` or `hi` will never be negative inside the loop, // so computing median using uints is safe since we know // `length <= int.MaxValue`, and indices are >= 0 // and thus cannot overflow an uint. // Saves one subtraction per loop compared to // `int i = lo + ((hi - lo) >> 1);` int i = (int)(((uint)hi + (uint)lo) >> 1); int c = comparable.CompareTo(Unsafe.Add(ref spanStart, i)); if (c == 0) { return i; } else if (c > 0) { lo = i + 1; } else { hi = i - 1; } } // If none found, then a negative number that is the bitwise complement // of the index of the next element that is larger than or, if there is // no larger element, the bitwise complement of `length`, which // is `lo` at this point. return ~lo; } // Helper to allow sharing all code via IComparable<T> inlineable internal readonly struct ComparerComparable<T, TComparer> : IComparable<T> where TComparer : IComparer<T> { private readonly T _value; private readonly TComparer _comparer; public ComparerComparable(T value, TComparer comparer) { _value = value; _comparer = comparer; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(T? other) => _comparer.Compare(_value, other); } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Interop/DisabledRuntimeMarshalling/PInvokeAssemblyMarshallingEnabled/Delegates.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; using Xunit; using static DisabledRuntimeMarshallingNative; namespace DisabledRuntimeMarshalling.PInvokeAssemblyMarshallingEnabled; public unsafe class DelegatesFromExternalAssembly { [Fact] public static void StructWithDefaultNonBlittableFields() { short s = 42; bool b = true; var callback = Marshal.GetDelegateForFunctionPointer<CheckStructWithShortAndBoolCallback>((IntPtr)DisabledRuntimeMarshallingNative.GetStructWithShortAndBoolCallback()); Assert.False(callback(new StructWithShortAndBool(s, b), s, b)); } [Fact] [PlatformSpecific(TestPlatforms.Windows)] public static void StructWithDefaultNonBlittableFields_MarshalAsInfo() { short s = 41; bool b = true; var callback = Marshal.GetDelegateForFunctionPointer<CheckStructWithShortAndBoolWithMarshalAsAndVariantBoolCallback>((IntPtr)DisabledRuntimeMarshallingNative.GetStructWithShortAndBoolWithVariantBoolCallback()); Assert.True(callback(new StructWithShortAndBoolWithMarshalAs(s, b), s, b)); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; using Xunit; using static DisabledRuntimeMarshallingNative; namespace DisabledRuntimeMarshalling.PInvokeAssemblyMarshallingEnabled; public unsafe class DelegatesFromExternalAssembly { [Fact] public static void StructWithDefaultNonBlittableFields() { short s = 42; bool b = true; var callback = Marshal.GetDelegateForFunctionPointer<CheckStructWithShortAndBoolCallback>((IntPtr)DisabledRuntimeMarshallingNative.GetStructWithShortAndBoolCallback()); Assert.False(callback(new StructWithShortAndBool(s, b), s, b)); } [Fact] [PlatformSpecific(TestPlatforms.Windows)] public static void StructWithDefaultNonBlittableFields_MarshalAsInfo() { short s = 41; bool b = true; var callback = Marshal.GetDelegateForFunctionPointer<CheckStructWithShortAndBoolWithMarshalAsAndVariantBoolCallback>((IntPtr)DisabledRuntimeMarshallingNative.GetStructWithShortAndBoolWithVariantBoolCallback()); Assert.True(callback(new StructWithShortAndBoolWithMarshalAs(s, b), s, b)); } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Methodical/int64/signed/s_ldsfld_mulovf_il_d.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="s_ldsfld_mulovf.il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="s_ldsfld_mulovf.il" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/CoreMangLib/system/delegate/miscellaneous/ClosedStatic.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Reflection; class Program { public int scale; public Program(int scale) { this.scale = scale; } public static decimal getfunc(Program prog,int constituent) { return new decimal(constituent/prog.scale); } static int Main(string[] args) { int result = -1; int constituent = 3; Program prog = new Program(1); 2.Equals(3); MethodInfo info = typeof(Program).GetMethod("getfunc", BindingFlags.Static | BindingFlags.Public); //Tests closed delegates over static methods with return buffer Func<int, decimal> deepThought = (Func<int, decimal>)info.CreateDelegate(typeof(Func<int, decimal>), prog); var res1 = deepThought(constituent); var res2 = deepThought(constituent); if (decimal.Compare(res1, res2) == 0) return 100; return result; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Reflection; class Program { public int scale; public Program(int scale) { this.scale = scale; } public static decimal getfunc(Program prog,int constituent) { return new decimal(constituent/prog.scale); } static int Main(string[] args) { int result = -1; int constituent = 3; Program prog = new Program(1); 2.Equals(3); MethodInfo info = typeof(Program).GetMethod("getfunc", BindingFlags.Static | BindingFlags.Public); //Tests closed delegates over static methods with return buffer Func<int, decimal> deepThought = (Func<int, decimal>)info.CreateDelegate(typeof(Func<int, decimal>), prog); var res1 = deepThought(constituent); var res2 = deepThought(constituent); if (decimal.Compare(res1, res2) == 0) return 100; return result; } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b423721/b423721.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="c1.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>False</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="c1.csproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest1314/Generated1314.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated1314.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated1314.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Net.Ping/System.Net.Ping.sln
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{37231AFF-11DE-41E7-85A7-F23D136D254E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Ping", "ref\System.Net.Ping.csproj", "{A16A6C85-DF86-44A1-9032-238C223A0AE0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Ping", "src\System.Net.Ping.csproj", "{65B08958-069E-4F8B-A996-2A987ACCAA49}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Ping.Functional.Tests", "tests\FunctionalTests\System.Net.Ping.Functional.Tests.csproj", "{E2A63467-3D66-448C-BF81-5DF684E02AD3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{26E69A05-FCF8-4D01-A93A-F97FE4B92D74}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B59DB44D-8E1E-4F62-A223-E3AC71BB0370}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FABDD2DA-5365-4FD2-8C67-4C643E618CE9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{AAB0D01D-C3A4-4E09-9BFD-CBC737A3CA73}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A687595D-ACCE-4380-95B8-628F598C7229}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{D26792B6-6D00-4CC0-B60B-7028F377BD4F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {37231AFF-11DE-41E7-85A7-F23D136D254E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {37231AFF-11DE-41E7-85A7-F23D136D254E}.Debug|Any CPU.Build.0 = Debug|Any CPU {37231AFF-11DE-41E7-85A7-F23D136D254E}.Release|Any CPU.ActiveCfg = Release|Any CPU {37231AFF-11DE-41E7-85A7-F23D136D254E}.Release|Any CPU.Build.0 = Release|Any CPU {A16A6C85-DF86-44A1-9032-238C223A0AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A16A6C85-DF86-44A1-9032-238C223A0AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {A16A6C85-DF86-44A1-9032-238C223A0AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {A16A6C85-DF86-44A1-9032-238C223A0AE0}.Release|Any CPU.Build.0 = Release|Any CPU {65B08958-069E-4F8B-A996-2A987ACCAA49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {65B08958-069E-4F8B-A996-2A987ACCAA49}.Debug|Any CPU.Build.0 = Debug|Any CPU {65B08958-069E-4F8B-A996-2A987ACCAA49}.Release|Any CPU.ActiveCfg = Release|Any CPU {65B08958-069E-4F8B-A996-2A987ACCAA49}.Release|Any CPU.Build.0 = Release|Any CPU {E2A63467-3D66-448C-BF81-5DF684E02AD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E2A63467-3D66-448C-BF81-5DF684E02AD3}.Debug|Any CPU.Build.0 = Debug|Any CPU {E2A63467-3D66-448C-BF81-5DF684E02AD3}.Release|Any CPU.ActiveCfg = Release|Any CPU {E2A63467-3D66-448C-BF81-5DF684E02AD3}.Release|Any CPU.Build.0 = Release|Any CPU {26E69A05-FCF8-4D01-A93A-F97FE4B92D74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {26E69A05-FCF8-4D01-A93A-F97FE4B92D74}.Debug|Any CPU.Build.0 = Debug|Any CPU {26E69A05-FCF8-4D01-A93A-F97FE4B92D74}.Release|Any CPU.ActiveCfg = Release|Any CPU {26E69A05-FCF8-4D01-A93A-F97FE4B92D74}.Release|Any CPU.Build.0 = Release|Any CPU {B59DB44D-8E1E-4F62-A223-E3AC71BB0370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B59DB44D-8E1E-4F62-A223-E3AC71BB0370}.Debug|Any CPU.Build.0 = Debug|Any CPU {B59DB44D-8E1E-4F62-A223-E3AC71BB0370}.Release|Any CPU.ActiveCfg = Release|Any CPU {B59DB44D-8E1E-4F62-A223-E3AC71BB0370}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {37231AFF-11DE-41E7-85A7-F23D136D254E} = {FABDD2DA-5365-4FD2-8C67-4C643E618CE9} {E2A63467-3D66-448C-BF81-5DF684E02AD3} = {FABDD2DA-5365-4FD2-8C67-4C643E618CE9} {A16A6C85-DF86-44A1-9032-238C223A0AE0} = {AAB0D01D-C3A4-4E09-9BFD-CBC737A3CA73} {65B08958-069E-4F8B-A996-2A987ACCAA49} = {A687595D-ACCE-4380-95B8-628F598C7229} {26E69A05-FCF8-4D01-A93A-F97FE4B92D74} = {D26792B6-6D00-4CC0-B60B-7028F377BD4F} {B59DB44D-8E1E-4F62-A223-E3AC71BB0370} = {D26792B6-6D00-4CC0-B60B-7028F377BD4F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {23612E2C-7AC3-4D7B-812D-44BB88E94278} EndGlobalSection EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{37231AFF-11DE-41E7-85A7-F23D136D254E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Ping", "ref\System.Net.Ping.csproj", "{A16A6C85-DF86-44A1-9032-238C223A0AE0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Ping", "src\System.Net.Ping.csproj", "{65B08958-069E-4F8B-A996-2A987ACCAA49}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Ping.Functional.Tests", "tests\FunctionalTests\System.Net.Ping.Functional.Tests.csproj", "{E2A63467-3D66-448C-BF81-5DF684E02AD3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{26E69A05-FCF8-4D01-A93A-F97FE4B92D74}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{B59DB44D-8E1E-4F62-A223-E3AC71BB0370}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FABDD2DA-5365-4FD2-8C67-4C643E618CE9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{AAB0D01D-C3A4-4E09-9BFD-CBC737A3CA73}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A687595D-ACCE-4380-95B8-628F598C7229}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{D26792B6-6D00-4CC0-B60B-7028F377BD4F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {37231AFF-11DE-41E7-85A7-F23D136D254E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {37231AFF-11DE-41E7-85A7-F23D136D254E}.Debug|Any CPU.Build.0 = Debug|Any CPU {37231AFF-11DE-41E7-85A7-F23D136D254E}.Release|Any CPU.ActiveCfg = Release|Any CPU {37231AFF-11DE-41E7-85A7-F23D136D254E}.Release|Any CPU.Build.0 = Release|Any CPU {A16A6C85-DF86-44A1-9032-238C223A0AE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A16A6C85-DF86-44A1-9032-238C223A0AE0}.Debug|Any CPU.Build.0 = Debug|Any CPU {A16A6C85-DF86-44A1-9032-238C223A0AE0}.Release|Any CPU.ActiveCfg = Release|Any CPU {A16A6C85-DF86-44A1-9032-238C223A0AE0}.Release|Any CPU.Build.0 = Release|Any CPU {65B08958-069E-4F8B-A996-2A987ACCAA49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {65B08958-069E-4F8B-A996-2A987ACCAA49}.Debug|Any CPU.Build.0 = Debug|Any CPU {65B08958-069E-4F8B-A996-2A987ACCAA49}.Release|Any CPU.ActiveCfg = Release|Any CPU {65B08958-069E-4F8B-A996-2A987ACCAA49}.Release|Any CPU.Build.0 = Release|Any CPU {E2A63467-3D66-448C-BF81-5DF684E02AD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E2A63467-3D66-448C-BF81-5DF684E02AD3}.Debug|Any CPU.Build.0 = Debug|Any CPU {E2A63467-3D66-448C-BF81-5DF684E02AD3}.Release|Any CPU.ActiveCfg = Release|Any CPU {E2A63467-3D66-448C-BF81-5DF684E02AD3}.Release|Any CPU.Build.0 = Release|Any CPU {26E69A05-FCF8-4D01-A93A-F97FE4B92D74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {26E69A05-FCF8-4D01-A93A-F97FE4B92D74}.Debug|Any CPU.Build.0 = Debug|Any CPU {26E69A05-FCF8-4D01-A93A-F97FE4B92D74}.Release|Any CPU.ActiveCfg = Release|Any CPU {26E69A05-FCF8-4D01-A93A-F97FE4B92D74}.Release|Any CPU.Build.0 = Release|Any CPU {B59DB44D-8E1E-4F62-A223-E3AC71BB0370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B59DB44D-8E1E-4F62-A223-E3AC71BB0370}.Debug|Any CPU.Build.0 = Debug|Any CPU {B59DB44D-8E1E-4F62-A223-E3AC71BB0370}.Release|Any CPU.ActiveCfg = Release|Any CPU {B59DB44D-8E1E-4F62-A223-E3AC71BB0370}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {37231AFF-11DE-41E7-85A7-F23D136D254E} = {FABDD2DA-5365-4FD2-8C67-4C643E618CE9} {E2A63467-3D66-448C-BF81-5DF684E02AD3} = {FABDD2DA-5365-4FD2-8C67-4C643E618CE9} {A16A6C85-DF86-44A1-9032-238C223A0AE0} = {AAB0D01D-C3A4-4E09-9BFD-CBC737A3CA73} {65B08958-069E-4F8B-A996-2A987ACCAA49} = {A687595D-ACCE-4380-95B8-628F598C7229} {26E69A05-FCF8-4D01-A93A-F97FE4B92D74} = {D26792B6-6D00-4CC0-B60B-7028F377BD4F} {B59DB44D-8E1E-4F62-A223-E3AC71BB0370} = {D26792B6-6D00-4CC0-B60B-7028F377BD4F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {23612E2C-7AC3-4D7B-812D-44BB88E94278} EndGlobalSection EndGlobal
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.ComponentModel.Primitives/src/System/ComponentModel/CategoryAttribute.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; namespace System.ComponentModel { /// <summary> /// Specifies the category in which the property or event will be displayed in a /// visual designer. /// </summary> [AttributeUsage(AttributeTargets.All)] public class CategoryAttribute : Attribute { private static volatile CategoryAttribute? s_action; private static volatile CategoryAttribute? s_appearance; private static volatile CategoryAttribute? s_asynchronous; private static volatile CategoryAttribute? s_behavior; private static volatile CategoryAttribute? s_data; private static volatile CategoryAttribute? s_design; private static volatile CategoryAttribute? s_dragDrop; private static volatile CategoryAttribute? s_defAttr; private static volatile CategoryAttribute? s_focus; private static volatile CategoryAttribute? s_format; private static volatile CategoryAttribute? s_key; private static volatile CategoryAttribute? s_layout; private static volatile CategoryAttribute? s_mouse; private static volatile CategoryAttribute? s_windowStyle; private bool _localized; private readonly object _locker = new object(); /// <summary> /// Provides the actual category name. /// </summary> private string _categoryValue; /// <summary> /// Gets the action category attribute. /// </summary> public static CategoryAttribute Action { get => s_action ?? (s_action = new CategoryAttribute(nameof(Action))); } /// <summary> /// Gets the appearance category attribute. /// </summary> public static CategoryAttribute Appearance { get => s_appearance ?? (s_appearance = new CategoryAttribute(nameof(Appearance))); } /// <summary> /// Gets the asynchronous category attribute. /// </summary> public static CategoryAttribute Asynchronous { get => s_asynchronous ?? (s_asynchronous = new CategoryAttribute(nameof(Asynchronous))); } /// <summary> /// Gets the behavior category attribute. /// </summary> public static CategoryAttribute Behavior { get => s_behavior ?? (s_behavior = new CategoryAttribute(nameof(Behavior))); } /// <summary> /// Gets the data category attribute. /// </summary> public static CategoryAttribute Data { get => s_data ?? (s_data = new CategoryAttribute(nameof(Data))); } /// <summary> /// Gets the default category attribute. /// </summary> public static CategoryAttribute Default { get => s_defAttr ?? (s_defAttr = new CategoryAttribute()); } /// <summary> /// Gets the design category attribute. /// </summary> public static CategoryAttribute Design { get => s_design ?? (s_design = new CategoryAttribute(nameof(Design))); } /// <summary> /// Gets the drag and drop category attribute. /// </summary> public static CategoryAttribute DragDrop { get => s_dragDrop ?? (s_dragDrop = new CategoryAttribute(nameof(DragDrop))); } /// <summary> /// Gets the focus category attribute. /// </summary> public static CategoryAttribute Focus { get => s_focus ?? (s_focus = new CategoryAttribute(nameof(Focus))); } /// <summary> /// Gets the format category attribute. /// </summary> public static CategoryAttribute Format { get => s_format ?? (s_format = new CategoryAttribute(nameof(Format))); } /// <summary> /// Gets the keyboard category attribute. /// </summary> public static CategoryAttribute Key { get => s_key ?? (s_key = new CategoryAttribute(nameof(Key))); } /// <summary> /// Gets the layout category attribute. /// </summary> public static CategoryAttribute Layout { get => s_layout ?? (s_layout = new CategoryAttribute(nameof(Layout))); } /// <summary> /// Gets the mouse category attribute. /// </summary> public static CategoryAttribute Mouse { get => s_mouse ?? (s_mouse = new CategoryAttribute(nameof(Mouse))); } /// <summary> /// Gets the window style category attribute. /// </summary> public static CategoryAttribute WindowStyle { get => s_windowStyle ?? (s_windowStyle = new CategoryAttribute(nameof(WindowStyle))); } /// <summary> /// Initializes a new instance of the <see cref='System.ComponentModel.CategoryAttribute'/> /// class with the default category. /// </summary> public CategoryAttribute() : this(nameof(Default)) { } /// <summary> /// Initializes a new instance of the <see cref='System.ComponentModel.CategoryAttribute'/> /// class with the specified category name. /// </summary> public CategoryAttribute(string category) { _categoryValue = category; } /// <summary> /// Gets the name of the category for the property or event that this attribute is /// bound to. /// </summary> public string Category { get { if (!_localized) { lock (_locker) { string? localizedValue = GetLocalizedString(_categoryValue); if (localizedValue != null) { _categoryValue = localizedValue; } _localized = true; } } return _categoryValue; } } public override bool Equals([NotNullWhen(true)] object? obj) => obj is CategoryAttribute other && other.Category == Category; public override int GetHashCode() => Category?.GetHashCode() ?? 0; /// <summary> /// Looks up the localized name of a given category. /// </summary> protected virtual string? GetLocalizedString(string value) => value switch { "Action" => SR.PropertyCategoryAction, "Appearance" => SR.PropertyCategoryAppearance, "Asynchronous" => SR.PropertyCategoryAsynchronous, "Behavior" => SR.PropertyCategoryBehavior, "Config" => SR.PropertyCategoryConfig, "Data" => SR.PropertyCategoryData, "DDE" => SR.PropertyCategoryDDE, "Default" => SR.PropertyCategoryDefault, "Design" => SR.PropertyCategoryDesign, "DragDrop" => SR.PropertyCategoryDragDrop, "Focus" => SR.PropertyCategoryFocus, "Font" => SR.PropertyCategoryFont, "Format" => SR.PropertyCategoryFormat, "Key" => SR.PropertyCategoryKey, "Layout" => SR.PropertyCategoryLayout, "List" => SR.PropertyCategoryList, "Mouse" => SR.PropertyCategoryMouse, "Position" => SR.PropertyCategoryPosition, "Scale" => SR.PropertyCategoryScale, "Text" => SR.PropertyCategoryText, "WindowStyle" => SR.PropertyCategoryWindowStyle, _ => null }; public override bool IsDefaultAttribute() => Category == Default.Category; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; namespace System.ComponentModel { /// <summary> /// Specifies the category in which the property or event will be displayed in a /// visual designer. /// </summary> [AttributeUsage(AttributeTargets.All)] public class CategoryAttribute : Attribute { private static volatile CategoryAttribute? s_action; private static volatile CategoryAttribute? s_appearance; private static volatile CategoryAttribute? s_asynchronous; private static volatile CategoryAttribute? s_behavior; private static volatile CategoryAttribute? s_data; private static volatile CategoryAttribute? s_design; private static volatile CategoryAttribute? s_dragDrop; private static volatile CategoryAttribute? s_defAttr; private static volatile CategoryAttribute? s_focus; private static volatile CategoryAttribute? s_format; private static volatile CategoryAttribute? s_key; private static volatile CategoryAttribute? s_layout; private static volatile CategoryAttribute? s_mouse; private static volatile CategoryAttribute? s_windowStyle; private bool _localized; private readonly object _locker = new object(); /// <summary> /// Provides the actual category name. /// </summary> private string _categoryValue; /// <summary> /// Gets the action category attribute. /// </summary> public static CategoryAttribute Action { get => s_action ?? (s_action = new CategoryAttribute(nameof(Action))); } /// <summary> /// Gets the appearance category attribute. /// </summary> public static CategoryAttribute Appearance { get => s_appearance ?? (s_appearance = new CategoryAttribute(nameof(Appearance))); } /// <summary> /// Gets the asynchronous category attribute. /// </summary> public static CategoryAttribute Asynchronous { get => s_asynchronous ?? (s_asynchronous = new CategoryAttribute(nameof(Asynchronous))); } /// <summary> /// Gets the behavior category attribute. /// </summary> public static CategoryAttribute Behavior { get => s_behavior ?? (s_behavior = new CategoryAttribute(nameof(Behavior))); } /// <summary> /// Gets the data category attribute. /// </summary> public static CategoryAttribute Data { get => s_data ?? (s_data = new CategoryAttribute(nameof(Data))); } /// <summary> /// Gets the default category attribute. /// </summary> public static CategoryAttribute Default { get => s_defAttr ?? (s_defAttr = new CategoryAttribute()); } /// <summary> /// Gets the design category attribute. /// </summary> public static CategoryAttribute Design { get => s_design ?? (s_design = new CategoryAttribute(nameof(Design))); } /// <summary> /// Gets the drag and drop category attribute. /// </summary> public static CategoryAttribute DragDrop { get => s_dragDrop ?? (s_dragDrop = new CategoryAttribute(nameof(DragDrop))); } /// <summary> /// Gets the focus category attribute. /// </summary> public static CategoryAttribute Focus { get => s_focus ?? (s_focus = new CategoryAttribute(nameof(Focus))); } /// <summary> /// Gets the format category attribute. /// </summary> public static CategoryAttribute Format { get => s_format ?? (s_format = new CategoryAttribute(nameof(Format))); } /// <summary> /// Gets the keyboard category attribute. /// </summary> public static CategoryAttribute Key { get => s_key ?? (s_key = new CategoryAttribute(nameof(Key))); } /// <summary> /// Gets the layout category attribute. /// </summary> public static CategoryAttribute Layout { get => s_layout ?? (s_layout = new CategoryAttribute(nameof(Layout))); } /// <summary> /// Gets the mouse category attribute. /// </summary> public static CategoryAttribute Mouse { get => s_mouse ?? (s_mouse = new CategoryAttribute(nameof(Mouse))); } /// <summary> /// Gets the window style category attribute. /// </summary> public static CategoryAttribute WindowStyle { get => s_windowStyle ?? (s_windowStyle = new CategoryAttribute(nameof(WindowStyle))); } /// <summary> /// Initializes a new instance of the <see cref='System.ComponentModel.CategoryAttribute'/> /// class with the default category. /// </summary> public CategoryAttribute() : this(nameof(Default)) { } /// <summary> /// Initializes a new instance of the <see cref='System.ComponentModel.CategoryAttribute'/> /// class with the specified category name. /// </summary> public CategoryAttribute(string category) { _categoryValue = category; } /// <summary> /// Gets the name of the category for the property or event that this attribute is /// bound to. /// </summary> public string Category { get { if (!_localized) { lock (_locker) { string? localizedValue = GetLocalizedString(_categoryValue); if (localizedValue != null) { _categoryValue = localizedValue; } _localized = true; } } return _categoryValue; } } public override bool Equals([NotNullWhen(true)] object? obj) => obj is CategoryAttribute other && other.Category == Category; public override int GetHashCode() => Category?.GetHashCode() ?? 0; /// <summary> /// Looks up the localized name of a given category. /// </summary> protected virtual string? GetLocalizedString(string value) => value switch { "Action" => SR.PropertyCategoryAction, "Appearance" => SR.PropertyCategoryAppearance, "Asynchronous" => SR.PropertyCategoryAsynchronous, "Behavior" => SR.PropertyCategoryBehavior, "Config" => SR.PropertyCategoryConfig, "Data" => SR.PropertyCategoryData, "DDE" => SR.PropertyCategoryDDE, "Default" => SR.PropertyCategoryDefault, "Design" => SR.PropertyCategoryDesign, "DragDrop" => SR.PropertyCategoryDragDrop, "Focus" => SR.PropertyCategoryFocus, "Font" => SR.PropertyCategoryFont, "Format" => SR.PropertyCategoryFormat, "Key" => SR.PropertyCategoryKey, "Layout" => SR.PropertyCategoryLayout, "List" => SR.PropertyCategoryList, "Mouse" => SR.PropertyCategoryMouse, "Position" => SR.PropertyCategoryPosition, "Scale" => SR.PropertyCategoryScale, "Text" => SR.PropertyCategoryText, "WindowStyle" => SR.PropertyCategoryWindowStyle, _ => null }; public override bool IsDefaultAttribute() => Category == Default.Category; } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/coreclr/tools/Common/TypeSystem/Ecma/EcmaType.Sorting.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Reflection.Metadata.Ecma335; namespace Internal.TypeSystem.Ecma { // Functionality related to determinstic ordering of types partial class EcmaType { protected internal override int ClassCode => 1340416537; protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { // Sort by module in preference to by token. This will place types from the same module near each other // even when working with several modules. var otherType = (EcmaType)other; int result = _module.CompareTo(otherType._module); if (result != 0) return result; return _module.MetadataReader.GetToken(_handle) - otherType._module.MetadataReader.GetToken(otherType._handle); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Reflection.Metadata.Ecma335; namespace Internal.TypeSystem.Ecma { // Functionality related to determinstic ordering of types partial class EcmaType { protected internal override int ClassCode => 1340416537; protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer) { // Sort by module in preference to by token. This will place types from the same module near each other // even when working with several modules. var otherType = (EcmaType)other; int result = _module.CompareTo(otherType._module); if (result != 0) return result; return _module.MetadataReader.GetToken(_handle) - otherType._module.MetadataReader.GetToken(otherType._handle); } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Math/Functions/Double/SinDouble.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace System.MathBenchmarks { public partial class Double { // Tests Math.Sin(double) over 5000 iterations for the domain -PI/2, +PI/2 private const double sinDelta = 0.0006283185307180; private const double sinExpectedResult = 1.0000000005445053; public void Sin() => SinTest(); public static void SinTest() { double result = 0.0, value = -1.5707963267948966; for (int iteration = 0; iteration < MathTests.Iterations; iteration++) { value += sinDelta; result += Math.Sin(value); } double diff = Math.Abs(sinExpectedResult - result); if (diff > MathTests.DoubleEpsilon) { throw new Exception($"Expected Result {sinExpectedResult,20:g17}; Actual Result {result,20:g17}"); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace System.MathBenchmarks { public partial class Double { // Tests Math.Sin(double) over 5000 iterations for the domain -PI/2, +PI/2 private const double sinDelta = 0.0006283185307180; private const double sinExpectedResult = 1.0000000005445053; public void Sin() => SinTest(); public static void SinTest() { double result = 0.0, value = -1.5707963267948966; for (int iteration = 0; iteration < MathTests.Iterations; iteration++) { value += sinDelta; result += Math.Sin(value); } double diff = Math.Abs(sinExpectedResult - result); if (diff > MathTests.DoubleEpsilon) { throw new Exception($"Expected Result {sinExpectedResult,20:g17}; Actual Result {result,20:g17}"); } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/Common/src/Interop/Unix/Interop.Errors.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { /// <summary>Common Unix errno error codes.</summary> internal enum Error { // These values were defined in src/Native/System.Native/fxerrno.h // // They compare against values obtained via Interop.Sys.GetLastError() not Marshal.GetLastWin32Error() // which obtains the raw errno that varies between unixes. The strong typing as an enum is meant to // prevent confusing the two. Casting to or from int is suspect. Use GetLastErrorInfo() if you need to // correlate these to the underlying platform values or obtain the corresponding error message. // SUCCESS = 0, E2BIG = 0x10001, // Argument list too long. EACCES = 0x10002, // Permission denied. EADDRINUSE = 0x10003, // Address in use. EADDRNOTAVAIL = 0x10004, // Address not available. EAFNOSUPPORT = 0x10005, // Address family not supported. EAGAIN = 0x10006, // Resource unavailable, try again (same value as EWOULDBLOCK), EALREADY = 0x10007, // Connection already in progress. EBADF = 0x10008, // Bad file descriptor. EBADMSG = 0x10009, // Bad message. EBUSY = 0x1000A, // Device or resource busy. ECANCELED = 0x1000B, // Operation canceled. ECHILD = 0x1000C, // No child processes. ECONNABORTED = 0x1000D, // Connection aborted. ECONNREFUSED = 0x1000E, // Connection refused. ECONNRESET = 0x1000F, // Connection reset. EDEADLK = 0x10010, // Resource deadlock would occur. EDESTADDRREQ = 0x10011, // Destination address required. EDOM = 0x10012, // Mathematics argument out of domain of function. EDQUOT = 0x10013, // Reserved. EEXIST = 0x10014, // File exists. EFAULT = 0x10015, // Bad address. EFBIG = 0x10016, // File too large. EHOSTUNREACH = 0x10017, // Host is unreachable. EIDRM = 0x10018, // Identifier removed. EILSEQ = 0x10019, // Illegal byte sequence. EINPROGRESS = 0x1001A, // Operation in progress. EINTR = 0x1001B, // Interrupted function. EINVAL = 0x1001C, // Invalid argument. EIO = 0x1001D, // I/O error. EISCONN = 0x1001E, // Socket is connected. EISDIR = 0x1001F, // Is a directory. ELOOP = 0x10020, // Too many levels of symbolic links. EMFILE = 0x10021, // File descriptor value too large. EMLINK = 0x10022, // Too many links. EMSGSIZE = 0x10023, // Message too large. EMULTIHOP = 0x10024, // Reserved. ENAMETOOLONG = 0x10025, // Filename too long. ENETDOWN = 0x10026, // Network is down. ENETRESET = 0x10027, // Connection aborted by network. ENETUNREACH = 0x10028, // Network unreachable. ENFILE = 0x10029, // Too many files open in system. ENOBUFS = 0x1002A, // No buffer space available. ENODEV = 0x1002C, // No such device. ENOENT = 0x1002D, // No such file or directory. ENOEXEC = 0x1002E, // Executable file format error. ENOLCK = 0x1002F, // No locks available. ENOLINK = 0x10030, // Reserved. ENOMEM = 0x10031, // Not enough space. ENOMSG = 0x10032, // No message of the desired type. ENOPROTOOPT = 0x10033, // Protocol not available. ENOSPC = 0x10034, // No space left on device. ENOSYS = 0x10037, // Function not supported. ENOTCONN = 0x10038, // The socket is not connected. ENOTDIR = 0x10039, // Not a directory or a symbolic link to a directory. ENOTEMPTY = 0x1003A, // Directory not empty. ENOTRECOVERABLE = 0x1003B, // State not recoverable. ENOTSOCK = 0x1003C, // Not a socket. ENOTSUP = 0x1003D, // Not supported (same value as EOPNOTSUP). ENOTTY = 0x1003E, // Inappropriate I/O control operation. ENXIO = 0x1003F, // No such device or address. EOVERFLOW = 0x10040, // Value too large to be stored in data type. EOWNERDEAD = 0x10041, // Previous owner died. EPERM = 0x10042, // Operation not permitted. EPIPE = 0x10043, // Broken pipe. EPROTO = 0x10044, // Protocol error. EPROTONOSUPPORT = 0x10045, // Protocol not supported. EPROTOTYPE = 0x10046, // Protocol wrong type for socket. ERANGE = 0x10047, // Result too large. EROFS = 0x10048, // Read-only file system. ESPIPE = 0x10049, // Invalid seek. ESRCH = 0x1004A, // No such process. ESTALE = 0x1004B, // Reserved. ETIMEDOUT = 0x1004D, // Connection timed out. ETXTBSY = 0x1004E, // Text file busy. EXDEV = 0x1004F, // Cross-device link. ESOCKTNOSUPPORT = 0x1005E, // Socket type not supported. EPFNOSUPPORT = 0x10060, // Protocol family not supported. ESHUTDOWN = 0x1006C, // Socket shutdown. EHOSTDOWN = 0x10070, // Host is down. ENODATA = 0x10071, // No data available. // Custom Error codes to track errors beyond kernel interface. EHOSTNOTFOUND = 0x20001, // Name lookup failed ESOCKETERROR = 0x20002, // Unspecified socket error // POSIX permits these to have the same value and we make them always equal so // that we do not introduce a dependency on distinguishing between them that // would not work on all platforms. EOPNOTSUPP = ENOTSUP, // Operation not supported on socket. EWOULDBLOCK = EAGAIN, // Operation would block. } // Represents a platform-agnostic Error and underlying platform-specific errno internal struct ErrorInfo { private readonly Error _error; private int _rawErrno; internal ErrorInfo(int errno) { _error = Interop.Sys.ConvertErrorPlatformToPal(errno); _rawErrno = errno; } internal ErrorInfo(Error error) { _error = error; _rawErrno = -1; } internal Error Error { get { return _error; } } internal int RawErrno { get { return _rawErrno == -1 ? (_rawErrno = Interop.Sys.ConvertErrorPalToPlatform(_error)) : _rawErrno; } } internal string GetErrorMessage() { return Interop.Sys.StrError(RawErrno); } public override string ToString() { return $"RawErrno: {RawErrno} Error: {Error} GetErrorMessage: {GetErrorMessage()}"; // No localization required; text is member names used for debugging purposes } } internal static partial class Sys { internal static Error GetLastError() { return ConvertErrorPlatformToPal(Marshal.GetLastWin32Error()); } internal static ErrorInfo GetLastErrorInfo() { return new ErrorInfo(Marshal.GetLastWin32Error()); } internal static unsafe string StrError(int platformErrno) { int maxBufferLength = 1024; // should be long enough for most any UNIX error byte* buffer = stackalloc byte[maxBufferLength]; byte* message = StrErrorR(platformErrno, buffer, maxBufferLength); if (message == null) { // This means the buffer was not large enough, but still contains // as much of the error message as possible and is guaranteed to // be null-terminated. We're not currently resizing/retrying because // maxBufferLength is large enough in practice, but we could do // so here in the future if necessary. message = buffer; } return Marshal.PtrToStringAnsi((IntPtr)message)!; } #if SERIAL_PORTS [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal")] internal static partial Error ConvertErrorPlatformToPal(int platformErrno); [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform")] internal static partial int ConvertErrorPalToPlatform(Error error); [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_StrErrorR")] private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #else [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")] [SuppressGCTransition] internal static partial Error ConvertErrorPlatformToPal(int platformErrno); [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPalToPlatform")] [SuppressGCTransition] internal static partial int ConvertErrorPalToPlatform(Error error); [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_StrErrorR")] private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #endif } } // NOTE: extension method can't be nested inside Interop class. internal static class InteropErrorExtensions { // Intended usage is e.g. Interop.Error.EFAIL.Info() for brevity // vs. new Interop.ErrorInfo(Interop.Error.EFAIL) for synthesizing // errors. Errors originated from the system should be obtained // via GetLastErrorInfo(), not GetLastError().Info() as that will // convert twice, which is not only inefficient but also lossy if // we ever encounter a raw errno that no equivalent in the Error // enum. public static Interop.ErrorInfo Info(this Interop.Error error) { return new Interop.ErrorInfo(error); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Runtime.InteropServices; internal static partial class Interop { /// <summary>Common Unix errno error codes.</summary> internal enum Error { // These values were defined in src/Native/System.Native/fxerrno.h // // They compare against values obtained via Interop.Sys.GetLastError() not Marshal.GetLastWin32Error() // which obtains the raw errno that varies between unixes. The strong typing as an enum is meant to // prevent confusing the two. Casting to or from int is suspect. Use GetLastErrorInfo() if you need to // correlate these to the underlying platform values or obtain the corresponding error message. // SUCCESS = 0, E2BIG = 0x10001, // Argument list too long. EACCES = 0x10002, // Permission denied. EADDRINUSE = 0x10003, // Address in use. EADDRNOTAVAIL = 0x10004, // Address not available. EAFNOSUPPORT = 0x10005, // Address family not supported. EAGAIN = 0x10006, // Resource unavailable, try again (same value as EWOULDBLOCK), EALREADY = 0x10007, // Connection already in progress. EBADF = 0x10008, // Bad file descriptor. EBADMSG = 0x10009, // Bad message. EBUSY = 0x1000A, // Device or resource busy. ECANCELED = 0x1000B, // Operation canceled. ECHILD = 0x1000C, // No child processes. ECONNABORTED = 0x1000D, // Connection aborted. ECONNREFUSED = 0x1000E, // Connection refused. ECONNRESET = 0x1000F, // Connection reset. EDEADLK = 0x10010, // Resource deadlock would occur. EDESTADDRREQ = 0x10011, // Destination address required. EDOM = 0x10012, // Mathematics argument out of domain of function. EDQUOT = 0x10013, // Reserved. EEXIST = 0x10014, // File exists. EFAULT = 0x10015, // Bad address. EFBIG = 0x10016, // File too large. EHOSTUNREACH = 0x10017, // Host is unreachable. EIDRM = 0x10018, // Identifier removed. EILSEQ = 0x10019, // Illegal byte sequence. EINPROGRESS = 0x1001A, // Operation in progress. EINTR = 0x1001B, // Interrupted function. EINVAL = 0x1001C, // Invalid argument. EIO = 0x1001D, // I/O error. EISCONN = 0x1001E, // Socket is connected. EISDIR = 0x1001F, // Is a directory. ELOOP = 0x10020, // Too many levels of symbolic links. EMFILE = 0x10021, // File descriptor value too large. EMLINK = 0x10022, // Too many links. EMSGSIZE = 0x10023, // Message too large. EMULTIHOP = 0x10024, // Reserved. ENAMETOOLONG = 0x10025, // Filename too long. ENETDOWN = 0x10026, // Network is down. ENETRESET = 0x10027, // Connection aborted by network. ENETUNREACH = 0x10028, // Network unreachable. ENFILE = 0x10029, // Too many files open in system. ENOBUFS = 0x1002A, // No buffer space available. ENODEV = 0x1002C, // No such device. ENOENT = 0x1002D, // No such file or directory. ENOEXEC = 0x1002E, // Executable file format error. ENOLCK = 0x1002F, // No locks available. ENOLINK = 0x10030, // Reserved. ENOMEM = 0x10031, // Not enough space. ENOMSG = 0x10032, // No message of the desired type. ENOPROTOOPT = 0x10033, // Protocol not available. ENOSPC = 0x10034, // No space left on device. ENOSYS = 0x10037, // Function not supported. ENOTCONN = 0x10038, // The socket is not connected. ENOTDIR = 0x10039, // Not a directory or a symbolic link to a directory. ENOTEMPTY = 0x1003A, // Directory not empty. ENOTRECOVERABLE = 0x1003B, // State not recoverable. ENOTSOCK = 0x1003C, // Not a socket. ENOTSUP = 0x1003D, // Not supported (same value as EOPNOTSUP). ENOTTY = 0x1003E, // Inappropriate I/O control operation. ENXIO = 0x1003F, // No such device or address. EOVERFLOW = 0x10040, // Value too large to be stored in data type. EOWNERDEAD = 0x10041, // Previous owner died. EPERM = 0x10042, // Operation not permitted. EPIPE = 0x10043, // Broken pipe. EPROTO = 0x10044, // Protocol error. EPROTONOSUPPORT = 0x10045, // Protocol not supported. EPROTOTYPE = 0x10046, // Protocol wrong type for socket. ERANGE = 0x10047, // Result too large. EROFS = 0x10048, // Read-only file system. ESPIPE = 0x10049, // Invalid seek. ESRCH = 0x1004A, // No such process. ESTALE = 0x1004B, // Reserved. ETIMEDOUT = 0x1004D, // Connection timed out. ETXTBSY = 0x1004E, // Text file busy. EXDEV = 0x1004F, // Cross-device link. ESOCKTNOSUPPORT = 0x1005E, // Socket type not supported. EPFNOSUPPORT = 0x10060, // Protocol family not supported. ESHUTDOWN = 0x1006C, // Socket shutdown. EHOSTDOWN = 0x10070, // Host is down. ENODATA = 0x10071, // No data available. // Custom Error codes to track errors beyond kernel interface. EHOSTNOTFOUND = 0x20001, // Name lookup failed ESOCKETERROR = 0x20002, // Unspecified socket error // POSIX permits these to have the same value and we make them always equal so // that we do not introduce a dependency on distinguishing between them that // would not work on all platforms. EOPNOTSUPP = ENOTSUP, // Operation not supported on socket. EWOULDBLOCK = EAGAIN, // Operation would block. } // Represents a platform-agnostic Error and underlying platform-specific errno internal struct ErrorInfo { private readonly Error _error; private int _rawErrno; internal ErrorInfo(int errno) { _error = Interop.Sys.ConvertErrorPlatformToPal(errno); _rawErrno = errno; } internal ErrorInfo(Error error) { _error = error; _rawErrno = -1; } internal Error Error { get { return _error; } } internal int RawErrno { get { return _rawErrno == -1 ? (_rawErrno = Interop.Sys.ConvertErrorPalToPlatform(_error)) : _rawErrno; } } internal string GetErrorMessage() { return Interop.Sys.StrError(RawErrno); } public override string ToString() { return $"RawErrno: {RawErrno} Error: {Error} GetErrorMessage: {GetErrorMessage()}"; // No localization required; text is member names used for debugging purposes } } internal static partial class Sys { internal static Error GetLastError() { return ConvertErrorPlatformToPal(Marshal.GetLastWin32Error()); } internal static ErrorInfo GetLastErrorInfo() { return new ErrorInfo(Marshal.GetLastWin32Error()); } internal static unsafe string StrError(int platformErrno) { int maxBufferLength = 1024; // should be long enough for most any UNIX error byte* buffer = stackalloc byte[maxBufferLength]; byte* message = StrErrorR(platformErrno, buffer, maxBufferLength); if (message == null) { // This means the buffer was not large enough, but still contains // as much of the error message as possible and is guaranteed to // be null-terminated. We're not currently resizing/retrying because // maxBufferLength is large enough in practice, but we could do // so here in the future if necessary. message = buffer; } return Marshal.PtrToStringAnsi((IntPtr)message)!; } #if SERIAL_PORTS [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal")] internal static partial Error ConvertErrorPlatformToPal(int platformErrno); [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform")] internal static partial int ConvertErrorPalToPlatform(Error error); [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_StrErrorR")] private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #else [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")] [SuppressGCTransition] internal static partial Error ConvertErrorPlatformToPal(int platformErrno); [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPalToPlatform")] [SuppressGCTransition] internal static partial int ConvertErrorPalToPlatform(Error error); [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_StrErrorR")] private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #endif } } // NOTE: extension method can't be nested inside Interop class. internal static class InteropErrorExtensions { // Intended usage is e.g. Interop.Error.EFAIL.Info() for brevity // vs. new Interop.ErrorInfo(Interop.Error.EFAIL) for synthesizing // errors. Errors originated from the system should be obtained // via GetLastErrorInfo(), not GetLastError().Info() as that will // convert twice, which is not only inefficient but also lossy if // we ever encounter a raw errno that no equivalent in the Error // enum. public static Interop.ErrorInfo Info(this Interop.Error error) { return new Interop.ErrorInfo(error); } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/InstructionList.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Enables instruction counting and displaying stats at process exit. // #define STATS using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Dynamic.Utils; namespace System.Linq.Expressions.Interpreter { [DebuggerTypeProxy(typeof(InstructionArray.DebugView))] internal readonly struct InstructionArray { internal readonly int MaxStackDepth; internal readonly int MaxContinuationDepth; internal readonly Instruction[] Instructions; internal readonly object[]? Objects; internal readonly RuntimeLabel[] Labels; // list of (instruction index, cookie) sorted by instruction index: internal readonly List<KeyValuePair<int, object?>>? DebugCookies; internal InstructionArray(int maxStackDepth, int maxContinuationDepth, Instruction[] instructions, object[]? objects, RuntimeLabel[] labels, List<KeyValuePair<int, object?>>? debugCookies) { MaxStackDepth = maxStackDepth; MaxContinuationDepth = maxContinuationDepth; Instructions = instructions; DebugCookies = debugCookies; Objects = objects; Labels = labels; } #region Debug View internal sealed class DebugView { private readonly InstructionArray _array; public DebugView(InstructionArray array) { ContractUtils.RequiresNotNull(array, nameof(array)); _array = array; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public InstructionList.DebugView.InstructionView[]/*!*/ A0 => GetInstructionViews(includeDebugCookies: true); public InstructionList.DebugView.InstructionView[] GetInstructionViews(bool includeDebugCookies = false) { return InstructionList.DebugView.GetInstructionViews( _array.Instructions, _array.Objects, (index) => _array.Labels[index].Index, includeDebugCookies ? _array.DebugCookies : null ); } } #endregion } [DebuggerTypeProxy(typeof(InstructionList.DebugView))] internal sealed class InstructionList { private readonly List<Instruction> _instructions = new List<Instruction>(); private List<object>? _objects; private int _currentStackDepth; private int _maxStackDepth; private int _currentContinuationsDepth; private int _maxContinuationDepth; private int _runtimeLabelCount; private List<BranchLabel>? _labels; #if DEBUG // list of (instruction index, cookie) sorted by instruction index: private List<KeyValuePair<int, object?>>? _debugCookies; #endif #region Debug View internal sealed class DebugView { private readonly InstructionList _list; public DebugView(InstructionList list) { ContractUtils.RequiresNotNull(list, nameof(list)); _list = list; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public InstructionView[]/*!*/ A0 => GetInstructionViews(includeDebugCookies: true); public InstructionView[] GetInstructionViews(bool includeDebugCookies = false) { return GetInstructionViews( _list._instructions, _list._objects, (index) => _list._labels![index].TargetIndex, #if DEBUG includeDebugCookies ? _list._debugCookies : #endif null ); } internal static InstructionView[] GetInstructionViews(IReadOnlyList<Instruction> instructions, IReadOnlyList<object>? objects, Func<int, int> labelIndexer, IReadOnlyList<KeyValuePair<int, object?>>? debugCookies) { var result = new List<InstructionView>(); int index = 0; int stackDepth = 0; int continuationsDepth = 0; IEnumerator<KeyValuePair<int, object?>> cookieEnumerator = (debugCookies ?? Array.Empty<KeyValuePair<int, object?>>()).GetEnumerator(); bool hasCookie = cookieEnumerator.MoveNext(); for (int i = 0, n = instructions.Count; i < n; i++) { Instruction instruction = instructions[i]; object? cookie = null; while (hasCookie && cookieEnumerator.Current.Key == i) { cookie = cookieEnumerator.Current.Value; hasCookie = cookieEnumerator.MoveNext(); } int stackDiff = instruction.StackBalance; int contDiff = instruction.ContinuationsBalance; string name = instruction.ToDebugString(i, cookie, labelIndexer, objects); result.Add(new InstructionView(instruction, name, i, stackDepth, continuationsDepth)); index++; stackDepth += stackDiff; continuationsDepth += contDiff; } return result.ToArray(); } [DebuggerDisplay("{GetValue(),nq}", Name = "{GetName(),nq}", Type = "{GetDisplayType(), nq}")] internal readonly struct InstructionView { private readonly int _index; private readonly int _stackDepth; private readonly int _continuationsDepth; private readonly string _name; private readonly Instruction _instruction; internal string GetName() { return _index + (_continuationsDepth == 0 ? "" : " C(" + _continuationsDepth + ")") + (_stackDepth == 0 ? "" : " S(" + _stackDepth + ")"); } internal string GetValue() { return _name; } internal string GetDisplayType() { return _instruction.ContinuationsBalance + "/" + _instruction.StackBalance; } public InstructionView(Instruction instruction, string name, int index, int stackDepth, int continuationsDepth) { _instruction = instruction; _name = name; _index = index; _stackDepth = stackDepth; _continuationsDepth = continuationsDepth; } } } #endregion #region Core Emit Ops public void Emit(Instruction instruction) { _instructions.Add(instruction); UpdateStackDepth(instruction); } private void UpdateStackDepth(Instruction instruction) { Debug.Assert(instruction.ConsumedStack >= 0 && instruction.ProducedStack >= 0 && instruction.ConsumedContinuations >= 0 && instruction.ProducedContinuations >= 0, "bad instruction " + instruction.ToString()); _currentStackDepth -= instruction.ConsumedStack; Debug.Assert(_currentStackDepth >= 0, $"negative stack depth {instruction}"); _currentStackDepth += instruction.ProducedStack; if (_currentStackDepth > _maxStackDepth) { _maxStackDepth = _currentStackDepth; } _currentContinuationsDepth -= instruction.ConsumedContinuations; Debug.Assert(_currentContinuationsDepth >= 0, $"negative continuations {instruction}"); _currentContinuationsDepth += instruction.ProducedContinuations; if (_currentContinuationsDepth > _maxContinuationDepth) { _maxContinuationDepth = _currentContinuationsDepth; } } // "Un-emit" the previous instruction. // Useful if the instruction was emitted in the calling method, and covers the more usual case. // In particular, calling this after an EmitPush() or EmitDup() costs about the same as adding // an EmitPop() to undo it at compile time, and leaves a slightly leaner instruction list. public void UnEmit() { Instruction instruction = _instructions[_instructions.Count - 1]; _instructions.RemoveAt(_instructions.Count - 1); _currentContinuationsDepth -= instruction.ProducedContinuations; _currentContinuationsDepth += instruction.ConsumedContinuations; _currentStackDepth -= instruction.ProducedStack; _currentStackDepth += instruction.ConsumedStack; } /// <summary> /// Attaches a cookie to the last emitted instruction. /// </summary> [Conditional("DEBUG")] public void SetDebugCookie(object? cookie) { #if DEBUG _debugCookies ??= new List<KeyValuePair<int, object?>>(); Debug.Assert(Count > 0); _debugCookies.Add(new KeyValuePair<int, object?>(Count - 1, cookie)); #endif } public int Count => _instructions.Count; public int CurrentStackDepth => _currentStackDepth; public int CurrentContinuationsDepth => _currentContinuationsDepth; public int MaxStackDepth => _maxStackDepth; internal Instruction GetInstruction(int index) => _instructions[index]; #if STATS private static Dictionary<string, int> _executedInstructions = new Dictionary<string, int>(); private static Dictionary<string, Dictionary<object, bool>> _instances = new Dictionary<string, Dictionary<object, bool>>(); static InstructionList() { AppDomain.CurrentDomain.ProcessExit += new EventHandler((_, __) => { PerfTrack.DumpHistogram(_executedInstructions); Console.WriteLine("-- Total executed: {0}", _executedInstructions.Values.Aggregate(0, (sum, value) => sum + value)); Console.WriteLine("-----"); var referenced = new Dictionary<string, int>(); int total = 0; foreach (var entry in _instances) { referenced[entry.Key] = entry.Value.Count; total += entry.Value.Count; } PerfTrack.DumpHistogram(referenced); Console.WriteLine("-- Total referenced: {0}", total); Console.WriteLine("-----"); }); } #endif public InstructionArray ToArray() { #if STATS lock (_executedInstructions) { _instructions.ForEach((instr) => { int value = 0; var name = instr.GetType().Name; _executedInstructions.TryGetValue(name, out value); _executedInstructions[name] = value + 1; Dictionary<object, bool> dict; if (!_instances.TryGetValue(name, out dict)) { _instances[name] = dict = new Dictionary<object, bool>(); } dict[instr] = true; }); } #endif return new InstructionArray( _maxStackDepth, _maxContinuationDepth, _instructions.ToArray(), _objects?.ToArray(), BuildRuntimeLabels(), #if DEBUG _debugCookies #else null #endif ); } #endregion #region Stack Operations private const int PushIntMinCachedValue = -100; private const int PushIntMaxCachedValue = 100; private const int CachedObjectCount = 256; private static Instruction? s_null; private static Instruction? s_true; private static Instruction? s_false; private static Instruction[]? s_Ints; private static Instruction[]? s_loadObjectCached; public void EmitLoad(object? value) { EmitLoad(value, type: null); } public void EmitLoad(bool value) { if (value) { Emit(s_true ?? (s_true = new LoadObjectInstruction(Utils.BoxedTrue))); } else { Emit(s_false ?? (s_false = new LoadObjectInstruction(Utils.BoxedFalse))); } } public void EmitLoad(object? value, Type? type) { if (value == null) { Emit(s_null ?? (s_null = new LoadObjectInstruction(null))); return; } if (type == null || type.IsValueType) { if (value is bool) { EmitLoad((bool)value); return; } if (value is int) { int i = (int)value; if (i >= PushIntMinCachedValue && i <= PushIntMaxCachedValue) { if (s_Ints == null) { s_Ints = new Instruction[PushIntMaxCachedValue - PushIntMinCachedValue + 1]; } i -= PushIntMinCachedValue; Emit(s_Ints[i] ?? (s_Ints[i] = new LoadObjectInstruction(value))); return; } } } if (_objects == null) { _objects = new List<object>(); if (s_loadObjectCached == null) { s_loadObjectCached = new Instruction[CachedObjectCount]; } } if (_objects.Count < s_loadObjectCached!.Length) { uint index = (uint)_objects.Count; _objects.Add(value); Emit(s_loadObjectCached[index] ?? (s_loadObjectCached[index] = new LoadCachedObjectInstruction(index))); } else { Emit(new LoadObjectInstruction(value)); } } public void EmitDup() { Emit(DupInstruction.Instance); } public void EmitPop() { Emit(PopInstruction.Instance); } #endregion #region Locals internal void SwitchToBoxed(int index, int instructionIndex) { if (_instructions[instructionIndex] is IBoxableInstruction instruction) { Instruction? newInstruction = instruction.BoxIfIndexMatches(index); if (newInstruction != null) { _instructions[instructionIndex] = newInstruction; } } } private const int LocalInstrCacheSize = 64; private static Instruction[]? s_loadLocal; private static Instruction[]? s_loadLocalBoxed; private static Instruction[]? s_loadLocalFromClosure; private static Instruction[]? s_loadLocalFromClosureBoxed; private static Instruction[]? s_assignLocal; private static Instruction[]? s_storeLocal; private static Instruction[]? s_assignLocalBoxed; private static Instruction[]? s_storeLocalBoxed; private static Instruction[]? s_assignLocalToClosure; public void EmitLoadLocal(int index) { if (s_loadLocal == null) { s_loadLocal = new Instruction[LocalInstrCacheSize]; } if (index < s_loadLocal.Length) { Emit(s_loadLocal[index] ?? (s_loadLocal[index] = new LoadLocalInstruction(index))); } else { Emit(new LoadLocalInstruction(index)); } } public void EmitLoadLocalBoxed(int index) { Emit(LoadLocalBoxed(index)); } internal static Instruction LoadLocalBoxed(int index) { if (s_loadLocalBoxed == null) { s_loadLocalBoxed = new Instruction[LocalInstrCacheSize]; } if (index < s_loadLocalBoxed.Length) { return s_loadLocalBoxed[index] ?? (s_loadLocalBoxed[index] = new LoadLocalBoxedInstruction(index)); } else { return new LoadLocalBoxedInstruction(index); } } public void EmitLoadLocalFromClosure(int index) { if (s_loadLocalFromClosure == null) { s_loadLocalFromClosure = new Instruction[LocalInstrCacheSize]; } if (index < s_loadLocalFromClosure.Length) { Emit(s_loadLocalFromClosure[index] ?? (s_loadLocalFromClosure[index] = new LoadLocalFromClosureInstruction(index))); } else { Emit(new LoadLocalFromClosureInstruction(index)); } } public void EmitLoadLocalFromClosureBoxed(int index) { if (s_loadLocalFromClosureBoxed == null) { s_loadLocalFromClosureBoxed = new Instruction[LocalInstrCacheSize]; } if (index < s_loadLocalFromClosureBoxed.Length) { Emit(s_loadLocalFromClosureBoxed[index] ?? (s_loadLocalFromClosureBoxed[index] = new LoadLocalFromClosureBoxedInstruction(index))); } else { Emit(new LoadLocalFromClosureBoxedInstruction(index)); } } public void EmitAssignLocal(int index) { if (s_assignLocal == null) { s_assignLocal = new Instruction[LocalInstrCacheSize]; } if (index < s_assignLocal.Length) { Emit(s_assignLocal[index] ?? (s_assignLocal[index] = new AssignLocalInstruction(index))); } else { Emit(new AssignLocalInstruction(index)); } } public void EmitStoreLocal(int index) { if (s_storeLocal == null) { s_storeLocal = new Instruction[LocalInstrCacheSize]; } if (index < s_storeLocal.Length) { Emit(s_storeLocal[index] ?? (s_storeLocal[index] = new StoreLocalInstruction(index))); } else { Emit(new StoreLocalInstruction(index)); } } public void EmitAssignLocalBoxed(int index) { Emit(AssignLocalBoxed(index)); } internal static Instruction AssignLocalBoxed(int index) { if (s_assignLocalBoxed == null) { s_assignLocalBoxed = new Instruction[LocalInstrCacheSize]; } if (index < s_assignLocalBoxed.Length) { return s_assignLocalBoxed[index] ?? (s_assignLocalBoxed[index] = new AssignLocalBoxedInstruction(index)); } else { return new AssignLocalBoxedInstruction(index); } } public void EmitStoreLocalBoxed(int index) { Emit(StoreLocalBoxed(index)); } internal static Instruction StoreLocalBoxed(int index) { if (s_storeLocalBoxed == null) { s_storeLocalBoxed = new Instruction[LocalInstrCacheSize]; } if (index < s_storeLocalBoxed.Length) { return s_storeLocalBoxed[index] ?? (s_storeLocalBoxed[index] = new StoreLocalBoxedInstruction(index)); } else { return new StoreLocalBoxedInstruction(index); } } public void EmitAssignLocalToClosure(int index) { if (s_assignLocalToClosure == null) { s_assignLocalToClosure = new Instruction[LocalInstrCacheSize]; } if (index < s_assignLocalToClosure.Length) { Emit(s_assignLocalToClosure[index] ?? (s_assignLocalToClosure[index] = new AssignLocalToClosureInstruction(index))); } else { Emit(new AssignLocalToClosureInstruction(index)); } } public void EmitStoreLocalToClosure(int index) { EmitAssignLocalToClosure(index); EmitPop(); } public void EmitInitializeLocal(int index, Type type) { object? value = ScriptingRuntimeHelpers.GetPrimitiveDefaultValue(type); if (value != null) { Emit(new InitializeLocalInstruction.ImmutableValue(index, value)); } else if (type.IsValueType) { Emit(new InitializeLocalInstruction.MutableValue(index, type)); } else { Emit(InitReference(index)); } } internal void EmitInitializeParameter(int index) { Emit(Parameter(index)); } internal static Instruction Parameter(int index) { return new InitializeLocalInstruction.Parameter(index); } internal static Instruction ParameterBox(int index) { return new InitializeLocalInstruction.ParameterBox(index); } internal static Instruction InitReference(int index) { return new InitializeLocalInstruction.Reference(index); } internal static Instruction InitImmutableRefBox(int index) { return new InitializeLocalInstruction.ImmutableRefBox(index); } public void EmitNewRuntimeVariables(int count) { Emit(new RuntimeVariablesInstruction(count)); } #endregion #region Array Operations public void EmitGetArrayItem() { Emit(GetArrayItemInstruction.Instance); } public void EmitSetArrayItem() { Emit(SetArrayItemInstruction.Instance); } public void EmitNewArray(Type elementType) { Emit(new NewArrayInstruction(elementType)); } public void EmitNewArrayBounds(Type elementType, int rank) { Emit(new NewArrayBoundsInstruction(elementType, rank)); } public void EmitNewArrayInit(Type elementType, int elementCount) { Emit(new NewArrayInitInstruction(elementType, elementCount)); } #endregion #region Arithmetic Operations public void EmitAdd(Type type, bool @checked) { Emit(@checked ? AddOvfInstruction.Create(type) : AddInstruction.Create(type)); } public void EmitSub(Type type, bool @checked) { Emit(@checked ? SubOvfInstruction.Create(type) : SubInstruction.Create(type)); } public void EmitMul(Type type, bool @checked) { Emit(@checked ? MulOvfInstruction.Create(type) : MulInstruction.Create(type)); } public void EmitDiv(Type type) { Emit(DivInstruction.Create(type)); } public void EmitModulo(Type type) { Emit(ModuloInstruction.Create(type)); } #endregion #region Comparisons public void EmitExclusiveOr(Type type) { Emit(ExclusiveOrInstruction.Create(type)); } public void EmitAnd(Type type) { Emit(AndInstruction.Create(type)); } public void EmitOr(Type type) { Emit(OrInstruction.Create(type)); } public void EmitLeftShift(Type type) { Emit(LeftShiftInstruction.Create(type)); } public void EmitRightShift(Type type) { Emit(RightShiftInstruction.Create(type)); } public void EmitEqual(Type type, bool liftedToNull = false) { Emit(EqualInstruction.Create(type, liftedToNull)); } public void EmitNotEqual(Type type, bool liftedToNull = false) { Emit(NotEqualInstruction.Create(type, liftedToNull)); } public void EmitLessThan(Type type, bool liftedToNull) { Emit(LessThanInstruction.Create(type, liftedToNull)); } public void EmitLessThanOrEqual(Type type, bool liftedToNull) { Emit(LessThanOrEqualInstruction.Create(type, liftedToNull)); } public void EmitGreaterThan(Type type, bool liftedToNull) { Emit(GreaterThanInstruction.Create(type, liftedToNull)); } public void EmitGreaterThanOrEqual(Type type, bool liftedToNull) { Emit(GreaterThanOrEqualInstruction.Create(type, liftedToNull)); } #endregion #region Conversions public void EmitNumericConvertChecked(TypeCode from, TypeCode to, bool isLiftedToNull) { Emit(new NumericConvertInstruction.Checked(from, to, isLiftedToNull)); } public void EmitNumericConvertUnchecked(TypeCode from, TypeCode to, bool isLiftedToNull) { Emit(new NumericConvertInstruction.Unchecked(from, to, isLiftedToNull)); } public void EmitConvertToUnderlying(TypeCode to, bool isLiftedToNull) { Emit(new NumericConvertInstruction.ToUnderlying(to, isLiftedToNull)); } public void EmitCast(Type toType) { Emit(CastInstruction.Create(toType)); } public void EmitCastToEnum(Type toType) { Emit(new CastToEnumInstruction(toType)); } public void EmitCastReferenceToEnum(Type toType) { Debug.Assert(_instructions[_instructions.Count - 1] == NullCheckInstruction.Instance); Emit(new CastReferenceToEnumInstruction(toType)); } #endregion #region Boolean Operators public void EmitNot(Type type) { Emit(NotInstruction.Create(type)); } #endregion #region Types public void EmitDefaultValue(Type type) { Emit(new DefaultValueInstruction(type)); } public void EmitNew(ConstructorInfo constructorInfo, ParameterInfo[] parameters) { Emit(new NewInstruction(constructorInfo, parameters.Length)); } public void EmitByRefNew(ConstructorInfo constructorInfo, ParameterInfo[] parameters, ByRefUpdater[] updaters) { Emit(new ByRefNewInstruction(constructorInfo, parameters.Length, updaters)); } internal void EmitCreateDelegate(LightDelegateCreator creator) { Emit(new CreateDelegateInstruction(creator)); } public void EmitTypeEquals() { Emit(TypeEqualsInstruction.Instance); } public void EmitArrayLength() { Emit(ArrayLengthInstruction.Instance); } public void EmitNegate(Type type) { Emit(NegateInstruction.Create(type)); } public void EmitNegateChecked(Type type) { Emit(NegateCheckedInstruction.Create(type)); } public void EmitIncrement(Type type) { Emit(IncrementInstruction.Create(type)); } public void EmitDecrement(Type type) { Emit(DecrementInstruction.Create(type)); } public void EmitTypeIs(Type type) { Emit(new TypeIsInstruction(type)); } public void EmitTypeAs(Type type) { Emit(new TypeAsInstruction(type)); } #endregion #region Fields and Methods private static readonly Dictionary<FieldInfo, Instruction> s_loadFields = new Dictionary<FieldInfo, Instruction>(); public void EmitLoadField(FieldInfo field) { Emit(GetLoadField(field)); } private Instruction GetLoadField(FieldInfo field) { lock (s_loadFields) { if (!s_loadFields.TryGetValue(field, out Instruction? instruction)) { if (field.IsStatic) { instruction = new LoadStaticFieldInstruction(field); } else { instruction = new LoadFieldInstruction(field); } s_loadFields.Add(field, instruction); } return instruction; } } public void EmitStoreField(FieldInfo field) { if (field.IsStatic) { Emit(new StoreStaticFieldInstruction(field)); } else { Emit(new StoreFieldInstruction(field)); } } public void EmitCall(MethodInfo method) { EmitCall(method, method.GetParametersCached()); } public void EmitCall(MethodInfo method, ParameterInfo[] parameters) { Emit(CallInstruction.Create(method, parameters)); } public void EmitByRefCall(MethodInfo method, ParameterInfo[] parameters, ByRefUpdater[] byrefArgs) { Emit(new ByRefMethodInfoCallInstruction(method, method.IsStatic ? parameters.Length : parameters.Length + 1, byrefArgs)); } public void EmitNullableCall(MethodInfo method, ParameterInfo[] parameters) { Emit(NullableMethodCallInstruction.Create(method.Name, parameters.Length, method)); } #endregion #region Control Flow private static readonly RuntimeLabel[] s_emptyRuntimeLabels = new RuntimeLabel[] { new RuntimeLabel(Interpreter.RethrowOnReturn, 0, 0) }; private RuntimeLabel[] BuildRuntimeLabels() { if (_runtimeLabelCount == 0) { return s_emptyRuntimeLabels; } var result = new RuntimeLabel[_runtimeLabelCount + 1]; foreach (BranchLabel label in _labels!) { if (label.HasRuntimeLabel) { result[label.LabelIndex] = label.ToRuntimeLabel(); } } // "return and rethrow" label: result[result.Length - 1] = new RuntimeLabel(Interpreter.RethrowOnReturn, 0, 0); return result; } public BranchLabel MakeLabel() { if (_labels == null) { _labels = new List<BranchLabel>(); } var label = new BranchLabel(); _labels.Add(label); return label; } internal void FixupBranch(int branchIndex, int offset) { _instructions[branchIndex] = ((OffsetInstruction)_instructions[branchIndex]).Fixup(offset); } private int EnsureLabelIndex(BranchLabel label) { if (label.HasRuntimeLabel) { return label.LabelIndex; } label.LabelIndex = _runtimeLabelCount; _runtimeLabelCount++; return label.LabelIndex; } public int MarkRuntimeLabel() { BranchLabel handlerLabel = MakeLabel(); MarkLabel(handlerLabel); return EnsureLabelIndex(handlerLabel); } public void MarkLabel(BranchLabel label) { label.Mark(this); } public void EmitGoto(BranchLabel label, bool hasResult, bool hasValue, bool labelTargetGetsValue) { Emit(GotoInstruction.Create(EnsureLabelIndex(label), hasResult, hasValue, labelTargetGetsValue)); } private void EmitBranch(OffsetInstruction instruction, BranchLabel label) { Emit(instruction); label.AddBranch(this, Count - 1); } public void EmitBranch(BranchLabel label) { EmitBranch(new BranchInstruction(), label); } public void EmitBranch(BranchLabel label, bool hasResult, bool hasValue) { EmitBranch(new BranchInstruction(hasResult, hasValue), label); } public void EmitCoalescingBranch(BranchLabel leftNotNull) { EmitBranch(new CoalescingBranchInstruction(), leftNotNull); } public void EmitBranchTrue(BranchLabel elseLabel) { EmitBranch(new BranchTrueInstruction(), elseLabel); } public void EmitBranchFalse(BranchLabel elseLabel) { EmitBranch(new BranchFalseInstruction(), elseLabel); } public void EmitThrow() { Emit(ThrowInstruction.Throw); } public void EmitThrowVoid() { Emit(ThrowInstruction.VoidThrow); } public void EmitRethrow() { Emit(ThrowInstruction.Rethrow); } public void EmitRethrowVoid() { Emit(ThrowInstruction.VoidRethrow); } public void EmitEnterTryFinally(BranchLabel finallyStartLabel) { Emit(EnterTryCatchFinallyInstruction.CreateTryFinally(EnsureLabelIndex(finallyStartLabel))); } public void EmitEnterTryCatch() { Emit(EnterTryCatchFinallyInstruction.CreateTryCatch()); } public EnterTryFaultInstruction EmitEnterTryFault(BranchLabel tryEnd) { var instruction = new EnterTryFaultInstruction(EnsureLabelIndex(tryEnd)); Emit(instruction); return instruction; } public void EmitEnterFinally(BranchLabel finallyStartLabel) { Emit(EnterFinallyInstruction.Create(EnsureLabelIndex(finallyStartLabel))); } public void EmitLeaveFinally() { Emit(LeaveFinallyInstruction.Instance); } public void EmitEnterFault(BranchLabel faultStartLabel) { Emit(EnterFaultInstruction.Create(EnsureLabelIndex(faultStartLabel))); } public void EmitLeaveFault() { Emit(LeaveFaultInstruction.Instance); } public void EmitEnterExceptionFilter() { Emit(EnterExceptionFilterInstruction.Instance); } public void EmitLeaveExceptionFilter() { Emit(LeaveExceptionFilterInstruction.Instance); } public void EmitEnterExceptionHandlerNonVoid() { Emit(EnterExceptionHandlerInstruction.NonVoid); } public void EmitEnterExceptionHandlerVoid() { Emit(EnterExceptionHandlerInstruction.Void); } public void EmitLeaveExceptionHandler(bool hasValue, BranchLabel tryExpressionEndLabel) { Emit(LeaveExceptionHandlerInstruction.Create(EnsureLabelIndex(tryExpressionEndLabel), hasValue)); } public void EmitIntSwitch<T>(Dictionary<T, int> cases) where T : notnull { Emit(new IntSwitchInstruction<T>(cases)); } public void EmitStringSwitch(Dictionary<string, int> cases, StrongBox<int> nullCase) { Emit(new StringSwitchInstruction(cases, nullCase)); } #endregion } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Enables instruction counting and displaying stats at process exit. // #define STATS using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Dynamic.Utils; namespace System.Linq.Expressions.Interpreter { [DebuggerTypeProxy(typeof(InstructionArray.DebugView))] internal readonly struct InstructionArray { internal readonly int MaxStackDepth; internal readonly int MaxContinuationDepth; internal readonly Instruction[] Instructions; internal readonly object[]? Objects; internal readonly RuntimeLabel[] Labels; // list of (instruction index, cookie) sorted by instruction index: internal readonly List<KeyValuePair<int, object?>>? DebugCookies; internal InstructionArray(int maxStackDepth, int maxContinuationDepth, Instruction[] instructions, object[]? objects, RuntimeLabel[] labels, List<KeyValuePair<int, object?>>? debugCookies) { MaxStackDepth = maxStackDepth; MaxContinuationDepth = maxContinuationDepth; Instructions = instructions; DebugCookies = debugCookies; Objects = objects; Labels = labels; } #region Debug View internal sealed class DebugView { private readonly InstructionArray _array; public DebugView(InstructionArray array) { ContractUtils.RequiresNotNull(array, nameof(array)); _array = array; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public InstructionList.DebugView.InstructionView[]/*!*/ A0 => GetInstructionViews(includeDebugCookies: true); public InstructionList.DebugView.InstructionView[] GetInstructionViews(bool includeDebugCookies = false) { return InstructionList.DebugView.GetInstructionViews( _array.Instructions, _array.Objects, (index) => _array.Labels[index].Index, includeDebugCookies ? _array.DebugCookies : null ); } } #endregion } [DebuggerTypeProxy(typeof(InstructionList.DebugView))] internal sealed class InstructionList { private readonly List<Instruction> _instructions = new List<Instruction>(); private List<object>? _objects; private int _currentStackDepth; private int _maxStackDepth; private int _currentContinuationsDepth; private int _maxContinuationDepth; private int _runtimeLabelCount; private List<BranchLabel>? _labels; #if DEBUG // list of (instruction index, cookie) sorted by instruction index: private List<KeyValuePair<int, object?>>? _debugCookies; #endif #region Debug View internal sealed class DebugView { private readonly InstructionList _list; public DebugView(InstructionList list) { ContractUtils.RequiresNotNull(list, nameof(list)); _list = list; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public InstructionView[]/*!*/ A0 => GetInstructionViews(includeDebugCookies: true); public InstructionView[] GetInstructionViews(bool includeDebugCookies = false) { return GetInstructionViews( _list._instructions, _list._objects, (index) => _list._labels![index].TargetIndex, #if DEBUG includeDebugCookies ? _list._debugCookies : #endif null ); } internal static InstructionView[] GetInstructionViews(IReadOnlyList<Instruction> instructions, IReadOnlyList<object>? objects, Func<int, int> labelIndexer, IReadOnlyList<KeyValuePair<int, object?>>? debugCookies) { var result = new List<InstructionView>(); int index = 0; int stackDepth = 0; int continuationsDepth = 0; IEnumerator<KeyValuePair<int, object?>> cookieEnumerator = (debugCookies ?? Array.Empty<KeyValuePair<int, object?>>()).GetEnumerator(); bool hasCookie = cookieEnumerator.MoveNext(); for (int i = 0, n = instructions.Count; i < n; i++) { Instruction instruction = instructions[i]; object? cookie = null; while (hasCookie && cookieEnumerator.Current.Key == i) { cookie = cookieEnumerator.Current.Value; hasCookie = cookieEnumerator.MoveNext(); } int stackDiff = instruction.StackBalance; int contDiff = instruction.ContinuationsBalance; string name = instruction.ToDebugString(i, cookie, labelIndexer, objects); result.Add(new InstructionView(instruction, name, i, stackDepth, continuationsDepth)); index++; stackDepth += stackDiff; continuationsDepth += contDiff; } return result.ToArray(); } [DebuggerDisplay("{GetValue(),nq}", Name = "{GetName(),nq}", Type = "{GetDisplayType(), nq}")] internal readonly struct InstructionView { private readonly int _index; private readonly int _stackDepth; private readonly int _continuationsDepth; private readonly string _name; private readonly Instruction _instruction; internal string GetName() { return _index + (_continuationsDepth == 0 ? "" : " C(" + _continuationsDepth + ")") + (_stackDepth == 0 ? "" : " S(" + _stackDepth + ")"); } internal string GetValue() { return _name; } internal string GetDisplayType() { return _instruction.ContinuationsBalance + "/" + _instruction.StackBalance; } public InstructionView(Instruction instruction, string name, int index, int stackDepth, int continuationsDepth) { _instruction = instruction; _name = name; _index = index; _stackDepth = stackDepth; _continuationsDepth = continuationsDepth; } } } #endregion #region Core Emit Ops public void Emit(Instruction instruction) { _instructions.Add(instruction); UpdateStackDepth(instruction); } private void UpdateStackDepth(Instruction instruction) { Debug.Assert(instruction.ConsumedStack >= 0 && instruction.ProducedStack >= 0 && instruction.ConsumedContinuations >= 0 && instruction.ProducedContinuations >= 0, "bad instruction " + instruction.ToString()); _currentStackDepth -= instruction.ConsumedStack; Debug.Assert(_currentStackDepth >= 0, $"negative stack depth {instruction}"); _currentStackDepth += instruction.ProducedStack; if (_currentStackDepth > _maxStackDepth) { _maxStackDepth = _currentStackDepth; } _currentContinuationsDepth -= instruction.ConsumedContinuations; Debug.Assert(_currentContinuationsDepth >= 0, $"negative continuations {instruction}"); _currentContinuationsDepth += instruction.ProducedContinuations; if (_currentContinuationsDepth > _maxContinuationDepth) { _maxContinuationDepth = _currentContinuationsDepth; } } // "Un-emit" the previous instruction. // Useful if the instruction was emitted in the calling method, and covers the more usual case. // In particular, calling this after an EmitPush() or EmitDup() costs about the same as adding // an EmitPop() to undo it at compile time, and leaves a slightly leaner instruction list. public void UnEmit() { Instruction instruction = _instructions[_instructions.Count - 1]; _instructions.RemoveAt(_instructions.Count - 1); _currentContinuationsDepth -= instruction.ProducedContinuations; _currentContinuationsDepth += instruction.ConsumedContinuations; _currentStackDepth -= instruction.ProducedStack; _currentStackDepth += instruction.ConsumedStack; } /// <summary> /// Attaches a cookie to the last emitted instruction. /// </summary> [Conditional("DEBUG")] public void SetDebugCookie(object? cookie) { #if DEBUG _debugCookies ??= new List<KeyValuePair<int, object?>>(); Debug.Assert(Count > 0); _debugCookies.Add(new KeyValuePair<int, object?>(Count - 1, cookie)); #endif } public int Count => _instructions.Count; public int CurrentStackDepth => _currentStackDepth; public int CurrentContinuationsDepth => _currentContinuationsDepth; public int MaxStackDepth => _maxStackDepth; internal Instruction GetInstruction(int index) => _instructions[index]; #if STATS private static Dictionary<string, int> _executedInstructions = new Dictionary<string, int>(); private static Dictionary<string, Dictionary<object, bool>> _instances = new Dictionary<string, Dictionary<object, bool>>(); static InstructionList() { AppDomain.CurrentDomain.ProcessExit += new EventHandler((_, __) => { PerfTrack.DumpHistogram(_executedInstructions); Console.WriteLine("-- Total executed: {0}", _executedInstructions.Values.Aggregate(0, (sum, value) => sum + value)); Console.WriteLine("-----"); var referenced = new Dictionary<string, int>(); int total = 0; foreach (var entry in _instances) { referenced[entry.Key] = entry.Value.Count; total += entry.Value.Count; } PerfTrack.DumpHistogram(referenced); Console.WriteLine("-- Total referenced: {0}", total); Console.WriteLine("-----"); }); } #endif public InstructionArray ToArray() { #if STATS lock (_executedInstructions) { _instructions.ForEach((instr) => { int value = 0; var name = instr.GetType().Name; _executedInstructions.TryGetValue(name, out value); _executedInstructions[name] = value + 1; Dictionary<object, bool> dict; if (!_instances.TryGetValue(name, out dict)) { _instances[name] = dict = new Dictionary<object, bool>(); } dict[instr] = true; }); } #endif return new InstructionArray( _maxStackDepth, _maxContinuationDepth, _instructions.ToArray(), _objects?.ToArray(), BuildRuntimeLabels(), #if DEBUG _debugCookies #else null #endif ); } #endregion #region Stack Operations private const int PushIntMinCachedValue = -100; private const int PushIntMaxCachedValue = 100; private const int CachedObjectCount = 256; private static Instruction? s_null; private static Instruction? s_true; private static Instruction? s_false; private static Instruction[]? s_Ints; private static Instruction[]? s_loadObjectCached; public void EmitLoad(object? value) { EmitLoad(value, type: null); } public void EmitLoad(bool value) { if (value) { Emit(s_true ?? (s_true = new LoadObjectInstruction(Utils.BoxedTrue))); } else { Emit(s_false ?? (s_false = new LoadObjectInstruction(Utils.BoxedFalse))); } } public void EmitLoad(object? value, Type? type) { if (value == null) { Emit(s_null ?? (s_null = new LoadObjectInstruction(null))); return; } if (type == null || type.IsValueType) { if (value is bool) { EmitLoad((bool)value); return; } if (value is int) { int i = (int)value; if (i >= PushIntMinCachedValue && i <= PushIntMaxCachedValue) { if (s_Ints == null) { s_Ints = new Instruction[PushIntMaxCachedValue - PushIntMinCachedValue + 1]; } i -= PushIntMinCachedValue; Emit(s_Ints[i] ?? (s_Ints[i] = new LoadObjectInstruction(value))); return; } } } if (_objects == null) { _objects = new List<object>(); if (s_loadObjectCached == null) { s_loadObjectCached = new Instruction[CachedObjectCount]; } } if (_objects.Count < s_loadObjectCached!.Length) { uint index = (uint)_objects.Count; _objects.Add(value); Emit(s_loadObjectCached[index] ?? (s_loadObjectCached[index] = new LoadCachedObjectInstruction(index))); } else { Emit(new LoadObjectInstruction(value)); } } public void EmitDup() { Emit(DupInstruction.Instance); } public void EmitPop() { Emit(PopInstruction.Instance); } #endregion #region Locals internal void SwitchToBoxed(int index, int instructionIndex) { if (_instructions[instructionIndex] is IBoxableInstruction instruction) { Instruction? newInstruction = instruction.BoxIfIndexMatches(index); if (newInstruction != null) { _instructions[instructionIndex] = newInstruction; } } } private const int LocalInstrCacheSize = 64; private static Instruction[]? s_loadLocal; private static Instruction[]? s_loadLocalBoxed; private static Instruction[]? s_loadLocalFromClosure; private static Instruction[]? s_loadLocalFromClosureBoxed; private static Instruction[]? s_assignLocal; private static Instruction[]? s_storeLocal; private static Instruction[]? s_assignLocalBoxed; private static Instruction[]? s_storeLocalBoxed; private static Instruction[]? s_assignLocalToClosure; public void EmitLoadLocal(int index) { if (s_loadLocal == null) { s_loadLocal = new Instruction[LocalInstrCacheSize]; } if (index < s_loadLocal.Length) { Emit(s_loadLocal[index] ?? (s_loadLocal[index] = new LoadLocalInstruction(index))); } else { Emit(new LoadLocalInstruction(index)); } } public void EmitLoadLocalBoxed(int index) { Emit(LoadLocalBoxed(index)); } internal static Instruction LoadLocalBoxed(int index) { if (s_loadLocalBoxed == null) { s_loadLocalBoxed = new Instruction[LocalInstrCacheSize]; } if (index < s_loadLocalBoxed.Length) { return s_loadLocalBoxed[index] ?? (s_loadLocalBoxed[index] = new LoadLocalBoxedInstruction(index)); } else { return new LoadLocalBoxedInstruction(index); } } public void EmitLoadLocalFromClosure(int index) { if (s_loadLocalFromClosure == null) { s_loadLocalFromClosure = new Instruction[LocalInstrCacheSize]; } if (index < s_loadLocalFromClosure.Length) { Emit(s_loadLocalFromClosure[index] ?? (s_loadLocalFromClosure[index] = new LoadLocalFromClosureInstruction(index))); } else { Emit(new LoadLocalFromClosureInstruction(index)); } } public void EmitLoadLocalFromClosureBoxed(int index) { if (s_loadLocalFromClosureBoxed == null) { s_loadLocalFromClosureBoxed = new Instruction[LocalInstrCacheSize]; } if (index < s_loadLocalFromClosureBoxed.Length) { Emit(s_loadLocalFromClosureBoxed[index] ?? (s_loadLocalFromClosureBoxed[index] = new LoadLocalFromClosureBoxedInstruction(index))); } else { Emit(new LoadLocalFromClosureBoxedInstruction(index)); } } public void EmitAssignLocal(int index) { if (s_assignLocal == null) { s_assignLocal = new Instruction[LocalInstrCacheSize]; } if (index < s_assignLocal.Length) { Emit(s_assignLocal[index] ?? (s_assignLocal[index] = new AssignLocalInstruction(index))); } else { Emit(new AssignLocalInstruction(index)); } } public void EmitStoreLocal(int index) { if (s_storeLocal == null) { s_storeLocal = new Instruction[LocalInstrCacheSize]; } if (index < s_storeLocal.Length) { Emit(s_storeLocal[index] ?? (s_storeLocal[index] = new StoreLocalInstruction(index))); } else { Emit(new StoreLocalInstruction(index)); } } public void EmitAssignLocalBoxed(int index) { Emit(AssignLocalBoxed(index)); } internal static Instruction AssignLocalBoxed(int index) { if (s_assignLocalBoxed == null) { s_assignLocalBoxed = new Instruction[LocalInstrCacheSize]; } if (index < s_assignLocalBoxed.Length) { return s_assignLocalBoxed[index] ?? (s_assignLocalBoxed[index] = new AssignLocalBoxedInstruction(index)); } else { return new AssignLocalBoxedInstruction(index); } } public void EmitStoreLocalBoxed(int index) { Emit(StoreLocalBoxed(index)); } internal static Instruction StoreLocalBoxed(int index) { if (s_storeLocalBoxed == null) { s_storeLocalBoxed = new Instruction[LocalInstrCacheSize]; } if (index < s_storeLocalBoxed.Length) { return s_storeLocalBoxed[index] ?? (s_storeLocalBoxed[index] = new StoreLocalBoxedInstruction(index)); } else { return new StoreLocalBoxedInstruction(index); } } public void EmitAssignLocalToClosure(int index) { if (s_assignLocalToClosure == null) { s_assignLocalToClosure = new Instruction[LocalInstrCacheSize]; } if (index < s_assignLocalToClosure.Length) { Emit(s_assignLocalToClosure[index] ?? (s_assignLocalToClosure[index] = new AssignLocalToClosureInstruction(index))); } else { Emit(new AssignLocalToClosureInstruction(index)); } } public void EmitStoreLocalToClosure(int index) { EmitAssignLocalToClosure(index); EmitPop(); } public void EmitInitializeLocal(int index, Type type) { object? value = ScriptingRuntimeHelpers.GetPrimitiveDefaultValue(type); if (value != null) { Emit(new InitializeLocalInstruction.ImmutableValue(index, value)); } else if (type.IsValueType) { Emit(new InitializeLocalInstruction.MutableValue(index, type)); } else { Emit(InitReference(index)); } } internal void EmitInitializeParameter(int index) { Emit(Parameter(index)); } internal static Instruction Parameter(int index) { return new InitializeLocalInstruction.Parameter(index); } internal static Instruction ParameterBox(int index) { return new InitializeLocalInstruction.ParameterBox(index); } internal static Instruction InitReference(int index) { return new InitializeLocalInstruction.Reference(index); } internal static Instruction InitImmutableRefBox(int index) { return new InitializeLocalInstruction.ImmutableRefBox(index); } public void EmitNewRuntimeVariables(int count) { Emit(new RuntimeVariablesInstruction(count)); } #endregion #region Array Operations public void EmitGetArrayItem() { Emit(GetArrayItemInstruction.Instance); } public void EmitSetArrayItem() { Emit(SetArrayItemInstruction.Instance); } public void EmitNewArray(Type elementType) { Emit(new NewArrayInstruction(elementType)); } public void EmitNewArrayBounds(Type elementType, int rank) { Emit(new NewArrayBoundsInstruction(elementType, rank)); } public void EmitNewArrayInit(Type elementType, int elementCount) { Emit(new NewArrayInitInstruction(elementType, elementCount)); } #endregion #region Arithmetic Operations public void EmitAdd(Type type, bool @checked) { Emit(@checked ? AddOvfInstruction.Create(type) : AddInstruction.Create(type)); } public void EmitSub(Type type, bool @checked) { Emit(@checked ? SubOvfInstruction.Create(type) : SubInstruction.Create(type)); } public void EmitMul(Type type, bool @checked) { Emit(@checked ? MulOvfInstruction.Create(type) : MulInstruction.Create(type)); } public void EmitDiv(Type type) { Emit(DivInstruction.Create(type)); } public void EmitModulo(Type type) { Emit(ModuloInstruction.Create(type)); } #endregion #region Comparisons public void EmitExclusiveOr(Type type) { Emit(ExclusiveOrInstruction.Create(type)); } public void EmitAnd(Type type) { Emit(AndInstruction.Create(type)); } public void EmitOr(Type type) { Emit(OrInstruction.Create(type)); } public void EmitLeftShift(Type type) { Emit(LeftShiftInstruction.Create(type)); } public void EmitRightShift(Type type) { Emit(RightShiftInstruction.Create(type)); } public void EmitEqual(Type type, bool liftedToNull = false) { Emit(EqualInstruction.Create(type, liftedToNull)); } public void EmitNotEqual(Type type, bool liftedToNull = false) { Emit(NotEqualInstruction.Create(type, liftedToNull)); } public void EmitLessThan(Type type, bool liftedToNull) { Emit(LessThanInstruction.Create(type, liftedToNull)); } public void EmitLessThanOrEqual(Type type, bool liftedToNull) { Emit(LessThanOrEqualInstruction.Create(type, liftedToNull)); } public void EmitGreaterThan(Type type, bool liftedToNull) { Emit(GreaterThanInstruction.Create(type, liftedToNull)); } public void EmitGreaterThanOrEqual(Type type, bool liftedToNull) { Emit(GreaterThanOrEqualInstruction.Create(type, liftedToNull)); } #endregion #region Conversions public void EmitNumericConvertChecked(TypeCode from, TypeCode to, bool isLiftedToNull) { Emit(new NumericConvertInstruction.Checked(from, to, isLiftedToNull)); } public void EmitNumericConvertUnchecked(TypeCode from, TypeCode to, bool isLiftedToNull) { Emit(new NumericConvertInstruction.Unchecked(from, to, isLiftedToNull)); } public void EmitConvertToUnderlying(TypeCode to, bool isLiftedToNull) { Emit(new NumericConvertInstruction.ToUnderlying(to, isLiftedToNull)); } public void EmitCast(Type toType) { Emit(CastInstruction.Create(toType)); } public void EmitCastToEnum(Type toType) { Emit(new CastToEnumInstruction(toType)); } public void EmitCastReferenceToEnum(Type toType) { Debug.Assert(_instructions[_instructions.Count - 1] == NullCheckInstruction.Instance); Emit(new CastReferenceToEnumInstruction(toType)); } #endregion #region Boolean Operators public void EmitNot(Type type) { Emit(NotInstruction.Create(type)); } #endregion #region Types public void EmitDefaultValue(Type type) { Emit(new DefaultValueInstruction(type)); } public void EmitNew(ConstructorInfo constructorInfo, ParameterInfo[] parameters) { Emit(new NewInstruction(constructorInfo, parameters.Length)); } public void EmitByRefNew(ConstructorInfo constructorInfo, ParameterInfo[] parameters, ByRefUpdater[] updaters) { Emit(new ByRefNewInstruction(constructorInfo, parameters.Length, updaters)); } internal void EmitCreateDelegate(LightDelegateCreator creator) { Emit(new CreateDelegateInstruction(creator)); } public void EmitTypeEquals() { Emit(TypeEqualsInstruction.Instance); } public void EmitArrayLength() { Emit(ArrayLengthInstruction.Instance); } public void EmitNegate(Type type) { Emit(NegateInstruction.Create(type)); } public void EmitNegateChecked(Type type) { Emit(NegateCheckedInstruction.Create(type)); } public void EmitIncrement(Type type) { Emit(IncrementInstruction.Create(type)); } public void EmitDecrement(Type type) { Emit(DecrementInstruction.Create(type)); } public void EmitTypeIs(Type type) { Emit(new TypeIsInstruction(type)); } public void EmitTypeAs(Type type) { Emit(new TypeAsInstruction(type)); } #endregion #region Fields and Methods private static readonly Dictionary<FieldInfo, Instruction> s_loadFields = new Dictionary<FieldInfo, Instruction>(); public void EmitLoadField(FieldInfo field) { Emit(GetLoadField(field)); } private Instruction GetLoadField(FieldInfo field) { lock (s_loadFields) { if (!s_loadFields.TryGetValue(field, out Instruction? instruction)) { if (field.IsStatic) { instruction = new LoadStaticFieldInstruction(field); } else { instruction = new LoadFieldInstruction(field); } s_loadFields.Add(field, instruction); } return instruction; } } public void EmitStoreField(FieldInfo field) { if (field.IsStatic) { Emit(new StoreStaticFieldInstruction(field)); } else { Emit(new StoreFieldInstruction(field)); } } public void EmitCall(MethodInfo method) { EmitCall(method, method.GetParametersCached()); } public void EmitCall(MethodInfo method, ParameterInfo[] parameters) { Emit(CallInstruction.Create(method, parameters)); } public void EmitByRefCall(MethodInfo method, ParameterInfo[] parameters, ByRefUpdater[] byrefArgs) { Emit(new ByRefMethodInfoCallInstruction(method, method.IsStatic ? parameters.Length : parameters.Length + 1, byrefArgs)); } public void EmitNullableCall(MethodInfo method, ParameterInfo[] parameters) { Emit(NullableMethodCallInstruction.Create(method.Name, parameters.Length, method)); } #endregion #region Control Flow private static readonly RuntimeLabel[] s_emptyRuntimeLabels = new RuntimeLabel[] { new RuntimeLabel(Interpreter.RethrowOnReturn, 0, 0) }; private RuntimeLabel[] BuildRuntimeLabels() { if (_runtimeLabelCount == 0) { return s_emptyRuntimeLabels; } var result = new RuntimeLabel[_runtimeLabelCount + 1]; foreach (BranchLabel label in _labels!) { if (label.HasRuntimeLabel) { result[label.LabelIndex] = label.ToRuntimeLabel(); } } // "return and rethrow" label: result[result.Length - 1] = new RuntimeLabel(Interpreter.RethrowOnReturn, 0, 0); return result; } public BranchLabel MakeLabel() { if (_labels == null) { _labels = new List<BranchLabel>(); } var label = new BranchLabel(); _labels.Add(label); return label; } internal void FixupBranch(int branchIndex, int offset) { _instructions[branchIndex] = ((OffsetInstruction)_instructions[branchIndex]).Fixup(offset); } private int EnsureLabelIndex(BranchLabel label) { if (label.HasRuntimeLabel) { return label.LabelIndex; } label.LabelIndex = _runtimeLabelCount; _runtimeLabelCount++; return label.LabelIndex; } public int MarkRuntimeLabel() { BranchLabel handlerLabel = MakeLabel(); MarkLabel(handlerLabel); return EnsureLabelIndex(handlerLabel); } public void MarkLabel(BranchLabel label) { label.Mark(this); } public void EmitGoto(BranchLabel label, bool hasResult, bool hasValue, bool labelTargetGetsValue) { Emit(GotoInstruction.Create(EnsureLabelIndex(label), hasResult, hasValue, labelTargetGetsValue)); } private void EmitBranch(OffsetInstruction instruction, BranchLabel label) { Emit(instruction); label.AddBranch(this, Count - 1); } public void EmitBranch(BranchLabel label) { EmitBranch(new BranchInstruction(), label); } public void EmitBranch(BranchLabel label, bool hasResult, bool hasValue) { EmitBranch(new BranchInstruction(hasResult, hasValue), label); } public void EmitCoalescingBranch(BranchLabel leftNotNull) { EmitBranch(new CoalescingBranchInstruction(), leftNotNull); } public void EmitBranchTrue(BranchLabel elseLabel) { EmitBranch(new BranchTrueInstruction(), elseLabel); } public void EmitBranchFalse(BranchLabel elseLabel) { EmitBranch(new BranchFalseInstruction(), elseLabel); } public void EmitThrow() { Emit(ThrowInstruction.Throw); } public void EmitThrowVoid() { Emit(ThrowInstruction.VoidThrow); } public void EmitRethrow() { Emit(ThrowInstruction.Rethrow); } public void EmitRethrowVoid() { Emit(ThrowInstruction.VoidRethrow); } public void EmitEnterTryFinally(BranchLabel finallyStartLabel) { Emit(EnterTryCatchFinallyInstruction.CreateTryFinally(EnsureLabelIndex(finallyStartLabel))); } public void EmitEnterTryCatch() { Emit(EnterTryCatchFinallyInstruction.CreateTryCatch()); } public EnterTryFaultInstruction EmitEnterTryFault(BranchLabel tryEnd) { var instruction = new EnterTryFaultInstruction(EnsureLabelIndex(tryEnd)); Emit(instruction); return instruction; } public void EmitEnterFinally(BranchLabel finallyStartLabel) { Emit(EnterFinallyInstruction.Create(EnsureLabelIndex(finallyStartLabel))); } public void EmitLeaveFinally() { Emit(LeaveFinallyInstruction.Instance); } public void EmitEnterFault(BranchLabel faultStartLabel) { Emit(EnterFaultInstruction.Create(EnsureLabelIndex(faultStartLabel))); } public void EmitLeaveFault() { Emit(LeaveFaultInstruction.Instance); } public void EmitEnterExceptionFilter() { Emit(EnterExceptionFilterInstruction.Instance); } public void EmitLeaveExceptionFilter() { Emit(LeaveExceptionFilterInstruction.Instance); } public void EmitEnterExceptionHandlerNonVoid() { Emit(EnterExceptionHandlerInstruction.NonVoid); } public void EmitEnterExceptionHandlerVoid() { Emit(EnterExceptionHandlerInstruction.Void); } public void EmitLeaveExceptionHandler(bool hasValue, BranchLabel tryExpressionEndLabel) { Emit(LeaveExceptionHandlerInstruction.Create(EnsureLabelIndex(tryExpressionEndLabel), hasValue)); } public void EmitIntSwitch<T>(Dictionary<T, int> cases) where T : notnull { Emit(new IntSwitchInstruction<T>(cases)); } public void EmitStringSwitch(Dictionary<string, int> cases, StrongBox<int> nullCase) { Emit(new StringSwitchInstruction(cases, nullCase)); } #endregion } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Private.Xml.Linq/tests/XPath/XDocument/XDocumentXPathTest.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using XPathTests.Common; namespace XPathTests.Common { public static partial class Utils { private static readonly ICreateNavigator _navigatorCreator = new CreateNavigatorComparer(); public static readonly string ResourceFilesPath = "System.Xml.XPath.XDocument.Tests.TestData."; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using XPathTests.Common; namespace XPathTests.Common { public static partial class Utils { private static readonly ICreateNavigator _navigatorCreator = new CreateNavigatorComparer(); public static readonly string ResourceFilesPath = "System.Xml.XPath.XDocument.Tests.TestData."; } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /* * Ordered String/String[] collection of name/value pairs with support for null key * Wraps NameObject collection * */ using System.Diagnostics; using System.Runtime.Serialization; using System.Text; namespace System.Collections.Specialized { /// <devdoc> /// <para>Represents a sorted collection of associated <see cref='string' qualify='true'/> keys and <see cref='string' qualify='true'/> values that /// can be accessed either with the hash code of the key or with the index.</para> /// </devdoc> public class NameValueCollection : NameObjectCollectionBase { private string?[]? _all; // Do not rename (binary serialization) private string?[]? _allKeys; // Do not rename (binary serialization) // // Constructors // /// <devdoc> /// <para>Creates an empty <see cref='System.Collections.Specialized.NameValueCollection'/> with the default initial capacity /// and using the default case-insensitive hash code provider and the default /// case-insensitive comparer.</para> /// </devdoc> public NameValueCollection() : base() { } /// <devdoc> /// <para>Copies the entries from the specified <see cref='System.Collections.Specialized.NameValueCollection'/> to a new <see cref='System.Collections.Specialized.NameValueCollection'/> with the same initial capacity as /// the number of entries copied and using the default case-insensitive hash code /// provider and the default case-insensitive comparer.</para> /// </devdoc> public NameValueCollection(NameValueCollection col) : base(col != null ? col.Comparer : null) { Add(col!); } [Obsolete("This constructor has been deprecated. Use NameValueCollection(IEqualityComparer) instead.")] public NameValueCollection(IHashCodeProvider? hashProvider, IComparer? comparer) : base(hashProvider, comparer) { } /// <devdoc> /// <para>Creates an empty <see cref='System.Collections.Specialized.NameValueCollection'/> with /// the specified initial capacity and using the default case-insensitive hash code /// provider and the default case-insensitive comparer.</para> /// </devdoc> public NameValueCollection(int capacity) : base(capacity) { } public NameValueCollection(IEqualityComparer? equalityComparer) : base(equalityComparer) { } public NameValueCollection(int capacity, IEqualityComparer? equalityComparer) : base(capacity, equalityComparer) { } /// <devdoc> /// <para>Copies the entries from the specified <see cref='System.Collections.Specialized.NameValueCollection'/> to a new <see cref='System.Collections.Specialized.NameValueCollection'/> with the specified initial capacity or the /// same initial capacity as the number of entries copied, whichever is greater, and /// using the default case-insensitive hash code provider and the default /// case-insensitive comparer.</para> /// </devdoc> public NameValueCollection(int capacity, NameValueCollection col!!) : base(capacity, col.Comparer) { this.Comparer = col.Comparer; Add(col); } [Obsolete("This constructor has been deprecated. Use NameValueCollection(Int32, IEqualityComparer) instead.")] public NameValueCollection(int capacity, IHashCodeProvider? hashProvider, IComparer? comparer) : base(capacity, hashProvider, comparer) { } protected NameValueCollection(SerializationInfo info, StreamingContext context) : base(info, context) { } // // Helper methods // /// <devdoc> /// <para> Resets the cached arrays of the collection to <see langword='null'/>.</para> /// </devdoc> protected void InvalidateCachedArrays() { _all = null; _allKeys = null; } private static string? GetAsOneString(ArrayList? list) { int n = (list != null) ? list.Count : 0; if (n == 1) { Debug.Assert(list != null); return (string?)list[0]; } else if (n > 1) { Debug.Assert(list != null); StringBuilder s = new StringBuilder((string?)list[0]); for (int i = 1; i < n; i++) { s.Append(','); s.Append((string?)list[i]); } return s.ToString(); } else { return null; } } private static string[]? GetAsStringArray(ArrayList? list) { int n = (list != null) ? list.Count : 0; if (n == 0) return null; string[] array = new string[n]; list!.CopyTo(0, array, 0, n); return array; } // // Misc public APIs // /// <devdoc> /// <para>Copies the entries in the specified <see cref='System.Collections.Specialized.NameValueCollection'/> to the current <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public void Add(NameValueCollection c!!) { InvalidateCachedArrays(); int n = c.Count; for (int i = 0; i < n; i++) { string? key = c.GetKey(i); string[]? values = c.GetValues(i); if (values != null) { for (int j = 0; j < values.Length; j++) Add(key, values[j]); } else { Add(key, null); } } } /// <devdoc> /// <para>Invalidates the cached arrays and removes all entries /// from the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual void Clear() { if (IsReadOnly) throw new NotSupportedException(SR.CollectionReadOnly); InvalidateCachedArrays(); BaseClear(); } public void CopyTo(Array dest!!, int index) { if (dest.Rank != 1) { throw new ArgumentException(SR.Arg_MultiRank, nameof(dest)); } if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_NeedNonNegNum_Index); } if (dest.Length - index < Count) { throw new ArgumentException(SR.Arg_InsufficientSpace); } int n = Count; if (_all == null) { string?[] all = new string[n]; for (int i = 0; i < n; i++) { all[i] = Get(i); dest.SetValue(all[i], i + index); } _all = all; // wait until end of loop to set _all reference in case Get throws } else { for (int i = 0; i < n; i++) { dest.SetValue(_all[i], i + index); } } } /// <devdoc> /// <para>Gets a value indicating whether the <see cref='System.Collections.Specialized.NameValueCollection'/> contains entries whose keys are not <see langword='null'/>.</para> /// </devdoc> public bool HasKeys() { return InternalHasKeys(); } /// <devdoc> /// <para>Allows derived classes to alter HasKeys().</para> /// </devdoc> internal virtual bool InternalHasKeys() { return BaseHasKeys(); } // // Access by name // /// <devdoc> /// <para>Adds an entry with the specified name and value into the /// <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual void Add(string? name, string? value) { if (IsReadOnly) throw new NotSupportedException(SR.CollectionReadOnly); InvalidateCachedArrays(); ArrayList? values = (ArrayList?)BaseGet(name); if (values == null) { // new key - add new key with single value values = new ArrayList(1); if (value != null) values.Add(value); BaseAdd(name, values); } else { // old key -- append value to the list of values if (value != null) values.Add(value); } } /// <devdoc> /// <para> Gets the values associated with the specified key from the <see cref='System.Collections.Specialized.NameValueCollection'/> combined into one comma-separated list.</para> /// </devdoc> public virtual string? Get(string? name) { ArrayList? values = (ArrayList?)BaseGet(name); return GetAsOneString(values); } /// <devdoc> /// <para>Gets the values associated with the specified key from the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual string[]? GetValues(string? name) { ArrayList? values = (ArrayList?)BaseGet(name); return GetAsStringArray(values); } /// <devdoc> /// <para>Adds a value to an entry in the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual void Set(string? name, string? value) { if (IsReadOnly) throw new NotSupportedException(SR.CollectionReadOnly); InvalidateCachedArrays(); ArrayList values = new ArrayList(1); values.Add(value); BaseSet(name, values); } /// <devdoc> /// <para>Removes the entries with the specified key from the <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para> /// </devdoc> public virtual void Remove(string? name) { InvalidateCachedArrays(); BaseRemove(name); } /// <devdoc> /// <para> Represents the entry with the specified key in the /// <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public string? this[string? name] { get { return Get(name); } set { Set(name, value); } } // // Indexed access // /// <devdoc> /// <para> /// Gets the values at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/> combined into one /// comma-separated list.</para> /// </devdoc> public virtual string? Get(int index) { ArrayList? values = (ArrayList?)BaseGet(index); return GetAsOneString(values); } /// <devdoc> /// <para> Gets the values at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual string[]? GetValues(int index) { ArrayList? values = (ArrayList?)BaseGet(index); return GetAsStringArray(values); } /// <devdoc> /// <para>Gets the key at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual string? GetKey(int index) { return BaseGetKey(index); } /// <devdoc> /// <para>Represents the entry at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public string? this[int index] { get { return Get(index); } } // // Access to keys and values as arrays // /// <devdoc> /// <para>Gets all the keys in the <see cref='System.Collections.Specialized.NameValueCollection'/>. </para> /// </devdoc> public virtual string?[] AllKeys { get { if (_allKeys == null) _allKeys = BaseGetAllKeys(); return _allKeys; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /* * Ordered String/String[] collection of name/value pairs with support for null key * Wraps NameObject collection * */ using System.Diagnostics; using System.Runtime.Serialization; using System.Text; namespace System.Collections.Specialized { /// <devdoc> /// <para>Represents a sorted collection of associated <see cref='string' qualify='true'/> keys and <see cref='string' qualify='true'/> values that /// can be accessed either with the hash code of the key or with the index.</para> /// </devdoc> public class NameValueCollection : NameObjectCollectionBase { private string?[]? _all; // Do not rename (binary serialization) private string?[]? _allKeys; // Do not rename (binary serialization) // // Constructors // /// <devdoc> /// <para>Creates an empty <see cref='System.Collections.Specialized.NameValueCollection'/> with the default initial capacity /// and using the default case-insensitive hash code provider and the default /// case-insensitive comparer.</para> /// </devdoc> public NameValueCollection() : base() { } /// <devdoc> /// <para>Copies the entries from the specified <see cref='System.Collections.Specialized.NameValueCollection'/> to a new <see cref='System.Collections.Specialized.NameValueCollection'/> with the same initial capacity as /// the number of entries copied and using the default case-insensitive hash code /// provider and the default case-insensitive comparer.</para> /// </devdoc> public NameValueCollection(NameValueCollection col) : base(col != null ? col.Comparer : null) { Add(col!); } [Obsolete("This constructor has been deprecated. Use NameValueCollection(IEqualityComparer) instead.")] public NameValueCollection(IHashCodeProvider? hashProvider, IComparer? comparer) : base(hashProvider, comparer) { } /// <devdoc> /// <para>Creates an empty <see cref='System.Collections.Specialized.NameValueCollection'/> with /// the specified initial capacity and using the default case-insensitive hash code /// provider and the default case-insensitive comparer.</para> /// </devdoc> public NameValueCollection(int capacity) : base(capacity) { } public NameValueCollection(IEqualityComparer? equalityComparer) : base(equalityComparer) { } public NameValueCollection(int capacity, IEqualityComparer? equalityComparer) : base(capacity, equalityComparer) { } /// <devdoc> /// <para>Copies the entries from the specified <see cref='System.Collections.Specialized.NameValueCollection'/> to a new <see cref='System.Collections.Specialized.NameValueCollection'/> with the specified initial capacity or the /// same initial capacity as the number of entries copied, whichever is greater, and /// using the default case-insensitive hash code provider and the default /// case-insensitive comparer.</para> /// </devdoc> public NameValueCollection(int capacity, NameValueCollection col!!) : base(capacity, col.Comparer) { this.Comparer = col.Comparer; Add(col); } [Obsolete("This constructor has been deprecated. Use NameValueCollection(Int32, IEqualityComparer) instead.")] public NameValueCollection(int capacity, IHashCodeProvider? hashProvider, IComparer? comparer) : base(capacity, hashProvider, comparer) { } protected NameValueCollection(SerializationInfo info, StreamingContext context) : base(info, context) { } // // Helper methods // /// <devdoc> /// <para> Resets the cached arrays of the collection to <see langword='null'/>.</para> /// </devdoc> protected void InvalidateCachedArrays() { _all = null; _allKeys = null; } private static string? GetAsOneString(ArrayList? list) { int n = (list != null) ? list.Count : 0; if (n == 1) { Debug.Assert(list != null); return (string?)list[0]; } else if (n > 1) { Debug.Assert(list != null); StringBuilder s = new StringBuilder((string?)list[0]); for (int i = 1; i < n; i++) { s.Append(','); s.Append((string?)list[i]); } return s.ToString(); } else { return null; } } private static string[]? GetAsStringArray(ArrayList? list) { int n = (list != null) ? list.Count : 0; if (n == 0) return null; string[] array = new string[n]; list!.CopyTo(0, array, 0, n); return array; } // // Misc public APIs // /// <devdoc> /// <para>Copies the entries in the specified <see cref='System.Collections.Specialized.NameValueCollection'/> to the current <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public void Add(NameValueCollection c!!) { InvalidateCachedArrays(); int n = c.Count; for (int i = 0; i < n; i++) { string? key = c.GetKey(i); string[]? values = c.GetValues(i); if (values != null) { for (int j = 0; j < values.Length; j++) Add(key, values[j]); } else { Add(key, null); } } } /// <devdoc> /// <para>Invalidates the cached arrays and removes all entries /// from the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual void Clear() { if (IsReadOnly) throw new NotSupportedException(SR.CollectionReadOnly); InvalidateCachedArrays(); BaseClear(); } public void CopyTo(Array dest!!, int index) { if (dest.Rank != 1) { throw new ArgumentException(SR.Arg_MultiRank, nameof(dest)); } if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_NeedNonNegNum_Index); } if (dest.Length - index < Count) { throw new ArgumentException(SR.Arg_InsufficientSpace); } int n = Count; if (_all == null) { string?[] all = new string[n]; for (int i = 0; i < n; i++) { all[i] = Get(i); dest.SetValue(all[i], i + index); } _all = all; // wait until end of loop to set _all reference in case Get throws } else { for (int i = 0; i < n; i++) { dest.SetValue(_all[i], i + index); } } } /// <devdoc> /// <para>Gets a value indicating whether the <see cref='System.Collections.Specialized.NameValueCollection'/> contains entries whose keys are not <see langword='null'/>.</para> /// </devdoc> public bool HasKeys() { return InternalHasKeys(); } /// <devdoc> /// <para>Allows derived classes to alter HasKeys().</para> /// </devdoc> internal virtual bool InternalHasKeys() { return BaseHasKeys(); } // // Access by name // /// <devdoc> /// <para>Adds an entry with the specified name and value into the /// <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual void Add(string? name, string? value) { if (IsReadOnly) throw new NotSupportedException(SR.CollectionReadOnly); InvalidateCachedArrays(); ArrayList? values = (ArrayList?)BaseGet(name); if (values == null) { // new key - add new key with single value values = new ArrayList(1); if (value != null) values.Add(value); BaseAdd(name, values); } else { // old key -- append value to the list of values if (value != null) values.Add(value); } } /// <devdoc> /// <para> Gets the values associated with the specified key from the <see cref='System.Collections.Specialized.NameValueCollection'/> combined into one comma-separated list.</para> /// </devdoc> public virtual string? Get(string? name) { ArrayList? values = (ArrayList?)BaseGet(name); return GetAsOneString(values); } /// <devdoc> /// <para>Gets the values associated with the specified key from the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual string[]? GetValues(string? name) { ArrayList? values = (ArrayList?)BaseGet(name); return GetAsStringArray(values); } /// <devdoc> /// <para>Adds a value to an entry in the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual void Set(string? name, string? value) { if (IsReadOnly) throw new NotSupportedException(SR.CollectionReadOnly); InvalidateCachedArrays(); ArrayList values = new ArrayList(1); values.Add(value); BaseSet(name, values); } /// <devdoc> /// <para>Removes the entries with the specified key from the <see cref='System.Collections.Specialized.NameObjectCollectionBase'/> instance.</para> /// </devdoc> public virtual void Remove(string? name) { InvalidateCachedArrays(); BaseRemove(name); } /// <devdoc> /// <para> Represents the entry with the specified key in the /// <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public string? this[string? name] { get { return Get(name); } set { Set(name, value); } } // // Indexed access // /// <devdoc> /// <para> /// Gets the values at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/> combined into one /// comma-separated list.</para> /// </devdoc> public virtual string? Get(int index) { ArrayList? values = (ArrayList?)BaseGet(index); return GetAsOneString(values); } /// <devdoc> /// <para> Gets the values at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual string[]? GetValues(int index) { ArrayList? values = (ArrayList?)BaseGet(index); return GetAsStringArray(values); } /// <devdoc> /// <para>Gets the key at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public virtual string? GetKey(int index) { return BaseGetKey(index); } /// <devdoc> /// <para>Represents the entry at the specified index of the <see cref='System.Collections.Specialized.NameValueCollection'/>.</para> /// </devdoc> public string? this[int index] { get { return Get(index); } } // // Access to keys and values as arrays // /// <devdoc> /// <para>Gets all the keys in the <see cref='System.Collections.Specialized.NameValueCollection'/>. </para> /// </devdoc> public virtual string?[] AllKeys { get { if (_allKeys == null) _allKeys = BaseGetAllKeys(); return _allKeys; } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b66620/b66620.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // ctor_merge2.il // // NEGATIVE // merge of instance and static method .assembly extern mscorlib { } .assembly extern System.Console { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:0:0:0 } .assembly 'b66620' { } .assembly extern xunit.core {} .class public auto ansi beforefieldinit TestClass extends [mscorlib]System.Object { .field private static bool _sel .field private bool dummy .method public hidebysig static void DelegateFunc1(int32) il managed { .maxstack 3 IL_0000: ldstr "DelegateFunc1" IL_0005: call void [System.Console]System.Console::WriteLine(class System.String) IL_001a: ret } .method public hidebysig instance void DelegateFunc2(int32) il managed { .maxstack 8 .locals (int32[] V_0) ldarg.0 castclass [mscorlib]System.Object pop IL_0000: ldstr "DelegateFunc2" IL_0005: call void [System.Console]System.Console::WriteLine(class System.String) IL_000f: ret } .method private hidebysig static bool sel() il managed { .maxstack 2 .locals (bool V_0) IL_0000: ldsfld bool TestClass::_sel IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stsfld bool TestClass::_sel IL_000d: ldsfld bool TestClass::_sel IL_0012: stloc.0 IL_0013: br.s IL_0015 IL_0015: ldloc.0 IL_0016: ret } .method public hidebysig static int32 Main(class System.String[] args) il managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .maxstack 8 newobj instance void TestClass::.ctor() ldc.i4.1 dup brfalse.s BRANCH ldftn instance void TestClass::DelegateFunc2(int32) pop pop br.s MERGE BRANCH: pop ldftn void TestClass::DelegateFunc1(int32) pop MERGE: pop ldc.i4 100 ret } .method private hidebysig specialname rtspecialname static void .cctor() il managed { .maxstack 8 IL_0000: ldc.i4.0 IL_0001: stsfld bool TestClass::_sel IL_0006: ret } .method public hidebysig specialname rtspecialname instance void .ctor() il managed { .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ret } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // ctor_merge2.il // // NEGATIVE // merge of instance and static method .assembly extern mscorlib { } .assembly extern System.Console { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:0:0:0 } .assembly 'b66620' { } .assembly extern xunit.core {} .class public auto ansi beforefieldinit TestClass extends [mscorlib]System.Object { .field private static bool _sel .field private bool dummy .method public hidebysig static void DelegateFunc1(int32) il managed { .maxstack 3 IL_0000: ldstr "DelegateFunc1" IL_0005: call void [System.Console]System.Console::WriteLine(class System.String) IL_001a: ret } .method public hidebysig instance void DelegateFunc2(int32) il managed { .maxstack 8 .locals (int32[] V_0) ldarg.0 castclass [mscorlib]System.Object pop IL_0000: ldstr "DelegateFunc2" IL_0005: call void [System.Console]System.Console::WriteLine(class System.String) IL_000f: ret } .method private hidebysig static bool sel() il managed { .maxstack 2 .locals (bool V_0) IL_0000: ldsfld bool TestClass::_sel IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stsfld bool TestClass::_sel IL_000d: ldsfld bool TestClass::_sel IL_0012: stloc.0 IL_0013: br.s IL_0015 IL_0015: ldloc.0 IL_0016: ret } .method public hidebysig static int32 Main(class System.String[] args) il managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .maxstack 8 newobj instance void TestClass::.ctor() ldc.i4.1 dup brfalse.s BRANCH ldftn instance void TestClass::DelegateFunc2(int32) pop pop br.s MERGE BRANCH: pop ldftn void TestClass::DelegateFunc1(int32) pop MERGE: pop ldc.i4 100 ret } .method private hidebysig specialname rtspecialname static void .cctor() il managed { .maxstack 8 IL_0000: ldc.i4.0 IL_0001: stsfld bool TestClass::_sel IL_0006: ret } .method public hidebysig specialname rtspecialname instance void .ctor() il managed { .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ret } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest966/Generated966.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated966.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated966.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/Asn1/TbsCertificateAsn.manual.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; using System.Security.Cryptography.Asn1; namespace System.Security.Cryptography.X509Certificates.Asn1 { // https://tools.ietf.org/html/rfc5280#section-4.1 // // TBSCertificate ::= SEQUENCE { // version [0] Version DEFAULT v1, // serialNumber CertificateSerialNumber, // signature AlgorithmIdentifier, // issuer Name, // validity Validity, // subject Name, // subjectPublicKeyInfo SubjectPublicKeyInfo, // issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, // -- If present, version MUST be v2 or v3 // subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, // -- If present, version MUST be v2 or v3 // extensions [3] Extensions OPTIONAL // -- If present, version MUST be v3 -- // } internal partial struct TbsCertificateAsn { /// <summary> /// Validate semantics by the specified version. /// </summary> public void ValidateVersion() { if (Version < 0 || Version > 2) { throw new CryptographicException(); } if (Version < 1) { if (IssuerUniqueId.HasValue || SubjectUniqueId.HasValue) { throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding); } } if (Version < 2) { if (Extensions != null) { throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding); } } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.InteropServices; using System.Security.Cryptography.Asn1; namespace System.Security.Cryptography.X509Certificates.Asn1 { // https://tools.ietf.org/html/rfc5280#section-4.1 // // TBSCertificate ::= SEQUENCE { // version [0] Version DEFAULT v1, // serialNumber CertificateSerialNumber, // signature AlgorithmIdentifier, // issuer Name, // validity Validity, // subject Name, // subjectPublicKeyInfo SubjectPublicKeyInfo, // issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, // -- If present, version MUST be v2 or v3 // subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, // -- If present, version MUST be v2 or v3 // extensions [3] Extensions OPTIONAL // -- If present, version MUST be v3 -- // } internal partial struct TbsCertificateAsn { /// <summary> /// Validate semantics by the specified version. /// </summary> public void ValidateVersion() { if (Version < 0 || Version > 2) { throw new CryptographicException(); } if (Version < 1) { if (IssuerUniqueId.HasValue || SubjectUniqueId.HasValue) { throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding); } } if (Version < 2) { if (Extensions != null) { throw new CryptographicException(SR.Cryptography_Der_Invalid_Encoding); } } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/KeyValueConfigurationCollection.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Configuration { [ConfigurationCollection(typeof(KeyValueConfigurationElement))] public class KeyValueConfigurationCollection : ConfigurationElementCollection { private static readonly ConfigurationPropertyCollection s_properties = new ConfigurationPropertyCollection(); public KeyValueConfigurationCollection() : base(StringComparer.OrdinalIgnoreCase) { InternalAddToEnd = true; } protected internal override ConfigurationPropertyCollection Properties => s_properties; protected override bool ThrowOnDuplicate => false; public new KeyValueConfigurationElement this[string key] => (KeyValueConfigurationElement)BaseGet(key); public string[] AllKeys => StringUtil.ObjectArrayToStringArray(BaseGetAllKeys()); public void Add(KeyValueConfigurationElement keyValue) { // Need to initialize in order to get the key keyValue.Init(); // the appsettings add works more like a namevalue collection add in that it appends values // when add is called and teh key already exists. KeyValueConfigurationElement oldValue = (KeyValueConfigurationElement)BaseGet(keyValue.Key); if (oldValue == null) { BaseAdd(keyValue); } else { oldValue.Value += "," + keyValue.Value; int index = BaseIndexOf(oldValue); BaseRemoveAt(index); BaseAdd(index, oldValue); } } public void Add(string key, string value) { KeyValueConfigurationElement element = new KeyValueConfigurationElement(key, value); Add(element); } public void Remove(string key) { BaseRemove(key); } public void Clear() { BaseClear(); } protected override ConfigurationElement CreateNewElement() { return new KeyValueConfigurationElement(); } protected override object GetElementKey(ConfigurationElement element) { return ((KeyValueConfigurationElement)element).Key; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Configuration { [ConfigurationCollection(typeof(KeyValueConfigurationElement))] public class KeyValueConfigurationCollection : ConfigurationElementCollection { private static readonly ConfigurationPropertyCollection s_properties = new ConfigurationPropertyCollection(); public KeyValueConfigurationCollection() : base(StringComparer.OrdinalIgnoreCase) { InternalAddToEnd = true; } protected internal override ConfigurationPropertyCollection Properties => s_properties; protected override bool ThrowOnDuplicate => false; public new KeyValueConfigurationElement this[string key] => (KeyValueConfigurationElement)BaseGet(key); public string[] AllKeys => StringUtil.ObjectArrayToStringArray(BaseGetAllKeys()); public void Add(KeyValueConfigurationElement keyValue) { // Need to initialize in order to get the key keyValue.Init(); // the appsettings add works more like a namevalue collection add in that it appends values // when add is called and teh key already exists. KeyValueConfigurationElement oldValue = (KeyValueConfigurationElement)BaseGet(keyValue.Key); if (oldValue == null) { BaseAdd(keyValue); } else { oldValue.Value += "," + keyValue.Value; int index = BaseIndexOf(oldValue); BaseRemoveAt(index); BaseAdd(index, oldValue); } } public void Add(string key, string value) { KeyValueConfigurationElement element = new KeyValueConfigurationElement(key, value); Add(element); } public void Remove(string key) { BaseRemove(key); } public void Clear() { BaseClear(); } protected override ConfigurationElement CreateNewElement() { return new KeyValueConfigurationElement(); } protected override object GetElementKey(ConfigurationElement element) { return ((KeyValueConfigurationElement)element).Key; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Loader/classloader/MethodImpl/CovariantReturns/Interfaces/UnitTest.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern System.Console { } .assembly extern xunit.core {} .assembly extern System.Runtime { } .assembly extern mscorlib { } .assembly UnitTest { } // ======================================================================================== // Types that will be used as return types on the various methods // ======================================================================================== .class interface public auto ansi abstract IUnused1 { } .class interface public auto ansi abstract IUnused2 { } .class interface public auto ansi abstract IA implements IUnused1, IUnused2 { } .class interface public auto ansi abstract IB implements IUnused1, IUnused2, IA { } .class interface public auto ansi abstract IC implements IUnused1, IUnused2, IB { } .class interface public auto ansi abstract IGenRetType<X,Y> { } .class interface public auto ansi abstract IDictionary<KEY,VAL> { } .class public auto ansi abstract CA {} .class public auto ansi abstract CB extends CA {} .class public auto ansi abstract CC extends CB {} .class interface public auto ansi abstract ICovariant<+ T> { } .class interface public auto ansi abstract IContravariant<- T> { } .class interface public auto ansi abstract IGenDerive1<V1,V2> implements IUnused1, IUnused2, class IGenRetType<!V1,!V2> { } .class interface public auto ansi abstract IGenDerive2<U1,U2,U3> implements IUnused1, IUnused2, class IGenDerive1<!U1, class IDictionary<!U3,!U2>> { } .class interface public auto ansi abstract IGenDerive3<T1,T2> implements IUnused1, IUnused2, class IGenDerive2<!T1,!T2,string> { } .class interface public auto ansi abstract INonGenericDerived1<ARG1,ARG2> implements IUnused1, IUnused2, class IGenRetType<!ARG1,!ARG2> { } .class interface public auto ansi abstract INonGenericDerived2<T> implements IUnused1, IUnused2, class INonGenericDerived1<!T,object> { } .class interface public auto ansi abstract INonGenericDerived3 implements IUnused1, IUnused2, class INonGenericDerived2<int32> { } .class interface public auto ansi abstract INonGenericDerived4 implements IUnused1, IUnused2, INonGenericDerived3 { } .class interface public auto ansi abstract IGenToNonGen1<V1,V2> implements IUnused1, IUnused2, IC { } .class interface public auto ansi abstract IGenToNonGen2<U1,U2,U3> implements IUnused1, IUnused2, class IGenToNonGen1<!U1, class IDictionary<!U3,!U2>> { } .class interface public auto ansi abstract IGenToNonGen3<T1,T2> implements IUnused1, IUnused2, class IGenToNonGen2<!T1,!T2,string> { } .class interface public auto ansi abstract INonGenThroughGen1<V1,V2> implements IUnused1, IUnused2, IC { } .class interface public auto ansi abstract INonGenThroughGen2<U1,U2,U3> implements IUnused1, IUnused2, class INonGenThroughGen1<!U1, class IDictionary<!U3,!U2>> { } .class interface public auto ansi abstract INonGenThroughGen3 implements IUnused1, IUnused2, class INonGenThroughGen2<object,int32,string> { } .class interface public auto ansi abstract INonGenThroughGen4 implements IUnused1, IUnused2, INonGenThroughGen3 { } // class implementing the interfaces .class public auto ansi beforefieldinit NonGenThroughGen4 implements IUnused1, IUnused2, INonGenThroughGen4 { } .class public auto ansi beforefieldinit GenToNonGen3<T1,T2> implements IUnused1, IUnused2, class IGenToNonGen3<!T1,!T2> { } .class public auto ansi beforefieldinit NonGenericDerived4 implements IUnused1, IUnused2, INonGenericDerived4 { } .class public auto ansi beforefieldinit GenDerive3<T1,T2> implements IUnused1, IUnused2, class IGenDerive3<!T1,!T2> { } .class public auto ansi beforefieldinit C implements IUnused1, IUnused2, IC { } .class public auto ansi beforefieldinit GenRetType<X,Y> implements IUnused1, IUnused2, class IGenRetType<!X,!Y> { } .class public auto ansi beforefieldinit Base<T> {} .class public auto ansi beforefieldinit Derived extends class Base<class Derived> {} .class public auto ansi beforefieldinit Derived2 extends class Base<class Derived2> {} .class interface public auto ansi abstract IVariant<+ V> { .method public hidebysig newslot virtual instance void Test() { ret } } // ======================================================================================== // Main base type with various virtual methods that will be overriden later // ======================================================================================== .class public auto ansi beforefieldinit GenBaseType<A,B> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance object MyFunc(string& res) { ldarg.1 ldstr "object GenBaseType.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IB MyFunc(string& res) { ldarg.1 ldstr "IB GenBaseType.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class ICovariant<class CB> MyFuncCovariant(string& res) { ldarg.1 ldstr "ICovariant<CB> GenBaseType.MyFuncCovariant()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IContravariant<class CB> MyFuncContravariant(string& res) { ldarg.1 ldstr "IContravariant<CB> GenBaseType.MyFuncContravariant()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IB GenToNonGen(string& res) { ldarg.1 ldstr "IB GenBaseType.GenToNonGen()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IB NonGenThroughGenFunc(string& res) { ldarg.1 ldstr "IB GenBaseType.NonGenThroughGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenRetType<int32,object> MyGenFunc(string& res) { ldarg.1 ldstr "IGenRetType<int32,object> GenBaseType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenRetType<!A, class IDictionary<string,!B>> MyGenFunc(string& res) { ldarg.1 ldstr "IGenRetType<!A, class IDictionary<string,!B>> GenBaseType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IVariant<class Base<class Derived>> MultiLevelGenericVariantFunc(string&) { ldarg.1 ldstr "IVariant<class Base<class Derived>> GenBaseType.MultiLevelGenericVariantFunc()" stind.ref ldnull ret } } // ======================================================================================== // SECOND LAYER type: overrides *SOME* virtuals on GenBaseType using MethodImpls with // covariant return types (more derived return types) // ======================================================================================== .class public auto ansi beforefieldinit GenMiddleType<U,V> extends class GenBaseType<!V,!U> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class INonGenThroughGen2<object,int32,string> NonGenThroughGenFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IB class GenBaseType<!V,!U>::NonGenThroughGenFunc(string& res) ldarg.1 ldstr "INonGenThroughGen2<object,int32,string> GenMiddleType.NonGenThroughGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenToNonGen1<!V, class IDictionary<string,object>> GenToNonGen(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IB class GenBaseType<!V,!U>::GenToNonGen(string& res) ldarg.1 ldstr "IGenToNonGen1<!V, class IDictionary<string,object>> GenMiddleType.GenToNonGen()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class INonGenericDerived1<int32,object> MyGenFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IGenRetType<int32,object> class GenBaseType<!V,!U>::MyGenFunc(string& res) ldarg.1 ldstr "INonGenericDerived1<int32,object> GenMiddleType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenDerive1<!V, class IDictionary<string,!U>> MyGenFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<!V,!U>::MyGenFunc(string& res) ldarg.1 ldstr "IGenDerive1<!U, class IDictionary<string,!V>> GenMiddleType.MyGenFunc()" stind.ref ldnull ret } } // ======================================================================================== // THIRD LAYER type: overrides all virtuals from GenBaseType using MethodImpls with // covariant return types (more derived return types than the ones used in GenMiddleType) // ======================================================================================== .class public auto ansi beforefieldinit GenTestType<UNUSED1,UNUSED2,U,V> extends class GenMiddleType<!V,!U> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class INonGenThroughGen4 NonGenThroughGenFunc(string& res) { .override method instance class IB class GenBaseType<!U,!V>::NonGenThroughGenFunc(string& res) ldarg.1 ldstr "INonGenThroughGen4 TestType.NonGenThroughGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenToNonGen3<!U,object> GenToNonGen(string& res) { .override method instance class IB class GenBaseType<!U,!V>::GenToNonGen(string& res) ldarg.1 ldstr "IGenToNonGen3<!U,object> TestType.GenToNonGen()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class INonGenericDerived4 MyGenFunc(string& res) { .override method instance class IGenRetType<int32,object> class GenBaseType<!U,!V>::MyGenFunc(string& res) ldarg.1 ldstr "INonGenericDerived4 TestType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenDerive3<!U,!V> MyGenFunc(string& res) { .override method instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<!U,!V>::MyGenFunc(string& res) ldarg.1 ldstr "IGenDerive3<!U,!V> TestType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenRetType<!U,!V> MyFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance object class GenBaseType<!U,!V>::MyFunc(string& res) ldarg.1 ldstr "IGenRetType<!U,!V> TestType.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IC MyFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IB class GenBaseType<!U,!V>::MyFunc(string& res) ldarg.1 ldstr "IC TestType.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class ICovariant<class CC> MyFuncCovariant(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class ICovariant<class CB> class GenBaseType<!U,!V>::MyFuncCovariant(string& res) ldarg.1 ldstr "ICovariant<CC> TestType.MyFuncCovariant()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IContravariant<class CA> MyFuncContravariant(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IContravariant<class CB> class GenBaseType<!U,!V>::MyFuncContravariant(string& res) ldarg.1 ldstr "IContravariant<CA> TestType.MyFuncContravariant()" stind.ref ldnull ret } // ======================================================================================== // Set of implicit overrides that should be ignored given there are explicit overrides from the MethodImpls // ======================================================================================== .method public hidebysig virtual instance class IB NonGenThroughGenFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IB GenToNonGen(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IGenRetType<int32,object> MyGenFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IGenRetType<!0, class IDictionary<string,!1>> MyGenFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance object MyFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IB MyFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class ICovariant<class CB> MyFuncCovariant(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IContravariant<class CB> MyFuncContravariant(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } } // ======================================================================================== // FOURTH LAYER type: overrides all virtuals from GenBaseType using MethodImpls with // covariant return types (classes that implement the interfaces used as return types) // ======================================================================================== .class public auto ansi beforefieldinit GenMoreDerived<UNUSED1,UNUSED2,U,V> extends class GenTestType<!UNUSED2,!UNUSED1,!U,!V> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class NonGenThroughGen4 NonGenThroughGenFunc(string& res) { .override method instance class IB class GenBaseType<!U,!V>::NonGenThroughGenFunc(string& res) ldarg.1 ldstr "class NonGenThroughGen4 GenMoreDerived.NonGenThroughGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class GenToNonGen3<!U,object> GenToNonGen(string& res) { .override method instance class IB class GenBaseType<!U,!V>::GenToNonGen(string& res) ldarg.1 ldstr "class GenToNonGen3<!U,object> GenMoreDerived.GenToNonGen()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class NonGenericDerived4 MyGenFunc(string& res) { .override method instance class IGenRetType<int32,object> class GenBaseType<!U,!V>::MyGenFunc(string& res) ldarg.1 ldstr "class NonGenericDerived4 GenMoreDerived.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class GenDerive3<!U,!V> MyGenFunc(string& res) { .override method instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<!U,!V>::MyGenFunc(string& res) ldarg.1 ldstr "class GenDerive3<!U,!V> GenMoreDerived.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class GenRetType<!U,!V> MyFunc(string& res) { .override method instance object class GenBaseType<!U,!V>::MyFunc(string& res) ldarg.1 ldstr "class GenRetType<!U,!V> GenMoreDerived.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class C MyFunc(string& res) { .override method instance class IB class GenBaseType<!U,!V>::MyFunc(string& res) ldarg.1 ldstr "class C GenMoreDerived.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IVariant<class Derived> MultiLevelGenericVariantFunc(string&) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IVariant<class Base<class Derived>> class GenBaseType<!U,!V>::MultiLevelGenericVariantFunc(string&) ldarg.1 ldstr "class IVariant<class Derived> GenMoreDerived.MultiLevelGenericVariantFunc()" stind.ref ldnull ret } } // ======================================================================================== // FIFTH LAYER INVALID type: Used to verify we can't override the method using a compatible interface // if it has been already overridden using a class that implements the interface (i.e. the new // interface return type won't be compatible with the class return type on the previous override // ======================================================================================== .class public auto ansi beforefieldinit Invalid1<Q,W> extends class GenMoreDerived<!Q,!W,!Q,!W> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class INonGenThroughGen4 NonGenThroughGenFunc(string& res) { .override method instance class IB class GenBaseType<!Q,!W>::NonGenThroughGenFunc(string& res) ldnull ret } } // ======================================================================================== // FIFTH LAYER INVALID type: Used to verify we can't override the method using a less derived interface // than one that has already been used in a previous override // ======================================================================================== .class public auto ansi beforefieldinit Invalid2<Q,W> extends class GenTestType<!Q,!W,!Q,!W> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class INonGenThroughGen2<object,int32,string> NonGenThroughGenFunc(string& res) { .override method instance class IB class GenBaseType<!Q,!W>::NonGenThroughGenFunc(string& res) ldnull ret } } .class public auto ansi beforefieldinit Invalid3<Q,W> extends class GenTestType<!Q,!W,!Q,!W> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class IVariant<class Derived2> MultiLevelGenericVariantFunc(string&) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IVariant<class Base<class Derived>> class GenBaseType<!Q,!W>::MultiLevelGenericVariantFunc(string&) ldnull ret } } // ======================================================================================== .class public auto ansi beforefieldinit CMain extends [mscorlib]System.Object { .method private hidebysig static bool CheckResults ( string expected, string a, [opt] string b, [opt] string c, [opt] string d) cil managed { .param [3] = nullref .param [4] = nullref .param [5] = nullref // Method begins at RVA 0x20a0 // Code size 164 (0xa4) .maxstack 2 .locals /* 11000002 */ init ( [0] bool ) IL_0000: ldarg.1 IL_0001: ldarg.0 IL_0002: call bool [System.Runtime]System.String::op_Equality(string, string) /* 0A000012 */ IL_0007: stloc.0 IL_0008: ldstr "EXPECTED: " /* 70000001 */ IL_000d: ldarg.0 IL_000e: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_0013: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_0018: ldstr "ACTUAL1 : " /* 70000017 */ IL_001d: ldarg.1 IL_001e: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_0023: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_0028: ldarg.2 IL_0029: call bool [System.Runtime]System.String::IsNullOrEmpty(string) /* 0A000015 */ IL_002e: brtrue.s IL_004e IL_0030: ldstr "ACTUAL2 : " /* 7000002D */ IL_0035: ldarg.2 IL_0036: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_003b: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_0040: ldloc.0 IL_0041: brfalse.s IL_004c IL_0043: ldarg.2 IL_0044: ldarg.0 IL_0045: call bool [System.Runtime]System.String::op_Equality(string, string) /* 0A000012 */ IL_004a: br.s IL_004d IL_004c: ldc.i4.0 IL_004d: stloc.0 IL_004e: ldarg.3 IL_004f: call bool [System.Runtime]System.String::IsNullOrEmpty(string) /* 0A000015 */ IL_0054: brtrue.s IL_0074 IL_0056: ldstr "ACTUAL3 : " /* 70000043 */ IL_005b: ldarg.3 IL_005c: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_0061: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_0066: ldloc.0 IL_0067: brfalse.s IL_0072 IL_0069: ldarg.3 IL_006a: ldarg.0 IL_006b: call bool [System.Runtime]System.String::op_Equality(string, string) /* 0A000012 */ IL_0070: br.s IL_0073 IL_0072: ldc.i4.0 IL_0073: stloc.0 IL_0074: ldarg.s d IL_0076: call bool [System.Runtime]System.String::IsNullOrEmpty(string) /* 0A000015 */ IL_007b: brtrue.s IL_009d IL_007d: ldstr "ACTUAL4 : " /* 70000059 */ IL_0082: ldarg.s d IL_0084: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_0089: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_008e: ldloc.0 IL_008f: brfalse.s IL_009b IL_0091: ldarg.s d IL_0093: ldarg.0 IL_0094: call bool [System.Runtime]System.String::op_Equality(string, string) /* 0A000012 */ IL_0099: br.s IL_009c IL_009b: ldc.i4.0 IL_009c: stloc.0 IL_009d: call void [System.Console]System.Console::WriteLine() /* 0A000016 */ IL_00a2: ldloc.0 IL_00a3: ret } // end of method Program::CheckResults // ============== Test using GenTestType ============== // // These test methods will callvirt each method using: // 1) The signature from GetBaseType // 2) The signature from GenMiddleType with covariant returns (when applicable) // 3) The signature from GenTestType with covariant returns // And verify that the override on GetTestType is the one that executes .method public static bool RunTest1() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance object class GenBaseType<int32,object>::MyFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenRetType<!2,!3> class GenTestType<int32,object,int32,object>::MyFunc(string&) pop ldstr "IGenRetType<!U,!V> TestType.MyFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest2() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::MyFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IC class GenTestType<int32,object,int32,object>::MyFunc(string&) pop ldstr "IC TestType.MyFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest3() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenDerive1<!1, class IDictionary<string,!0>> class GenMiddleType<object,int32>::MyGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 2 callvirt instance class IGenDerive3<!2,!3> class GenTestType<int32,object,int32,object>::MyGenFunc(string&) pop ldstr "IGenDerive3<!U,!V> TestType.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest4() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<int32,object> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class INonGenericDerived1<int32,object> class GenMiddleType<object,int32>::MyGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 2 callvirt instance class INonGenericDerived4 class GenTestType<int32,object,int32,object>::MyGenFunc(string&) pop ldstr "INonGenericDerived4 TestType.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest5() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::GenToNonGen(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenToNonGen1<!1, class IDictionary<string,object>> class GenMiddleType<object,int32>::GenToNonGen(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 2 callvirt instance class IGenToNonGen3<!2,object> class GenTestType<int32,object,int32,object>::GenToNonGen(string&) pop ldstr "IGenToNonGen3<!U,object> TestType.GenToNonGen()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest6() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::NonGenThroughGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class INonGenThroughGen2<object,int32,string> class GenMiddleType<object,int32>::NonGenThroughGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 2 callvirt instance class INonGenThroughGen4 class GenTestType<int32,object,int32,object>::NonGenThroughGenFunc(string&) pop ldstr "INonGenThroughGen4 TestType.NonGenThroughGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest7() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class ICovariant<class CB> class GenBaseType<int32,object>::MyFuncCovariant(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class ICovariant<class CC> class GenTestType<int32,object,int32,object>::MyFuncCovariant(string&) pop ldstr "ICovariant<CC> TestType.MyFuncCovariant()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest8() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IContravariant<class CB> class GenBaseType<int32,object>::MyFuncContravariant(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IContravariant<class CA> class GenTestType<int32,object,int32,object>::MyFuncContravariant(string&) pop ldstr "IContravariant<CA> TestType.MyFuncContravariant()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest9() noinlining { .locals init (string res1) newobj instance void class GenMoreDerived<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IVariant<class Derived> class GenMoreDerived<int32,object,int32,object>::MultiLevelGenericVariantFunc(string&) pop ldstr "class IVariant<class Derived> GenMoreDerived.MultiLevelGenericVariantFunc()" ldloc.0 ldnull ldnull ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } // ============== Test using GenMiddleType ============== // // These test methods will callvirt each method using: // 1) The signature from GetBaseType // 2) The signature from GenMiddleType with covariant returns // And verify that the override on GenMiddleType is the one that executes .method public static bool RunTest_Middle1() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 1 callvirt instance class IGenDerive1<!1, class IDictionary<string,!0>> class GenMiddleType<object,int32>::MyGenFunc(string&) pop ldstr "IGenDerive1<!U, class IDictionary<string,!V>> GenMiddleType.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_Middle2() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<int32,object> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 1 callvirt instance class INonGenericDerived1<int32,object> class GenMiddleType<object,int32>::MyGenFunc(string&) pop ldstr "INonGenericDerived1<int32,object> GenMiddleType.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_Middle3() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::GenToNonGen(string&) pop newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 1 callvirt instance class IGenToNonGen1<!1, class IDictionary<string,object>> class GenMiddleType<object,int32>::GenToNonGen(string&) pop ldstr "IGenToNonGen1<!V, class IDictionary<string,object>> GenMiddleType.GenToNonGen()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_Middle4() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::NonGenThroughGenFunc(string&) pop newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 1 callvirt instance class INonGenThroughGen2<object,int32,string> class GenMiddleType<object,int32>::NonGenThroughGenFunc(string&) pop ldstr "INonGenThroughGen2<object,int32,string> GenMiddleType.NonGenThroughGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } // ============== Test using GenMoreDerived ============== // // These test methods will callvirt each method using: // 1) The signature from GetBaseType // 2) The signature from GenMiddleType with covariant returns (when applicable) // 3) The signature from GenTestType with covariant returns // 4) The signature from GenMoreDerived with covariant returns // And verify that the override on GenMoreDerived is the one that executes .method public static bool RunTest_MoreDerived1() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance object class GenBaseType<int32,object>::MyFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenRetType<!2,!3> class GenTestType<int32,object,int32,object>::MyFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class GenRetType<!2,!3> class GenMoreDerived<object,int32,int32,object>::MyFunc(string&) pop ldstr "class GenRetType<!U,!V> GenMoreDerived.MyFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived2() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::MyFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class IC class GenTestType<int32,object,int32,object>::MyFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class C class GenMoreDerived<object,int32,int32,object>::MyFunc(string&) pop ldstr "class C GenMoreDerived.MyFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived3() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenDerive1<!1, class IDictionary<string,!0>> class GenMiddleType<object,int32>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class IGenDerive3<!2,!3> class GenTestType<int32,object,int32,object>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 3 callvirt instance class GenDerive3<!2,!3> class GenMoreDerived<object,int32,int32,object>::MyGenFunc(string&) pop ldstr "class GenDerive3<!U,!V> GenMoreDerived.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived4() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<int32,object> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class INonGenericDerived1<int32,object> class GenMiddleType<object,int32>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class INonGenericDerived4 class GenTestType<int32,object,int32,object>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 3 callvirt instance class NonGenericDerived4 class GenMoreDerived<object,int32,int32,object>::MyGenFunc(string&) pop ldstr "class NonGenericDerived4 GenMoreDerived.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived5() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::GenToNonGen(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenToNonGen1<!1, class IDictionary<string,object>> class GenMiddleType<object,int32>::GenToNonGen(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class IGenToNonGen3<!2,object> class GenTestType<int32,object,int32,object>::GenToNonGen(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 3 callvirt instance class GenToNonGen3<!2,object> class GenMoreDerived<object,int32,int32,object>::GenToNonGen(string&) pop ldstr "class GenToNonGen3<!U,object> GenMoreDerived.GenToNonGen()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived6() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::NonGenThroughGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class INonGenThroughGen2<object,int32,string> class GenMiddleType<object,int32>::NonGenThroughGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class INonGenThroughGen4 class GenTestType<int32,object,int32,object>::NonGenThroughGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 3 callvirt instance class NonGenThroughGen4 class GenMoreDerived<object,int32,int32,object>::NonGenThroughGenFunc(string&) pop ldstr "class NonGenThroughGen4 GenMoreDerived.NonGenThroughGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } // ===================================================================================== // .method public static void RunTest_Invalid1() noinlining { newobj instance void class Invalid1<int32,object>::.ctor() call void [System.Console]System.Console::WriteLine(object) ret } .method public static void RunTest_Invalid2() noinlining { newobj instance void class Invalid2<int32,object>::.ctor() call void [System.Console]System.Console::WriteLine(object) ret } .method public static void RunTest_Invalid3() noinlining { newobj instance void class Invalid3<int32,object>::.ctor() callvirt instance class IVariant<class Derived2> class Invalid3<int32,object>::MultiLevelGenericVariantFunc() pop ret } // ===================================================================================== // .method public hidebysig static int32 Main( string[] args) cil managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .maxstack 2 .locals init ( bool result ) ldc.i4.1 stloc.0 T1: call bool CMain::RunTest1() brtrue.s T2 ldc.i4.0 stloc.0 T2: call bool CMain::RunTest2() brtrue.s T3 ldc.i4.0 stloc.0 T3: call bool CMain::RunTest3() brtrue.s T4 ldc.i4.0 stloc.0 T4: call bool CMain::RunTest4() brtrue.s T5 ldc.i4.0 stloc.0 T5: call bool CMain::RunTest5() brtrue.s T6 ldc.i4.0 stloc.0 T6: call bool CMain::RunTest6() brtrue.s T7 ldc.i4.0 stloc.0 T7: call bool CMain::RunTest7() brtrue.s T8 ldc.i4.0 stloc.0 T8: call bool CMain::RunTest8() brtrue.s T9 ldc.i4.0 stloc.0 T9: call bool CMain::RunTest9() brtrue.s M1 ldc.i4.0 stloc.0 // ===================================================================================== // M1: call bool CMain::RunTest_Middle1() brtrue.s M2 ldc.i4.0 stloc.0 M2: call bool CMain::RunTest_Middle2() brtrue.s M3 ldc.i4.0 stloc.0 M3: call bool CMain::RunTest_Middle3() brtrue.s M4 ldc.i4.0 stloc.0 M4: call bool CMain::RunTest_Middle4() brtrue.s MOREDERIVED1 ldc.i4.0 stloc.0 // ===================================================================================== // MOREDERIVED1: call bool CMain::RunTest_MoreDerived1() brtrue.s MOREDERIVED2 ldc.i4.0 stloc.0 MOREDERIVED2: call bool CMain::RunTest_MoreDerived2() brtrue.s MOREDERIVED3 ldc.i4.0 stloc.0 MOREDERIVED3: call bool CMain::RunTest_MoreDerived3() brtrue.s MOREDERIVED4 ldc.i4.0 stloc.0 MOREDERIVED4: call bool CMain::RunTest_MoreDerived4() brtrue.s MOREDERIVED5 ldc.i4.0 stloc.0 MOREDERIVED5: call bool CMain::RunTest_MoreDerived5() brtrue.s MOREDERIVED6 ldc.i4.0 stloc.0 MOREDERIVED6: call bool CMain::RunTest_MoreDerived6() brtrue.s INVALID1 ldc.i4.0 stloc.0 // ===================================================================================== // INVALID1: .try { call void CMain::RunTest_Invalid1() ldc.i4.0 stloc.0 ldstr "FAIL: did not catch expected TypeLoadException when loading Invalid1." call void [System.Console]System.Console::WriteLine(string) leave.s INVALID2 } catch [mscorlib]System.TypeLoadException { ldstr "Caught expected TypeLoadException:" call void [System.Console]System.Console::WriteLine(string) call void [System.Console]System.Console::WriteLine(object) leave.s INVALID2 } INVALID2: .try { call void CMain::RunTest_Invalid2() ldc.i4.0 stloc.0 ldstr "FAIL: did not catch expected TypeLoadException when loading Invalid2." call void [System.Console]System.Console::WriteLine(string) leave.s INVALID3 } catch [mscorlib]System.TypeLoadException { ldstr "Caught expected TypeLoadException:" call void [System.Console]System.Console::WriteLine(string) call void [System.Console]System.Console::WriteLine(object) leave.s INVALID3 } INVALID3: .try { call void CMain::RunTest_Invalid3() ldc.i4.0 stloc.0 ldstr "FAIL: did not catch expected TypeLoadException when loading DerivedClassFail1." call void [System.Console]System.Console::WriteLine(string) leave.s DONE } catch [mscorlib]System.TypeLoadException { ldstr "Caught expected TypeLoadException:" call void [System.Console]System.Console::WriteLine(string) call void [System.Console]System.Console::WriteLine(object) leave.s DONE } // ===================================================================================== // DONE: ldloc.0 brtrue.s PASS ldstr "Test FAILED" call void [System.Console]System.Console::WriteLine(string) ldc.i4.s 101 ret PASS: ldstr "Test PASSED" call void [System.Console]System.Console::WriteLine(string) ldc.i4.s 100 ret ldc.i4.s 100 ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { .maxstack 8 ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern System.Console { } .assembly extern xunit.core {} .assembly extern System.Runtime { } .assembly extern mscorlib { } .assembly UnitTest { } // ======================================================================================== // Types that will be used as return types on the various methods // ======================================================================================== .class interface public auto ansi abstract IUnused1 { } .class interface public auto ansi abstract IUnused2 { } .class interface public auto ansi abstract IA implements IUnused1, IUnused2 { } .class interface public auto ansi abstract IB implements IUnused1, IUnused2, IA { } .class interface public auto ansi abstract IC implements IUnused1, IUnused2, IB { } .class interface public auto ansi abstract IGenRetType<X,Y> { } .class interface public auto ansi abstract IDictionary<KEY,VAL> { } .class public auto ansi abstract CA {} .class public auto ansi abstract CB extends CA {} .class public auto ansi abstract CC extends CB {} .class interface public auto ansi abstract ICovariant<+ T> { } .class interface public auto ansi abstract IContravariant<- T> { } .class interface public auto ansi abstract IGenDerive1<V1,V2> implements IUnused1, IUnused2, class IGenRetType<!V1,!V2> { } .class interface public auto ansi abstract IGenDerive2<U1,U2,U3> implements IUnused1, IUnused2, class IGenDerive1<!U1, class IDictionary<!U3,!U2>> { } .class interface public auto ansi abstract IGenDerive3<T1,T2> implements IUnused1, IUnused2, class IGenDerive2<!T1,!T2,string> { } .class interface public auto ansi abstract INonGenericDerived1<ARG1,ARG2> implements IUnused1, IUnused2, class IGenRetType<!ARG1,!ARG2> { } .class interface public auto ansi abstract INonGenericDerived2<T> implements IUnused1, IUnused2, class INonGenericDerived1<!T,object> { } .class interface public auto ansi abstract INonGenericDerived3 implements IUnused1, IUnused2, class INonGenericDerived2<int32> { } .class interface public auto ansi abstract INonGenericDerived4 implements IUnused1, IUnused2, INonGenericDerived3 { } .class interface public auto ansi abstract IGenToNonGen1<V1,V2> implements IUnused1, IUnused2, IC { } .class interface public auto ansi abstract IGenToNonGen2<U1,U2,U3> implements IUnused1, IUnused2, class IGenToNonGen1<!U1, class IDictionary<!U3,!U2>> { } .class interface public auto ansi abstract IGenToNonGen3<T1,T2> implements IUnused1, IUnused2, class IGenToNonGen2<!T1,!T2,string> { } .class interface public auto ansi abstract INonGenThroughGen1<V1,V2> implements IUnused1, IUnused2, IC { } .class interface public auto ansi abstract INonGenThroughGen2<U1,U2,U3> implements IUnused1, IUnused2, class INonGenThroughGen1<!U1, class IDictionary<!U3,!U2>> { } .class interface public auto ansi abstract INonGenThroughGen3 implements IUnused1, IUnused2, class INonGenThroughGen2<object,int32,string> { } .class interface public auto ansi abstract INonGenThroughGen4 implements IUnused1, IUnused2, INonGenThroughGen3 { } // class implementing the interfaces .class public auto ansi beforefieldinit NonGenThroughGen4 implements IUnused1, IUnused2, INonGenThroughGen4 { } .class public auto ansi beforefieldinit GenToNonGen3<T1,T2> implements IUnused1, IUnused2, class IGenToNonGen3<!T1,!T2> { } .class public auto ansi beforefieldinit NonGenericDerived4 implements IUnused1, IUnused2, INonGenericDerived4 { } .class public auto ansi beforefieldinit GenDerive3<T1,T2> implements IUnused1, IUnused2, class IGenDerive3<!T1,!T2> { } .class public auto ansi beforefieldinit C implements IUnused1, IUnused2, IC { } .class public auto ansi beforefieldinit GenRetType<X,Y> implements IUnused1, IUnused2, class IGenRetType<!X,!Y> { } .class public auto ansi beforefieldinit Base<T> {} .class public auto ansi beforefieldinit Derived extends class Base<class Derived> {} .class public auto ansi beforefieldinit Derived2 extends class Base<class Derived2> {} .class interface public auto ansi abstract IVariant<+ V> { .method public hidebysig newslot virtual instance void Test() { ret } } // ======================================================================================== // Main base type with various virtual methods that will be overriden later // ======================================================================================== .class public auto ansi beforefieldinit GenBaseType<A,B> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance object MyFunc(string& res) { ldarg.1 ldstr "object GenBaseType.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IB MyFunc(string& res) { ldarg.1 ldstr "IB GenBaseType.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class ICovariant<class CB> MyFuncCovariant(string& res) { ldarg.1 ldstr "ICovariant<CB> GenBaseType.MyFuncCovariant()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IContravariant<class CB> MyFuncContravariant(string& res) { ldarg.1 ldstr "IContravariant<CB> GenBaseType.MyFuncContravariant()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IB GenToNonGen(string& res) { ldarg.1 ldstr "IB GenBaseType.GenToNonGen()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IB NonGenThroughGenFunc(string& res) { ldarg.1 ldstr "IB GenBaseType.NonGenThroughGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenRetType<int32,object> MyGenFunc(string& res) { ldarg.1 ldstr "IGenRetType<int32,object> GenBaseType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenRetType<!A, class IDictionary<string,!B>> MyGenFunc(string& res) { ldarg.1 ldstr "IGenRetType<!A, class IDictionary<string,!B>> GenBaseType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IVariant<class Base<class Derived>> MultiLevelGenericVariantFunc(string&) { ldarg.1 ldstr "IVariant<class Base<class Derived>> GenBaseType.MultiLevelGenericVariantFunc()" stind.ref ldnull ret } } // ======================================================================================== // SECOND LAYER type: overrides *SOME* virtuals on GenBaseType using MethodImpls with // covariant return types (more derived return types) // ======================================================================================== .class public auto ansi beforefieldinit GenMiddleType<U,V> extends class GenBaseType<!V,!U> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class INonGenThroughGen2<object,int32,string> NonGenThroughGenFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IB class GenBaseType<!V,!U>::NonGenThroughGenFunc(string& res) ldarg.1 ldstr "INonGenThroughGen2<object,int32,string> GenMiddleType.NonGenThroughGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenToNonGen1<!V, class IDictionary<string,object>> GenToNonGen(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IB class GenBaseType<!V,!U>::GenToNonGen(string& res) ldarg.1 ldstr "IGenToNonGen1<!V, class IDictionary<string,object>> GenMiddleType.GenToNonGen()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class INonGenericDerived1<int32,object> MyGenFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IGenRetType<int32,object> class GenBaseType<!V,!U>::MyGenFunc(string& res) ldarg.1 ldstr "INonGenericDerived1<int32,object> GenMiddleType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenDerive1<!V, class IDictionary<string,!U>> MyGenFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<!V,!U>::MyGenFunc(string& res) ldarg.1 ldstr "IGenDerive1<!U, class IDictionary<string,!V>> GenMiddleType.MyGenFunc()" stind.ref ldnull ret } } // ======================================================================================== // THIRD LAYER type: overrides all virtuals from GenBaseType using MethodImpls with // covariant return types (more derived return types than the ones used in GenMiddleType) // ======================================================================================== .class public auto ansi beforefieldinit GenTestType<UNUSED1,UNUSED2,U,V> extends class GenMiddleType<!V,!U> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class INonGenThroughGen4 NonGenThroughGenFunc(string& res) { .override method instance class IB class GenBaseType<!U,!V>::NonGenThroughGenFunc(string& res) ldarg.1 ldstr "INonGenThroughGen4 TestType.NonGenThroughGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenToNonGen3<!U,object> GenToNonGen(string& res) { .override method instance class IB class GenBaseType<!U,!V>::GenToNonGen(string& res) ldarg.1 ldstr "IGenToNonGen3<!U,object> TestType.GenToNonGen()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class INonGenericDerived4 MyGenFunc(string& res) { .override method instance class IGenRetType<int32,object> class GenBaseType<!U,!V>::MyGenFunc(string& res) ldarg.1 ldstr "INonGenericDerived4 TestType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenDerive3<!U,!V> MyGenFunc(string& res) { .override method instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<!U,!V>::MyGenFunc(string& res) ldarg.1 ldstr "IGenDerive3<!U,!V> TestType.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IGenRetType<!U,!V> MyFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance object class GenBaseType<!U,!V>::MyFunc(string& res) ldarg.1 ldstr "IGenRetType<!U,!V> TestType.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IC MyFunc(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IB class GenBaseType<!U,!V>::MyFunc(string& res) ldarg.1 ldstr "IC TestType.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class ICovariant<class CC> MyFuncCovariant(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class ICovariant<class CB> class GenBaseType<!U,!V>::MyFuncCovariant(string& res) ldarg.1 ldstr "ICovariant<CC> TestType.MyFuncCovariant()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IContravariant<class CA> MyFuncContravariant(string& res) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IContravariant<class CB> class GenBaseType<!U,!V>::MyFuncContravariant(string& res) ldarg.1 ldstr "IContravariant<CA> TestType.MyFuncContravariant()" stind.ref ldnull ret } // ======================================================================================== // Set of implicit overrides that should be ignored given there are explicit overrides from the MethodImpls // ======================================================================================== .method public hidebysig virtual instance class IB NonGenThroughGenFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IB GenToNonGen(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IGenRetType<int32,object> MyGenFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IGenRetType<!0, class IDictionary<string,!1>> MyGenFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance object MyFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IB MyFunc(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class ICovariant<class CB> MyFuncCovariant(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } .method public hidebysig virtual instance class IContravariant<class CB> MyFuncContravariant(string& res) { ldstr "Should never execute this method" newobj instance void [System.Runtime]System.Exception::.ctor(string) throw } } // ======================================================================================== // FOURTH LAYER type: overrides all virtuals from GenBaseType using MethodImpls with // covariant return types (classes that implement the interfaces used as return types) // ======================================================================================== .class public auto ansi beforefieldinit GenMoreDerived<UNUSED1,UNUSED2,U,V> extends class GenTestType<!UNUSED2,!UNUSED1,!U,!V> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class NonGenThroughGen4 NonGenThroughGenFunc(string& res) { .override method instance class IB class GenBaseType<!U,!V>::NonGenThroughGenFunc(string& res) ldarg.1 ldstr "class NonGenThroughGen4 GenMoreDerived.NonGenThroughGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class GenToNonGen3<!U,object> GenToNonGen(string& res) { .override method instance class IB class GenBaseType<!U,!V>::GenToNonGen(string& res) ldarg.1 ldstr "class GenToNonGen3<!U,object> GenMoreDerived.GenToNonGen()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class NonGenericDerived4 MyGenFunc(string& res) { .override method instance class IGenRetType<int32,object> class GenBaseType<!U,!V>::MyGenFunc(string& res) ldarg.1 ldstr "class NonGenericDerived4 GenMoreDerived.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class GenDerive3<!U,!V> MyGenFunc(string& res) { .override method instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<!U,!V>::MyGenFunc(string& res) ldarg.1 ldstr "class GenDerive3<!U,!V> GenMoreDerived.MyGenFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class GenRetType<!U,!V> MyFunc(string& res) { .override method instance object class GenBaseType<!U,!V>::MyFunc(string& res) ldarg.1 ldstr "class GenRetType<!U,!V> GenMoreDerived.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class C MyFunc(string& res) { .override method instance class IB class GenBaseType<!U,!V>::MyFunc(string& res) ldarg.1 ldstr "class C GenMoreDerived.MyFunc()" stind.ref ldnull ret } .method public hidebysig newslot virtual instance class IVariant<class Derived> MultiLevelGenericVariantFunc(string&) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IVariant<class Base<class Derived>> class GenBaseType<!U,!V>::MultiLevelGenericVariantFunc(string&) ldarg.1 ldstr "class IVariant<class Derived> GenMoreDerived.MultiLevelGenericVariantFunc()" stind.ref ldnull ret } } // ======================================================================================== // FIFTH LAYER INVALID type: Used to verify we can't override the method using a compatible interface // if it has been already overridden using a class that implements the interface (i.e. the new // interface return type won't be compatible with the class return type on the previous override // ======================================================================================== .class public auto ansi beforefieldinit Invalid1<Q,W> extends class GenMoreDerived<!Q,!W,!Q,!W> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class INonGenThroughGen4 NonGenThroughGenFunc(string& res) { .override method instance class IB class GenBaseType<!Q,!W>::NonGenThroughGenFunc(string& res) ldnull ret } } // ======================================================================================== // FIFTH LAYER INVALID type: Used to verify we can't override the method using a less derived interface // than one that has already been used in a previous override // ======================================================================================== .class public auto ansi beforefieldinit Invalid2<Q,W> extends class GenTestType<!Q,!W,!Q,!W> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class INonGenThroughGen2<object,int32,string> NonGenThroughGenFunc(string& res) { .override method instance class IB class GenBaseType<!Q,!W>::NonGenThroughGenFunc(string& res) ldnull ret } } .class public auto ansi beforefieldinit Invalid3<Q,W> extends class GenTestType<!Q,!W,!Q,!W> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ret } .method public hidebysig newslot virtual instance class IVariant<class Derived2> MultiLevelGenericVariantFunc(string&) { .custom instance void [System.Runtime]System.Runtime.CompilerServices.PreserveBaseOverridesAttribute::.ctor() = (01 00 00 00) .override method instance class IVariant<class Base<class Derived>> class GenBaseType<!Q,!W>::MultiLevelGenericVariantFunc(string&) ldnull ret } } // ======================================================================================== .class public auto ansi beforefieldinit CMain extends [mscorlib]System.Object { .method private hidebysig static bool CheckResults ( string expected, string a, [opt] string b, [opt] string c, [opt] string d) cil managed { .param [3] = nullref .param [4] = nullref .param [5] = nullref // Method begins at RVA 0x20a0 // Code size 164 (0xa4) .maxstack 2 .locals /* 11000002 */ init ( [0] bool ) IL_0000: ldarg.1 IL_0001: ldarg.0 IL_0002: call bool [System.Runtime]System.String::op_Equality(string, string) /* 0A000012 */ IL_0007: stloc.0 IL_0008: ldstr "EXPECTED: " /* 70000001 */ IL_000d: ldarg.0 IL_000e: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_0013: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_0018: ldstr "ACTUAL1 : " /* 70000017 */ IL_001d: ldarg.1 IL_001e: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_0023: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_0028: ldarg.2 IL_0029: call bool [System.Runtime]System.String::IsNullOrEmpty(string) /* 0A000015 */ IL_002e: brtrue.s IL_004e IL_0030: ldstr "ACTUAL2 : " /* 7000002D */ IL_0035: ldarg.2 IL_0036: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_003b: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_0040: ldloc.0 IL_0041: brfalse.s IL_004c IL_0043: ldarg.2 IL_0044: ldarg.0 IL_0045: call bool [System.Runtime]System.String::op_Equality(string, string) /* 0A000012 */ IL_004a: br.s IL_004d IL_004c: ldc.i4.0 IL_004d: stloc.0 IL_004e: ldarg.3 IL_004f: call bool [System.Runtime]System.String::IsNullOrEmpty(string) /* 0A000015 */ IL_0054: brtrue.s IL_0074 IL_0056: ldstr "ACTUAL3 : " /* 70000043 */ IL_005b: ldarg.3 IL_005c: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_0061: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_0066: ldloc.0 IL_0067: brfalse.s IL_0072 IL_0069: ldarg.3 IL_006a: ldarg.0 IL_006b: call bool [System.Runtime]System.String::op_Equality(string, string) /* 0A000012 */ IL_0070: br.s IL_0073 IL_0072: ldc.i4.0 IL_0073: stloc.0 IL_0074: ldarg.s d IL_0076: call bool [System.Runtime]System.String::IsNullOrEmpty(string) /* 0A000015 */ IL_007b: brtrue.s IL_009d IL_007d: ldstr "ACTUAL4 : " /* 70000059 */ IL_0082: ldarg.s d IL_0084: call string [System.Runtime]System.String::Concat(string, string) /* 0A000013 */ IL_0089: call void [System.Console]System.Console::WriteLine(string) /* 0A000014 */ IL_008e: ldloc.0 IL_008f: brfalse.s IL_009b IL_0091: ldarg.s d IL_0093: ldarg.0 IL_0094: call bool [System.Runtime]System.String::op_Equality(string, string) /* 0A000012 */ IL_0099: br.s IL_009c IL_009b: ldc.i4.0 IL_009c: stloc.0 IL_009d: call void [System.Console]System.Console::WriteLine() /* 0A000016 */ IL_00a2: ldloc.0 IL_00a3: ret } // end of method Program::CheckResults // ============== Test using GenTestType ============== // // These test methods will callvirt each method using: // 1) The signature from GetBaseType // 2) The signature from GenMiddleType with covariant returns (when applicable) // 3) The signature from GenTestType with covariant returns // And verify that the override on GetTestType is the one that executes .method public static bool RunTest1() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance object class GenBaseType<int32,object>::MyFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenRetType<!2,!3> class GenTestType<int32,object,int32,object>::MyFunc(string&) pop ldstr "IGenRetType<!U,!V> TestType.MyFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest2() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::MyFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IC class GenTestType<int32,object,int32,object>::MyFunc(string&) pop ldstr "IC TestType.MyFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest3() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenDerive1<!1, class IDictionary<string,!0>> class GenMiddleType<object,int32>::MyGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 2 callvirt instance class IGenDerive3<!2,!3> class GenTestType<int32,object,int32,object>::MyGenFunc(string&) pop ldstr "IGenDerive3<!U,!V> TestType.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest4() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<int32,object> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class INonGenericDerived1<int32,object> class GenMiddleType<object,int32>::MyGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 2 callvirt instance class INonGenericDerived4 class GenTestType<int32,object,int32,object>::MyGenFunc(string&) pop ldstr "INonGenericDerived4 TestType.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest5() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::GenToNonGen(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenToNonGen1<!1, class IDictionary<string,object>> class GenMiddleType<object,int32>::GenToNonGen(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 2 callvirt instance class IGenToNonGen3<!2,object> class GenTestType<int32,object,int32,object>::GenToNonGen(string&) pop ldstr "IGenToNonGen3<!U,object> TestType.GenToNonGen()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest6() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::NonGenThroughGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class INonGenThroughGen2<object,int32,string> class GenMiddleType<object,int32>::NonGenThroughGenFunc(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 2 callvirt instance class INonGenThroughGen4 class GenTestType<int32,object,int32,object>::NonGenThroughGenFunc(string&) pop ldstr "INonGenThroughGen4 TestType.NonGenThroughGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest7() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class ICovariant<class CB> class GenBaseType<int32,object>::MyFuncCovariant(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class ICovariant<class CC> class GenTestType<int32,object,int32,object>::MyFuncCovariant(string&) pop ldstr "ICovariant<CC> TestType.MyFuncCovariant()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest8() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IContravariant<class CB> class GenBaseType<int32,object>::MyFuncContravariant(string&) pop newobj instance void class GenTestType<int32,object,int32,object>::.ctor() ldloca.s 1 callvirt instance class IContravariant<class CA> class GenTestType<int32,object,int32,object>::MyFuncContravariant(string&) pop ldstr "IContravariant<CA> TestType.MyFuncContravariant()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest9() noinlining { .locals init (string res1) newobj instance void class GenMoreDerived<int32,object,int32,object>::.ctor() ldloca.s 0 callvirt instance class IVariant<class Derived> class GenMoreDerived<int32,object,int32,object>::MultiLevelGenericVariantFunc(string&) pop ldstr "class IVariant<class Derived> GenMoreDerived.MultiLevelGenericVariantFunc()" ldloc.0 ldnull ldnull ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } // ============== Test using GenMiddleType ============== // // These test methods will callvirt each method using: // 1) The signature from GetBaseType // 2) The signature from GenMiddleType with covariant returns // And verify that the override on GenMiddleType is the one that executes .method public static bool RunTest_Middle1() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 1 callvirt instance class IGenDerive1<!1, class IDictionary<string,!0>> class GenMiddleType<object,int32>::MyGenFunc(string&) pop ldstr "IGenDerive1<!U, class IDictionary<string,!V>> GenMiddleType.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_Middle2() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<int32,object> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 1 callvirt instance class INonGenericDerived1<int32,object> class GenMiddleType<object,int32>::MyGenFunc(string&) pop ldstr "INonGenericDerived1<int32,object> GenMiddleType.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_Middle3() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::GenToNonGen(string&) pop newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 1 callvirt instance class IGenToNonGen1<!1, class IDictionary<string,object>> class GenMiddleType<object,int32>::GenToNonGen(string&) pop ldstr "IGenToNonGen1<!V, class IDictionary<string,object>> GenMiddleType.GenToNonGen()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_Middle4() noinlining { .locals init (string res1, string res2, string res3) newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::NonGenThroughGenFunc(string&) pop newobj instance void class GenMiddleType<object,int32>::.ctor() ldloca.s 1 callvirt instance class INonGenThroughGen2<object,int32,string> class GenMiddleType<object,int32>::NonGenThroughGenFunc(string&) pop ldstr "INonGenThroughGen2<object,int32,string> GenMiddleType.NonGenThroughGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldnull call bool CMain::CheckResults(string,string,string,string,string) ret } // ============== Test using GenMoreDerived ============== // // These test methods will callvirt each method using: // 1) The signature from GetBaseType // 2) The signature from GenMiddleType with covariant returns (when applicable) // 3) The signature from GenTestType with covariant returns // 4) The signature from GenMoreDerived with covariant returns // And verify that the override on GenMoreDerived is the one that executes .method public static bool RunTest_MoreDerived1() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance object class GenBaseType<int32,object>::MyFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenRetType<!2,!3> class GenTestType<int32,object,int32,object>::MyFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class GenRetType<!2,!3> class GenMoreDerived<object,int32,int32,object>::MyFunc(string&) pop ldstr "class GenRetType<!U,!V> GenMoreDerived.MyFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived2() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::MyFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class IC class GenTestType<int32,object,int32,object>::MyFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class C class GenMoreDerived<object,int32,int32,object>::MyFunc(string&) pop ldstr "class C GenMoreDerived.MyFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived3() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<!0, class IDictionary<string,!1>> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenDerive1<!1, class IDictionary<string,!0>> class GenMiddleType<object,int32>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class IGenDerive3<!2,!3> class GenTestType<int32,object,int32,object>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 3 callvirt instance class GenDerive3<!2,!3> class GenMoreDerived<object,int32,int32,object>::MyGenFunc(string&) pop ldstr "class GenDerive3<!U,!V> GenMoreDerived.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived4() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IGenRetType<int32,object> class GenBaseType<int32,object>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class INonGenericDerived1<int32,object> class GenMiddleType<object,int32>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class INonGenericDerived4 class GenTestType<int32,object,int32,object>::MyGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 3 callvirt instance class NonGenericDerived4 class GenMoreDerived<object,int32,int32,object>::MyGenFunc(string&) pop ldstr "class NonGenericDerived4 GenMoreDerived.MyGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived5() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::GenToNonGen(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class IGenToNonGen1<!1, class IDictionary<string,object>> class GenMiddleType<object,int32>::GenToNonGen(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class IGenToNonGen3<!2,object> class GenTestType<int32,object,int32,object>::GenToNonGen(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 3 callvirt instance class GenToNonGen3<!2,object> class GenMoreDerived<object,int32,int32,object>::GenToNonGen(string&) pop ldstr "class GenToNonGen3<!U,object> GenMoreDerived.GenToNonGen()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } .method public static bool RunTest_MoreDerived6() noinlining { .locals init (string res1, string res2, string res3, string res4) newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 0 callvirt instance class IB class GenBaseType<int32,object>::NonGenThroughGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 1 callvirt instance class INonGenThroughGen2<object,int32,string> class GenMiddleType<object,int32>::NonGenThroughGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 2 callvirt instance class INonGenThroughGen4 class GenTestType<int32,object,int32,object>::NonGenThroughGenFunc(string&) pop newobj instance void class GenMoreDerived<object,int32,int32,object>::.ctor() ldloca.s 3 callvirt instance class NonGenThroughGen4 class GenMoreDerived<object,int32,int32,object>::NonGenThroughGenFunc(string&) pop ldstr "class NonGenThroughGen4 GenMoreDerived.NonGenThroughGenFunc()" ldloc.0 ldloc.1 ldloc.2 ldloc.3 call bool CMain::CheckResults(string,string,string,string,string) ret } // ===================================================================================== // .method public static void RunTest_Invalid1() noinlining { newobj instance void class Invalid1<int32,object>::.ctor() call void [System.Console]System.Console::WriteLine(object) ret } .method public static void RunTest_Invalid2() noinlining { newobj instance void class Invalid2<int32,object>::.ctor() call void [System.Console]System.Console::WriteLine(object) ret } .method public static void RunTest_Invalid3() noinlining { newobj instance void class Invalid3<int32,object>::.ctor() callvirt instance class IVariant<class Derived2> class Invalid3<int32,object>::MultiLevelGenericVariantFunc() pop ret } // ===================================================================================== // .method public hidebysig static int32 Main( string[] args) cil managed { .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) .entrypoint .maxstack 2 .locals init ( bool result ) ldc.i4.1 stloc.0 T1: call bool CMain::RunTest1() brtrue.s T2 ldc.i4.0 stloc.0 T2: call bool CMain::RunTest2() brtrue.s T3 ldc.i4.0 stloc.0 T3: call bool CMain::RunTest3() brtrue.s T4 ldc.i4.0 stloc.0 T4: call bool CMain::RunTest4() brtrue.s T5 ldc.i4.0 stloc.0 T5: call bool CMain::RunTest5() brtrue.s T6 ldc.i4.0 stloc.0 T6: call bool CMain::RunTest6() brtrue.s T7 ldc.i4.0 stloc.0 T7: call bool CMain::RunTest7() brtrue.s T8 ldc.i4.0 stloc.0 T8: call bool CMain::RunTest8() brtrue.s T9 ldc.i4.0 stloc.0 T9: call bool CMain::RunTest9() brtrue.s M1 ldc.i4.0 stloc.0 // ===================================================================================== // M1: call bool CMain::RunTest_Middle1() brtrue.s M2 ldc.i4.0 stloc.0 M2: call bool CMain::RunTest_Middle2() brtrue.s M3 ldc.i4.0 stloc.0 M3: call bool CMain::RunTest_Middle3() brtrue.s M4 ldc.i4.0 stloc.0 M4: call bool CMain::RunTest_Middle4() brtrue.s MOREDERIVED1 ldc.i4.0 stloc.0 // ===================================================================================== // MOREDERIVED1: call bool CMain::RunTest_MoreDerived1() brtrue.s MOREDERIVED2 ldc.i4.0 stloc.0 MOREDERIVED2: call bool CMain::RunTest_MoreDerived2() brtrue.s MOREDERIVED3 ldc.i4.0 stloc.0 MOREDERIVED3: call bool CMain::RunTest_MoreDerived3() brtrue.s MOREDERIVED4 ldc.i4.0 stloc.0 MOREDERIVED4: call bool CMain::RunTest_MoreDerived4() brtrue.s MOREDERIVED5 ldc.i4.0 stloc.0 MOREDERIVED5: call bool CMain::RunTest_MoreDerived5() brtrue.s MOREDERIVED6 ldc.i4.0 stloc.0 MOREDERIVED6: call bool CMain::RunTest_MoreDerived6() brtrue.s INVALID1 ldc.i4.0 stloc.0 // ===================================================================================== // INVALID1: .try { call void CMain::RunTest_Invalid1() ldc.i4.0 stloc.0 ldstr "FAIL: did not catch expected TypeLoadException when loading Invalid1." call void [System.Console]System.Console::WriteLine(string) leave.s INVALID2 } catch [mscorlib]System.TypeLoadException { ldstr "Caught expected TypeLoadException:" call void [System.Console]System.Console::WriteLine(string) call void [System.Console]System.Console::WriteLine(object) leave.s INVALID2 } INVALID2: .try { call void CMain::RunTest_Invalid2() ldc.i4.0 stloc.0 ldstr "FAIL: did not catch expected TypeLoadException when loading Invalid2." call void [System.Console]System.Console::WriteLine(string) leave.s INVALID3 } catch [mscorlib]System.TypeLoadException { ldstr "Caught expected TypeLoadException:" call void [System.Console]System.Console::WriteLine(string) call void [System.Console]System.Console::WriteLine(object) leave.s INVALID3 } INVALID3: .try { call void CMain::RunTest_Invalid3() ldc.i4.0 stloc.0 ldstr "FAIL: did not catch expected TypeLoadException when loading DerivedClassFail1." call void [System.Console]System.Console::WriteLine(string) leave.s DONE } catch [mscorlib]System.TypeLoadException { ldstr "Caught expected TypeLoadException:" call void [System.Console]System.Console::WriteLine(string) call void [System.Console]System.Console::WriteLine(object) leave.s DONE } // ===================================================================================== // DONE: ldloc.0 brtrue.s PASS ldstr "Test FAILED" call void [System.Console]System.Console::WriteLine(string) ldc.i4.s 101 ret PASS: ldstr "Test PASSED" call void [System.Console]System.Console::WriteLine(string) ldc.i4.s 100 ret ldc.i4.s 100 ret } .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { .maxstack 8 ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Providers/Metadata/MetadataViewProvider.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; namespace System.Composition.Hosting.Providers.Metadata { internal static class MetadataViewProvider { private static readonly MethodInfo s_getMetadataValueMethod = typeof(MetadataViewProvider).GetTypeInfo().GetDeclaredMethod(nameof(GetMetadataValue)); // While not called through the composition pipeline, we use the dependency mechanism to surface errors // with appropriate context information. public static Func<IDictionary<string, object>, TMetadata> GetMetadataViewProvider<TMetadata>() { if (typeof(TMetadata) == typeof(IDictionary<string, object>)) return m => (TMetadata)m; if (!typeof(TMetadata).GetTypeInfo().IsClass) throw new CompositionFailedException(SR.Format(SR.MetadataViewProvider_InvalidViewImplementation, typeof(TMetadata).Name)); var ti = typeof(TMetadata).GetTypeInfo(); var dictionaryConstructor = ti.DeclaredConstructors.SingleOrDefault(ci => { var ps = ci.GetParameters(); return ci.IsPublic && ps.Length == 1 && ps[0].ParameterType == typeof(IDictionary<string, object>); }); if (dictionaryConstructor != null) { var providerArg = Expression.Parameter(typeof(IDictionary<string, object>), "metadata"); return Expression.Lambda<Func<IDictionary<string, object>, TMetadata>>( Expression.New(dictionaryConstructor, providerArg), providerArg) .Compile(); } var parameterlessConstructor = ti.DeclaredConstructors.SingleOrDefault(ci => ci.IsPublic && ci.GetParameters().Length == 0); if (parameterlessConstructor != null) { var providerArg = Expression.Parameter(typeof(IDictionary<string, object>), "metadata"); var resultVar = Expression.Variable(typeof(TMetadata), "result"); var blockExprs = new List<Expression>(); blockExprs.Add(Expression.Assign(resultVar, Expression.New(parameterlessConstructor))); foreach (var prop in typeof(TMetadata).GetTypeInfo().DeclaredProperties .Where(prop => prop.GetMethod != null && prop.GetMethod.IsPublic && !prop.GetMethod.IsStatic && prop.SetMethod != null && prop.SetMethod.IsPublic && !prop.SetMethod.IsStatic)) { var dva = Expression.Constant(prop.GetCustomAttribute<DefaultValueAttribute>(false), typeof(DefaultValueAttribute)); var name = Expression.Constant(prop.Name, typeof(string)); var m = s_getMetadataValueMethod.MakeGenericMethod(prop.PropertyType); var assign = Expression.Assign( Expression.Property(resultVar, prop), Expression.Call(null, m, providerArg, name, dva)); blockExprs.Add(assign); } blockExprs.Add(resultVar); return Expression.Lambda<Func<IDictionary<string, object>, TMetadata>>( Expression.Block(new[] { resultVar }, blockExprs), providerArg) .Compile(); } throw new CompositionFailedException(SR.Format(SR.MetadataViewProvider_InvalidViewImplementation, typeof(TMetadata).Name)); } private static TValue GetMetadataValue<TValue>(IDictionary<string, object> metadata, string name, DefaultValueAttribute defaultValue) { object result; if (metadata.TryGetValue(name, out result)) return (TValue)result; if (defaultValue != null) return (TValue)defaultValue.Value; // This could be significantly improved by describing the target metadata property. var message = SR.Format(SR.MetadataViewProvider_MissingMetadata, name); var ex = new CompositionFailedException(message); Debug.WriteLine(SR.Diagnostic_ThrowingException, ex.ToString()); throw ex; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; namespace System.Composition.Hosting.Providers.Metadata { internal static class MetadataViewProvider { private static readonly MethodInfo s_getMetadataValueMethod = typeof(MetadataViewProvider).GetTypeInfo().GetDeclaredMethod(nameof(GetMetadataValue)); // While not called through the composition pipeline, we use the dependency mechanism to surface errors // with appropriate context information. public static Func<IDictionary<string, object>, TMetadata> GetMetadataViewProvider<TMetadata>() { if (typeof(TMetadata) == typeof(IDictionary<string, object>)) return m => (TMetadata)m; if (!typeof(TMetadata).GetTypeInfo().IsClass) throw new CompositionFailedException(SR.Format(SR.MetadataViewProvider_InvalidViewImplementation, typeof(TMetadata).Name)); var ti = typeof(TMetadata).GetTypeInfo(); var dictionaryConstructor = ti.DeclaredConstructors.SingleOrDefault(ci => { var ps = ci.GetParameters(); return ci.IsPublic && ps.Length == 1 && ps[0].ParameterType == typeof(IDictionary<string, object>); }); if (dictionaryConstructor != null) { var providerArg = Expression.Parameter(typeof(IDictionary<string, object>), "metadata"); return Expression.Lambda<Func<IDictionary<string, object>, TMetadata>>( Expression.New(dictionaryConstructor, providerArg), providerArg) .Compile(); } var parameterlessConstructor = ti.DeclaredConstructors.SingleOrDefault(ci => ci.IsPublic && ci.GetParameters().Length == 0); if (parameterlessConstructor != null) { var providerArg = Expression.Parameter(typeof(IDictionary<string, object>), "metadata"); var resultVar = Expression.Variable(typeof(TMetadata), "result"); var blockExprs = new List<Expression>(); blockExprs.Add(Expression.Assign(resultVar, Expression.New(parameterlessConstructor))); foreach (var prop in typeof(TMetadata).GetTypeInfo().DeclaredProperties .Where(prop => prop.GetMethod != null && prop.GetMethod.IsPublic && !prop.GetMethod.IsStatic && prop.SetMethod != null && prop.SetMethod.IsPublic && !prop.SetMethod.IsStatic)) { var dva = Expression.Constant(prop.GetCustomAttribute<DefaultValueAttribute>(false), typeof(DefaultValueAttribute)); var name = Expression.Constant(prop.Name, typeof(string)); var m = s_getMetadataValueMethod.MakeGenericMethod(prop.PropertyType); var assign = Expression.Assign( Expression.Property(resultVar, prop), Expression.Call(null, m, providerArg, name, dva)); blockExprs.Add(assign); } blockExprs.Add(resultVar); return Expression.Lambda<Func<IDictionary<string, object>, TMetadata>>( Expression.Block(new[] { resultVar }, blockExprs), providerArg) .Compile(); } throw new CompositionFailedException(SR.Format(SR.MetadataViewProvider_InvalidViewImplementation, typeof(TMetadata).Name)); } private static TValue GetMetadataValue<TValue>(IDictionary<string, object> metadata, string name, DefaultValueAttribute defaultValue) { object result; if (metadata.TryGetValue(name, out result)) return (TValue)result; if (defaultValue != null) return (TValue)defaultValue.Value; // This could be significantly improved by describing the target metadata property. var message = SR.Format(SR.MetadataViewProvider_MissingMetadata, name); var ex = new CompositionFailedException(message); Debug.WriteLine(SR.Diagnostic_ThrowingException, ex.ToString()); throw ex; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Data.Tests { [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser.")] public class DataTableExtensionsTest { private DataTable _dt; public DataTableExtensionsTest() { _dt = new DataTable("test"); _dt.Columns.Add("id", typeof(int)); _dt.Columns.Add("name", typeof(string)); _dt.Columns.Add("alias", typeof(string)); _dt.PrimaryKey = new DataColumn[] { _dt.Columns["id"] }; _dt.Rows.Add(new object[] { 1, "Dan", "danmosemsft" }); _dt.Rows.Add(new object[] { 2, "Diego", "divega" }); _dt.Rows.Add(new object[] { 3, "Stephen", "stephentoub" }); _dt.AcceptChanges(); } [Fact] public void AsDataView_NullTable_ThrowsArgumentNullException() { AssertExtensions.Throws<ArgumentNullException>("table", () => DataTableExtensions.AsDataView(null)); } [Fact] public void AsDataView_DataTable_Succeeds() { DataView dv = _dt.AsDataView(); Assert.NotNull(dv); Assert.Equal(_dt, dv.Table); dv.Sort = "id"; int index = dv.Find(2); Assert.Equal(1, index); DataRowView[] rows = dv.FindRows(1); Assert.Single(rows); Assert.Equal(_dt.Rows[0], rows[0].Row); } [Fact] public void AsDataView_NullSource_ThrowsArgumentNullException() { AssertExtensions.Throws<ArgumentNullException>("source", () => DataTableExtensions.AsDataView<DataRow>(null)); } [Fact] public void AsDataView_Source_Succeeds() { DataView dv = _dt.AsEnumerable().Where(r => r.Field<string>("alias").Length > 6).AsDataView(); Assert.NotNull(dv); Assert.Equal(_dt, dv.Table); dv.Sort = "name"; int index = dv.Find("Stephen"); Assert.Equal(1, index); DataRowView[] rows = dv.FindRows("Dan"); Assert.Single(rows); Assert.Equal(_dt.Rows[0], rows[0].Row); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Data.Tests { [SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser.")] public class DataTableExtensionsTest { private DataTable _dt; public DataTableExtensionsTest() { _dt = new DataTable("test"); _dt.Columns.Add("id", typeof(int)); _dt.Columns.Add("name", typeof(string)); _dt.Columns.Add("alias", typeof(string)); _dt.PrimaryKey = new DataColumn[] { _dt.Columns["id"] }; _dt.Rows.Add(new object[] { 1, "Dan", "danmosemsft" }); _dt.Rows.Add(new object[] { 2, "Diego", "divega" }); _dt.Rows.Add(new object[] { 3, "Stephen", "stephentoub" }); _dt.AcceptChanges(); } [Fact] public void AsDataView_NullTable_ThrowsArgumentNullException() { AssertExtensions.Throws<ArgumentNullException>("table", () => DataTableExtensions.AsDataView(null)); } [Fact] public void AsDataView_DataTable_Succeeds() { DataView dv = _dt.AsDataView(); Assert.NotNull(dv); Assert.Equal(_dt, dv.Table); dv.Sort = "id"; int index = dv.Find(2); Assert.Equal(1, index); DataRowView[] rows = dv.FindRows(1); Assert.Single(rows); Assert.Equal(_dt.Rows[0], rows[0].Row); } [Fact] public void AsDataView_NullSource_ThrowsArgumentNullException() { AssertExtensions.Throws<ArgumentNullException>("source", () => DataTableExtensions.AsDataView<DataRow>(null)); } [Fact] public void AsDataView_Source_Succeeds() { DataView dv = _dt.AsEnumerable().Where(r => r.Field<string>("alias").Length > 6).AsDataView(); Assert.NotNull(dv); Assert.Equal(_dt, dv.Table); dv.Sort = "name"; int index = dv.Find("Stephen"); Assert.Equal(1, index); DataRowView[] rows = dv.FindRows("Dan"); Assert.Single(rows); Assert.Equal(_dt.Rows[0], rows[0].Row); } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/mono/mono/profiler/test-heapshot.cs
using System; class T { T next; static void Main (string[] args) { int count = 5000; T list = null; for (int i = 0; i < count; ++i) { T n = new T (); n.next = list; list = n; } // trigger a heapshot GC.Collect (); for (int i = 0; i < 23; ++i) { T n = new T (); n.next = list; list = n; } // trigger another heapshot GC.Collect (); } }
using System; class T { T next; static void Main (string[] args) { int count = 5000; T list = null; for (int i = 0; i < count; ++i) { T n = new T (); n.next = list; list = n; } // trigger a heapshot GC.Collect (); for (int i = 0; i < 23; ++i) { T n = new T (); n.next = list; list = n; } // trigger another heapshot GC.Collect (); } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Loader/classloader/explicitlayout/misc/derivedExplicitClass.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="derivedexplicitclass.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="derivedexplicitclass.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/CompositionContainerTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.Composition.Factories; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition.Primitives; using System.Linq; using System.Linq.Expressions; using System.UnitTesting; using Xunit; namespace System.ComponentModel.Composition { public class CompositionContainerTests { [Fact] public void Constructor2_ArrayWithNullElementAsProvidersArgument_ShouldThrowArgumentException() { Assert.Throws<ArgumentException>("providers", () => { new CompositionContainer(new ExportProvider[] { null }); }); } [Fact] public void Constructor3_ArrayWithNullElementAsProvidersArgument_ShouldThrowArgumentException() { var catalog = CatalogFactory.Create(); Assert.Throws<ArgumentException>("providers", () => { new CompositionContainer(catalog, new ExportProvider[] { null }); }); } [Fact] public void Constructor2_ArrayAsProvidersArgument_ShouldNotAllowModificationAfterConstruction() { var providers = new ExportProvider[] { ExportProviderFactory.Create() }; var container = new CompositionContainer(providers); providers[0] = null; Assert.NotNull(container.Providers[0]); } [Fact] public void Constructor3_ArrayAsProvidersArgument_ShouldNotAllowModificationAfterConstruction() { var providers = new ExportProvider[] { ExportProviderFactory.Create() }; var container = new CompositionContainer(CatalogFactory.Create(), providers); providers[0] = null; Assert.NotNull(container.Providers[0]); } [Fact] public void Constructor1_ShouldSetProvidersPropertyToEmptyCollection() { var container = new CompositionContainer(); Assert.Empty(container.Providers); } [Fact] public void Constructor2_EmptyArrayAsProvidersArgument_ShouldSetProvidersPropertyToEmpty() { var container = new CompositionContainer(new ExportProvider[0]); Assert.Empty(container.Providers); } [Fact] public void Constructor3_EmptyArrayAsProvidersArgument_ShouldSetProvidersPropertyToEmpty() { var container = new CompositionContainer(CatalogFactory.Create(), new ExportProvider[0]); Assert.Empty(container.Providers); } [Fact] public void Constructor1_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer(); Assert.Null(container.Catalog); } [Fact] public void Constructor2_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer(new ExportProvider[0]); Assert.Null(container.Catalog); } [Fact] public void Constructor3_NullAsCatalogArgument_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer((ComposablePartCatalog)null, new ExportProvider[0]); Assert.Null(container.Catalog); } [Fact] public void Constructor3_ValueAsCatalogArgument_ShouldSetCatalogProperty() { var expectations = Expectations.GetCatalogs(); foreach (var e in expectations) { var container = new CompositionContainer(e, new ExportProvider[0]); Assert.Same(e, container.Catalog); } } [Fact] public void Catalog_WhenDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { var catalog = container.Catalog; }); } [Fact] public void Providers_WhenDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { var providers = container.Providers; }); } [Fact] public void AddPart1_ImportOnlyPart_ShouldNotGetGarbageCollected() { var container = CreateCompositionContainer(); var import = PartFactory.CreateImporter("Value", ImportCardinality.ZeroOrMore); CompositionBatch batch = new CompositionBatch(); batch.AddPart(import); container.Compose(batch); var weakRef = new WeakReference(import); import = null; GC.Collect(); GC.WaitForPendingFinalizers(); Assert.NotNull(weakRef.Target); GC.KeepAlive(container); } [Fact] public void Compose_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); CompositionBatch batch = new CompositionBatch(); ExceptionAssert.ThrowsDisposed(container, () => { container.Compose(batch); }); } [Fact] public void GetExportOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); var definition = ImportDefinitionFactory.Create(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports(definition); }); } [Fact] public void GetExports2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports(typeof(string), typeof(object), "Contract"); }); } [Fact] public void GetExportsOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string>(); }); } [Fact] public void GetExportsOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string>("Contract"); }); } [Fact] public void GetExportsOfTTMetadataView1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string, object>(); }); } [Fact] public void GetExportsOfTTMetadataView2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string, object>("Contract"); }); } [Fact] public void GetExportedValueOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValueOrDefault<string>(); }); } [Fact] public void GetExportedValueOrDefaultOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValueOrDefault<string>("Contract"); }); } [Fact] public void GetExportedValuesOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValues<string>(); }); } [Fact] public void GetExportedValuesOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValues<string>("Contract"); }); } [Fact] public void GetExports1_NullAsImportDefinitionArgument_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("definition", () => { container.GetExports((ImportDefinition)null); }); } [Fact] public void GetExports2_NullAsTypeArgument_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("type", () => { container.GetExports((Type)null, typeof(string), "ContractName"); }); } [Fact] public void GetExportOfT1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_DefinitionAskingForExactlyOneContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_DefinitionAskingForExactlyZeroOrOneContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports1_DefinitionAskingForExactlyZeroOrMoreContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports2_AskingForContractThatDoesNotExist_ShouldReturnNoExports() { var container = CreateCompositionContainer(); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); Assert.Empty(exports); } [Fact] public void GetExportsOfT1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>(); Assert.Empty(exports); } [Fact] public void GetExportsOfT2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string, object>(); Assert.Empty(exports); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string, object>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportedValueOfT1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForStringContractThatDoesNotExist_ShouldReturnNull() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<string>(); Assert.Null(exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForStringContractThatDoesNotExist_ShouldReturnNull() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<string>("Contract"); Assert.Null(exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForInt32ContractThatDoesNotExist_ShouldReturnZero() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<int>(); Assert.Equal(0, exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForInt32ContractThatDoesNotExist_ShouldReturnZero() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<int>("Contract"); Assert.Equal(0, exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExportedValues<string>(); Assert.Empty(exports); } [Fact] public void GetExportedValuesOfT2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value")); var export = container.GetExport<string>(); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var export = container.GetExport<string>("Contract"); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value")); var export = container.GetExport<string, object>(); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var export = container.GetExport<string, object>("Contract"); Assert.Equal("Value", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfT1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exports = container.GetExports<string>(); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfT2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exports = container.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValue = container.GetExportedValue<string>(); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValue = container.GetExportedValue<string>("Contract"); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValue = container.GetExportedValueOrDefault<string>(); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValue = container.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValues = container.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Value"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValues = container.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Value"); } [Fact] public void GetExportOfT1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_AskingForExactlyOneContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); Assert.Equal(0, container.GetExports(definition).Count()); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExports2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfT1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exports = container.GetExports<string>(); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfT2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exports = container.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); Assert.Null(container.GetExportedValueOrDefault<string>()); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); Assert.Null(container.GetExportedValueOrDefault<string>("Contract")); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exportedValues = container.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Value1", "Value2"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), "Value1", "Value2")); var exportedValues = container.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Value1", "Value2"); } [Fact] public void GetExports1_AskingForExactlyOneAndAll_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneAndAll_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ZeroOrOne); Assert.Equal(0, container.GetExports(definition).Count()); } [Fact] public void GetExports1_AskingForZeroOrMoreAndAll_ShouldReturnAll() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value1", "Value2", "Value3", "Value4", "Value5", "Value6"); } [Fact] public void GetExportOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var export = container.GetExport<string>(); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var export = container.GetExport<string>("Contract"); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfTTMetadataView1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var export = container.GetExport<string, object>(); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfTTMetadataView2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var export = container.GetExport<string, object>("Contract"); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExports2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var exports = container.GetExports<string>(); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports<string>("Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfTTMetadataView1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var exports = container.GetExports<string, object>(); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfTTMetadataView2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports<string, object>("Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportedValueOfT1_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValueOrDefault<string>(); }); } [Fact] public void GetExportedValueOrDefaultOfT2_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValueOrDefault<string>("Contract"); }); } [Fact] public void GetExportedValuesOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValues<string>(); }); } [Fact] public void GetExportedValuesOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValues<string>("Contract"); }); } [Fact] public void GetExportOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string>(); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string>("Contract"); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string, object>(); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string, object>("Contract"); Assert.Equal("Parent", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports1_AskingForZeroOrOneContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string>(); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportedValueOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValue<string>(); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValue<string>("Contract"); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValueOrDefault<string>(); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValues = child.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Parent"); } [Fact] public void GetExportedValuesOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValues = child.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Parent"); } [Fact] public void GetExportOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var export = child.GetExport<string>(); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var export = child.GetExport<string>("Contract"); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var export = child.GetExport<string, object>(); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var export = child.GetExport<string, object>("Contract"); Assert.Equal("Child", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child"); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExports2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exports = child.GetExports<string>(); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exports = child.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValue = child.GetExportedValue<string>(); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValue = child.GetExportedValue<string>("Contract"); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValue = child.GetExportedValueOrDefault<string>(); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValue = child.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValues = child.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Child", "Parent"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValues = child.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Child", "Parent"); } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/32295", TestRuntimes.Mono)] public void GetExportOfTTMetadataView1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport(typeof(string), metadata, "Value1"), new MicroExport(typeof(string), "Value2")); var export = container.GetExport<string, IMetadataView>(); var metadataExport = (Lazy<string, IMetadataView>)export; Assert.Equal("Value1", metadataExport.Value); Assert.Equal("MetadataValue1", metadataExport.Metadata.Metadata1); Assert.Equal("MetadataValue2", metadataExport.Metadata.Metadata2); Assert.Equal("MetadataValue3", metadataExport.Metadata.Metadata3); } [Fact] public void GetExportOfTTMetadataView2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var export = container.GetExport<string, IMetadataView>("Contract"); var metadataExport = (Lazy<string, IMetadataView>)export; Assert.Equal("Value1", metadataExport.Value); Assert.Equal("MetadataValue1", metadataExport.Metadata.Metadata1); Assert.Equal("MetadataValue2", metadataExport.Metadata.Metadata2); Assert.Equal("MetadataValue3", metadataExport.Metadata.Metadata3); } [Fact] public void GetExports1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var definition = ImportDefinitionFactory.Create( "Contract", new Dictionary<string, Type> { { "Metadata1", typeof(object) }, { "Metadata2", typeof(object) }, { "Metadata3", typeof(object) } } ); var exports = container.GetExports(definition); Assert.Equal(1, exports.Count()); var export = exports.First(); Assert.Equal("Value1", export.Value); EnumerableAssert.AreEqual(metadata, export.Metadata); } [Fact] public void GetExports2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var exports = container.GetExports(typeof(string), typeof(IMetadataView), "Contract"); Assert.Equal(1, exports.Count()); var export = exports.First(); IMetadataView exportMetadata = export.Metadata as IMetadataView; Assert.Equal("Value1", export.Value); Assert.NotNull(exportMetadata); Assert.Equal("MetadataValue1", exportMetadata.Metadata1); Assert.Equal("MetadataValue2", exportMetadata.Metadata2); Assert.Equal("MetadataValue3", exportMetadata.Metadata3); } [Fact] public void GetExportsOfTTMetadataView1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport(typeof(string), metadata, "Value1"), new MicroExport(typeof(string), "Value2")); var exports = container.GetExports<string, IMetadataView>(); Assert.Equal(1, exports.Count()); var export = (Lazy<string, IMetadataView>)exports.First(); Assert.Equal("Value1", export.Value); Assert.Equal("MetadataValue1", export.Metadata.Metadata1); Assert.Equal("MetadataValue2", export.Metadata.Metadata2); Assert.Equal("MetadataValue3", export.Metadata.Metadata3); } [Fact] public void GetExportsOfTTMetadataView2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var exports = container.GetExports<string, IMetadataView>("Contract"); Assert.Equal(1, exports.Count()); var export = (Lazy<string, IMetadataView>)exports.First(); Assert.Equal("Value1", export.Value); Assert.Equal("MetadataValue1", export.Metadata.Metadata1); Assert.Equal("MetadataValue2", export.Metadata.Metadata2); Assert.Equal("MetadataValue3", export.Metadata.Metadata3); } [Fact] public void GetExports1_AskingForExactlyOneAndAllWhenContainerEmpty_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneAndAllWhenContainerEmpty_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports1_AskingForExactlyOneAndAllWhenContainerEmpty_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void RemovePart_PartNotInContainerAsPartArgument_ShouldNotCauseImportsToBeRebound() { const string contractName = "Contract"; var exporter = PartFactory.CreateExporter(new MicroExport(contractName, 1)); var importer = PartFactory.CreateImporter(contractName); var container = ContainerFactory.Create(exporter, importer); Assert.Equal(1, importer.Value); Assert.Equal(1, importer.ImportSatisfiedCount); var doesNotExistInContainer = PartFactory.CreateExporter(new MicroExport(contractName, 2)); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(doesNotExistInContainer); container.Compose(batch); Assert.Equal(1, importer.ImportSatisfiedCount); } [Fact] public void RemovePart_PartInContainerQueueAsPartArgument_ShouldNotLeavePartInContainer() { const string contractName = "Contract"; var exporter = PartFactory.CreateExporter(new MicroExport(contractName, 1)); var importer = PartFactory.CreateImporter(true, contractName); var container = ContainerFactory.Create(exporter, importer); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.Null(importer.Value); Assert.Equal(2, importer.ImportSatisfiedCount); } [Fact] public void RemovePart_PartAlreadyRemovedAsPartArgument_ShouldNotThrow() { var exporter = PartFactory.CreateExporter(new MicroExport("Contract", 1)); var container = ContainerFactory.Create(exporter); Assert.Equal(1, container.GetExportedValue<int>("Contract")); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.False(container.IsPresent("Contract")); batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.False(container.IsPresent("Contract")); } [Fact] public void TryComposeSimple() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void TryComposeSimpleFail() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer); CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PartCannotSetImport, ErrorId.ImportEngine_ImportCardinalityMismatch, RetryMode.DoNotRetry, () => { container.Compose(batch); }); Assert.Equal(0, importer.Value); } [Fact] public void ComposeDisposableChildContainer() { var outerContainer = CreateCompositionContainer(); Int32Importer outerImporter = new Int32Importer(); CompositionBatch outerBatch = new CompositionBatch(); var key = outerBatch.AddExportedValue("Value", 42); outerBatch.AddPart(outerImporter); outerContainer.Compose(outerBatch); Assert.Equal(42, outerImporter.Value); Int32Importer innerImporter = new Int32Importer(); var innerContainer = new CompositionContainer(outerContainer); CompositionBatch innerBatch = new CompositionBatch(); innerBatch.AddPart(innerImporter); innerContainer.Compose(innerBatch); Assert.Equal(42, innerImporter.Value); Assert.Equal(42, outerImporter.Value); outerBatch = new CompositionBatch(); outerBatch.RemovePart(key); key = outerBatch.AddExportedValue("Value", -5); outerContainer.Compose(outerBatch); Assert.Equal(-5, innerImporter.Value); Assert.Equal(-5, outerImporter.Value); innerContainer.Dispose(); outerBatch = new CompositionBatch(); outerBatch.RemovePart(key); key = outerBatch.AddExportedValue("Value", 500); outerContainer.Compose(outerBatch); Assert.Equal(500, outerImporter.Value); Assert.Equal(-5, innerImporter.Value); } [Fact] public void RemoveValueTest() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); var key = batch.AddExportedValue("foo", "hello"); container.Compose(batch); var result = container.GetExportedValue<string>("foo"); Assert.Equal("hello", result); batch = new CompositionBatch(); batch.RemovePart(key); container.Compose(batch); Assert.False(container.IsPresent("foo")); batch = new CompositionBatch(); batch.RemovePart(key); // Remove should be idempotent container.Compose(batch); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfValueTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Equal(0, importer.ValueType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("ValueType"); }); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfNullableValueTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Null(importer.NullableValueType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("NullableValueType"); }); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfReferenceTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Null(importer.ReferenceType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("ReferenceType"); }); } [Fact] public void ExportsChanged_ExportNothing_ShouldNotFireExportsChanged() { var container = CreateCompositionContainer(); container.ExportsChanged += (sender, args) => { throw new NotImplementedException(); }; CompositionBatch batch = new CompositionBatch(); container.Compose(batch); } [Fact] public void ExportsChanged_ExportAdded_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_ExportRemoved_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; CompositionBatch batch = new CompositionBatch(); var part = batch.AddExportedValue("MyExport", new object()); container.Compose(batch); container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; batch = new CompositionBatch(); batch.RemovePart(part); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_ExportAddAnother_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); container.Compose(batch); container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; batch = new CompositionBatch(); // Adding another should cause an update. batch.AddExportedValue("MyExport", new object()); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_AddExportOnParent_ShouldFireExportsChangedOnBoth() { var parent = CreateCompositionContainer(); var child = new CompositionContainer(parent); IEnumerable<string> parentNames = null; parent.ExportsChanged += (sender, args) => { Assert.Same(parent, sender); parentNames = args.ChangedContractNames; }; IEnumerable<string> childNames = null; child.ExportsChanged += (sender, args) => { Assert.Same(child, sender); childNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); parent.Compose(batch); EnumerableAssert.AreEqual(parentNames, "MyExport"); EnumerableAssert.AreEqual(childNames, "MyExport"); } [Fact] public void ExportsChanged_AddExportOnChild_ShouldFireExportsChangedOnChildOnly() { var parent = CreateCompositionContainer(); var child = new CompositionContainer(parent); parent.ExportsChanged += (sender, args) => { throw new NotImplementedException(); }; IEnumerable<string> childNames = null; child.ExportsChanged += (sender, args) => { Assert.Same(child, sender); childNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport2", new object()); child.Compose(batch); EnumerableAssert.AreEqual(childNames, "MyExport2"); } [Fact] public void ExportsChanged_FromAggregateCatalog_ShouldFireExportsChangedOnce() { var cat = new AggregateCatalog(); var container = new CompositionContainer(cat); IEnumerable<string> changedNames = null; container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; var typeCatalog = new TypeCatalog(typeof(SimpleExporter)); cat.Catalogs.Add(typeCatalog); Assert.NotNull(changedNames); } [Fact] public void Dispose_BeforeCompose_CanBeCallMultipleTimes() { var container = ContainerFactory.Create(PartFactory.Create(), PartFactory.Create()); container.Dispose(); container.Dispose(); container.Dispose(); } [Fact] public void Dispose_AfterCompose_CanBeCallMultipleTimes() { var container = ContainerFactory.Create(PartFactory.Create(), PartFactory.Create()); container.Dispose(); container.Dispose(); container.Dispose(); } [Fact] public void Dispose_CallsGCSuppressFinalize() { bool finalizerCalled = false; var container = ContainerFactory.CreateDisposable(disposing => { if (!disposing) { finalizerCalled = true; } }); container.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Assert.False(finalizerCalled); } [Fact] public void Dispose_CallsDisposeBoolWithTrue() { var container = ContainerFactory.CreateDisposable(disposing => { Assert.True(disposing); }); container.Dispose(); } [Fact] public void Dispose_CallsDisposeBoolOnce() { int disposeCount = 0; var container = ContainerFactory.CreateDisposable(disposing => { disposeCount++; }); container.Dispose(); Assert.Equal(1, disposeCount); } [Fact] public void Dispose_ContainerAsExportedValue_CanBeDisposed() { using (var container = CreateCompositionContainer()) { CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<ICompositionService>(container); container.Compose(batch); } } [Fact] public void Dispose_ContainerAsPart_CanBeDisposed() { // Tests that when we re-enter CompositionContainer.Dispose, that we don't // stack overflow. using (var container = CreateCompositionContainer()) { var part = PartFactory.CreateExporter(new MicroExport(typeof(ICompositionService), container)); CompositionBatch batch = new CompositionBatch(); batch.AddPart(part); container.Compose(batch); Assert.Same(container, container.GetExportedValue<ICompositionService>()); } } [Fact] public void ICompositionService_ShouldNotBeImplicitlyExported() { var container = CreateCompositionContainer(); Assert.False(container.IsPresent<ICompositionService>()); } [Fact] public void CompositionContainer_ShouldNotBeImplicitlyExported() { var container = CreateCompositionContainer(); Assert.False(container.IsPresent<CompositionContainer>()); } [Fact] public void ICompositionService_ShouldNotBeImplicitlyImported() { var importer = PartFactory.CreateImporter<ICompositionService>(); var container = ContainerFactory.Create(importer); Assert.Null(importer.Value); } [Fact] public void CompositionContainer_ShouldNotBeImplicitlyImported() { var importer = PartFactory.CreateImporter<CompositionContainer>(); var container = ContainerFactory.Create(importer); Assert.Null(importer.Value); } [Fact] public void ICompositionService_CanBeExported() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<ICompositionService>(container); container.Compose(batch); Assert.Same(container, container.GetExportedValue<ICompositionService>()); } [Fact] public void CompositionContainer_CanBeExported() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<CompositionContainer>(container); container.Compose(batch); Assert.Same(container, container.GetExportedValue<CompositionContainer>()); } [Fact] public void ReleaseExport_Null_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("export", () => container.ReleaseExport(null)); } [Fact] public void ReleaseExports_Null_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("exports", () => container.ReleaseExports(null)); } [Fact] public void ReleaseExports_ElementNull_ShouldThrowArgument() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentException>("exports", () => container.ReleaseExports(new Export[] { null })); } public class OptionalImporter { [Import("ValueType", AllowDefault = true)] public int ValueType { get; set; } [Import("NullableValueType", AllowDefault = true)] public int? NullableValueType { get; set; } [Import("ReferenceType", AllowDefault = true)] public string ReferenceType { get; set; } } public class ExportSimpleIntWithException { [Export("SimpleInt")] public int SimpleInt { get { throw new NotImplementedException(); } } } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException) public void TryGetValueWithCatalogVerifyExecptionDuringGet() { var cat = CatalogFactory.CreateDefaultAttributed(); var container = new CompositionContainer(cat); CompositionAssert.ThrowsError(ErrorId.ImportEngine_PartCannotGetExportedValue, () => { container.GetExportedValue<int>("SimpleInt"); }); } [Fact] public void TryGetExportedValueWhileLockedForNotify() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { container.GetExportedValueOrDefault<int>(); })); container.Compose(batch); } [Fact] public void RawExportTests() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("foo", 1); container.Compose(batch); Lazy<int> export = container.GetExport<int>("foo"); Assert.Equal(1, export.Value); } [Export("MyExporterWithNoFoo")] public class MyExporterWithNoFoo { } [Export("MyExporterWithFoo")] [ExportMetadata("Foo", "Foo value")] public class MyExporterWithFoo { } [Export("MyExporterWithFooBar")] [ExportMetadata("Foo", "Foo value")] [ExportMetadata("Bar", "Bar value")] public class MyExporterWithFooBar { } // Silverlight doesn't support strongly typed metadata [Fact] public void ConverterExportTests() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("foo", 1); container.Compose(batch); var export = container.GetExport<int, IDictionary<string, object>>("foo"); Assert.Equal(1, export.Value); Assert.NotNull(export.Metadata); } [Fact] public void RemoveFromWrongContainerTest() { CompositionContainer d1 = CreateCompositionContainer(); CompositionContainer d2 = CreateCompositionContainer(); CompositionBatch batch1 = new CompositionBatch(); var valueKey = batch1.AddExportedValue("a", 1); d1.Compose(batch1); CompositionBatch batch2 = new CompositionBatch(); batch2.RemovePart(valueKey); // removing entry from wrong container, shoudl be a no-op d2.Compose(batch2); } [Fact] [Trait("Type", "Integration")] public void AddPartSimple() { var container = CreateCompositionContainer(); var importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); batch.AddPart(new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] [Trait("Type", "Integration")] public void AddPart() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(AttributedModelServices.CreatePart(importer)); batch.AddPart(new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void ComposeReentrantChildContainerDisposed() { var container = CreateCompositionContainer(); Int32Importer outerImporter = new Int32Importer(); Int32Importer innerImporter = new Int32Importer(); Int32Exporter exporter = new Int32Exporter(42); CompositionBatch batch = new CompositionBatch(); batch.AddPart(exporter); container.Compose(batch); CallbackExecuteCodeDuringCompose callback = new CallbackExecuteCodeDuringCompose(() => { using (CompositionContainer innerContainer = new CompositionContainer(container)) { CompositionBatch nestedBatch = new CompositionBatch(); nestedBatch.AddPart(innerImporter); innerContainer.Compose(nestedBatch); } Assert.Equal(42, innerImporter.Value); }); batch = new CompositionBatch(); batch.AddParts(outerImporter, callback); container.Compose(batch); Assert.Equal(42, outerImporter.Value); Assert.Equal(42, innerImporter.Value); } [Fact] public void ComposeSimple() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void ComposeSimpleFail() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PartCannotSetImport, // Cannot set Int32Importer.Value because ErrorId.ImportEngine_ImportCardinalityMismatch, // No exports are present that match contract RetryMode.DoNotRetry, () => { container.Compose(batch); }); } [Fact] public void ExceptionDuringNotify() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { throw new InvalidOperationException(); })); CompositionAssert.ThrowsError(ErrorId.ImportEngine_PartCannotActivate, // Cannot activate CallbackImportNotify because RetryMode.DoNotRetry, () => { container.Compose(batch); }); } [Fact] public void NeutralComposeWhileNotified() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { // Is this really a supported scenario? container.Compose(batch); })); container.Compose(batch); } public class PartWithReentrantCompose : ComposablePart { private CompositionContainer _container; public PartWithReentrantCompose(CompositionContainer container) { this._container = container; } public override IEnumerable<ExportDefinition> ExportDefinitions { get { this._container.ComposeExportedValue<string>("ExportedString"); return Enumerable.Empty<ExportDefinition>(); } } public override IEnumerable<ImportDefinition> ImportDefinitions { get { return Enumerable.Empty<ImportDefinition>(); } } public override object GetExportedValue(ExportDefinition definition) { throw new NotImplementedException(); } public override void SetImport(ImportDefinition definition, IEnumerable<Export> exports) { throw new NotImplementedException(); } } [Export] public class SimpleExporter { } [Fact] public void ThreadSafeCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, true); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void ThreadSafeCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.IsThreadSafe); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void DisableSilentRejectionCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void DisableSilentRejectionThreadSafeCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void CompositionOptionsInvalidValue() { Assert.Throws<ArgumentOutOfRangeException>("compositionOptions", () => new CompositionContainer((CompositionOptions)0x0400)); } [Fact] public void ReentrantencyDisabledWhileComposing() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(new PartWithReentrantCompose(container)); ExceptionAssert.Throws<InvalidOperationException>(() => container.Compose(batch)); } private static Expression<Func<ExportDefinition, bool>> ConstraintFromContract(string contractName) { return ConstraintFactory.Create(contractName); } private static string ContractFromType(Type type) { return AttributedModelServices.GetContractName(type); } private static CompositionContainer CreateCompositionContainer() { return new CompositionContainer(); } public interface IMetadataView { string Metadata1 { get; } string Metadata2 { get; } string Metadata3 { get; } } [Fact] public void ComposeExportedValueOfT_NullStringAsExportedValueArgument_VerifyCanPullOnValue() { var container = CreateCompositionContainer(); var expectation = (string)null; container.ComposeExportedValue<string>(expectation); var actualValue = container.GetExportedValue<string>(); Assert.Equal(expectation, actualValue); } [Fact] public void ComposeExportedValueOfT_StringAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<string>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectation); var actualValue = container.GetExportedValue<string>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_StringAsIEnumerableOfCharAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<string>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<IEnumerable<char>>(expectation); var actualValue = container.GetExportedValue<IEnumerable<char>>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_ObjectAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<object>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); expectations.Add(42); expectations.Add(new object()); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<object>(expectation); var actualValue = container.GetExportedValue<object>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_ExportedValue_ExportedUnderDefaultContractName() { string expectedContractName = AttributedModelServices.GetContractName(typeof(string)); var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(expectedContractName, exports.Single().Definition.ContractName); } [Fact] public void ComposeExportedValueOfT_ExportedValue_ExportContainsEmptyMetadata() { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(1, exports.Single().Metadata.Count); // contains type identity } [Fact] public void ComposeExportedValueOfT_ExportedValue_LazyContainsEmptyMetadata() { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var lazy = container.GetExport<string, IDictionary<string, object>>(); Assert.Equal(1, lazy.Metadata.Count); // contains type identity } [Fact] public void ComposeExportedValueOfT_ExportedValue_ImportsAreNotDiscovered() { var container = CreateCompositionContainer(); var importer = new PartWithRequiredImport(); container.ComposeExportedValue<object>(importer); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); // we only get one if the import was not discovered since the import is not satisfied } [Fact] public void ComposeExportedValueOfT_NullAsContractName_ThrowsArgumentNullException() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("contractName", () => container.ComposeExportedValue<string>((string)null, "Value")); } [Fact] public void ComposeExportedValueOfT_EmptyStringAsContractName_ThrowsArgumentException() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentException>("contractName", () => container.ComposeExportedValue<string>(string.Empty, "Value")); } [Fact] public void ComposeExportedValueOfT_ValidContractName_ValidExportedValue_VerifyCanPullOnValue() { var expectations = new List<Tuple<string, string>>(); expectations.Add(new Tuple<string, string>(" ", (string)null)); expectations.Add(new Tuple<string, string>(" ", string.Empty)); expectations.Add(new Tuple<string, string>(" ", "Value")); expectations.Add(new Tuple<string, string>("ContractName", (string)null)); expectations.Add(new Tuple<string, string>("ContractName", string.Empty)); expectations.Add(new Tuple<string, string>("ContractName", "Value")); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectation.Item1, expectation.Item2); var actualValue = container.GetExportedValue<string>(expectation.Item1); Assert.Equal(expectation.Item2, actualValue); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => container.GetExportedValue<string>()); } } [Fact] public void ComposeExportedValueOfT_ValidContractName_ExportedValue_ExportedUnderSpecifiedContractName() { string expectedContractName = "ContractName"; var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectedContractName, "Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(expectedContractName, exports.Single().Definition.ContractName); } [Fact] public void ComposeExportedValueOfT_ValidContractName_ExportedValue_ImportsAreNotDiscovered() { var container = CreateCompositionContainer(); var importer = new PartWithRequiredImport(); container.ComposeExportedValue<object>("ContractName", importer); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); // we only get one if the import was not discovered since the import is not satisfied } [Fact] public void TestExportedValueCachesNullValue() { var container = ContainerFactory.Create(); var exporter = new ExportsMutableProperty(); exporter.Property = null; container.ComposeParts(exporter); Assert.Null(container.GetExportedValue<string>("Property")); exporter.Property = "Value1"; // Exported value should have been cached and so it shouldn't change Assert.Null(container.GetExportedValue<string>("Property")); } [Fact] public void TestExportedValueUsingWhereClause_ExportSuccessful() { CompositionContainer container = new CompositionContainer(new TypeCatalog(typeof(MefCollection<,>))); IMefCollection<DerivedClass, BaseClass> actualValue = container.GetExportedValue<IMefCollection<DerivedClass, BaseClass>>("UsingWhereClause"); Assert.NotNull(actualValue); Assert.IsType<MefCollection<DerivedClass, BaseClass>>(actualValue); } public interface IMefCollection { } public interface IMefCollection<TC, TP> : IList<TC>, IMefCollection where TC : TP { } public class BaseClass { } public class DerivedClass : BaseClass { } [Export("UsingWhereClause", typeof(IMefCollection<,>))] public class MefCollection<TC, TP> : ObservableCollection<TC>, IMefCollection<TC, TP> where TC : TP { } public class ExportsMutableProperty { [Export("Property")] public string Property { get; set; } } public class PartWithRequiredImport { [Import] public object Import { get; set; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.Composition.Factories; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition.Primitives; using System.Linq; using System.Linq.Expressions; using System.UnitTesting; using Xunit; namespace System.ComponentModel.Composition { public class CompositionContainerTests { [Fact] public void Constructor2_ArrayWithNullElementAsProvidersArgument_ShouldThrowArgumentException() { Assert.Throws<ArgumentException>("providers", () => { new CompositionContainer(new ExportProvider[] { null }); }); } [Fact] public void Constructor3_ArrayWithNullElementAsProvidersArgument_ShouldThrowArgumentException() { var catalog = CatalogFactory.Create(); Assert.Throws<ArgumentException>("providers", () => { new CompositionContainer(catalog, new ExportProvider[] { null }); }); } [Fact] public void Constructor2_ArrayAsProvidersArgument_ShouldNotAllowModificationAfterConstruction() { var providers = new ExportProvider[] { ExportProviderFactory.Create() }; var container = new CompositionContainer(providers); providers[0] = null; Assert.NotNull(container.Providers[0]); } [Fact] public void Constructor3_ArrayAsProvidersArgument_ShouldNotAllowModificationAfterConstruction() { var providers = new ExportProvider[] { ExportProviderFactory.Create() }; var container = new CompositionContainer(CatalogFactory.Create(), providers); providers[0] = null; Assert.NotNull(container.Providers[0]); } [Fact] public void Constructor1_ShouldSetProvidersPropertyToEmptyCollection() { var container = new CompositionContainer(); Assert.Empty(container.Providers); } [Fact] public void Constructor2_EmptyArrayAsProvidersArgument_ShouldSetProvidersPropertyToEmpty() { var container = new CompositionContainer(new ExportProvider[0]); Assert.Empty(container.Providers); } [Fact] public void Constructor3_EmptyArrayAsProvidersArgument_ShouldSetProvidersPropertyToEmpty() { var container = new CompositionContainer(CatalogFactory.Create(), new ExportProvider[0]); Assert.Empty(container.Providers); } [Fact] public void Constructor1_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer(); Assert.Null(container.Catalog); } [Fact] public void Constructor2_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer(new ExportProvider[0]); Assert.Null(container.Catalog); } [Fact] public void Constructor3_NullAsCatalogArgument_ShouldSetCatalogPropertyToNull() { var container = new CompositionContainer((ComposablePartCatalog)null, new ExportProvider[0]); Assert.Null(container.Catalog); } [Fact] public void Constructor3_ValueAsCatalogArgument_ShouldSetCatalogProperty() { var expectations = Expectations.GetCatalogs(); foreach (var e in expectations) { var container = new CompositionContainer(e, new ExportProvider[0]); Assert.Same(e, container.Catalog); } } [Fact] public void Catalog_WhenDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { var catalog = container.Catalog; }); } [Fact] public void Providers_WhenDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { var providers = container.Providers; }); } [Fact] public void AddPart1_ImportOnlyPart_ShouldNotGetGarbageCollected() { var container = CreateCompositionContainer(); var import = PartFactory.CreateImporter("Value", ImportCardinality.ZeroOrMore); CompositionBatch batch = new CompositionBatch(); batch.AddPart(import); container.Compose(batch); var weakRef = new WeakReference(import); import = null; GC.Collect(); GC.WaitForPendingFinalizers(); Assert.NotNull(weakRef.Target); GC.KeepAlive(container); } [Fact] public void Compose_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); CompositionBatch batch = new CompositionBatch(); ExceptionAssert.ThrowsDisposed(container, () => { container.Compose(batch); }); } [Fact] public void GetExportOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); var definition = ImportDefinitionFactory.Create(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports(definition); }); } [Fact] public void GetExports2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports(typeof(string), typeof(object), "Contract"); }); } [Fact] public void GetExportsOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string>(); }); } [Fact] public void GetExportsOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string>("Contract"); }); } [Fact] public void GetExportsOfTTMetadataView1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string, object>(); }); } [Fact] public void GetExportsOfTTMetadataView2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExports<string, object>("Contract"); }); } [Fact] public void GetExportedValueOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValueOrDefault<string>(); }); } [Fact] public void GetExportedValueOrDefaultOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValueOrDefault<string>("Contract"); }); } [Fact] public void GetExportedValuesOfT1_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValues<string>(); }); } [Fact] public void GetExportedValuesOfT2_WhenContainerDisposed_ShouldThrowObjectDisposed() { var container = CreateCompositionContainer(); container.Dispose(); ExceptionAssert.ThrowsDisposed(container, () => { container.GetExportedValues<string>("Contract"); }); } [Fact] public void GetExports1_NullAsImportDefinitionArgument_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("definition", () => { container.GetExports((ImportDefinition)null); }); } [Fact] public void GetExports2_NullAsTypeArgument_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("type", () => { container.GetExports((Type)null, typeof(string), "ContractName"); }); } [Fact] public void GetExportOfT1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_DefinitionAskingForExactlyOneContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_DefinitionAskingForExactlyZeroOrOneContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports1_DefinitionAskingForExactlyZeroOrMoreContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports2_AskingForContractThatDoesNotExist_ShouldReturnNoExports() { var container = CreateCompositionContainer(); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); Assert.Empty(exports); } [Fact] public void GetExportsOfT1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>(); Assert.Empty(exports); } [Fact] public void GetExportsOfT2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string, object>(); Assert.Empty(exports); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string, object>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportedValueOfT1_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_AskingForContractThatDoesNotExist_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForStringContractThatDoesNotExist_ShouldReturnNull() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<string>(); Assert.Null(exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForStringContractThatDoesNotExist_ShouldReturnNull() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<string>("Contract"); Assert.Null(exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForInt32ContractThatDoesNotExist_ShouldReturnZero() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<int>(); Assert.Equal(0, exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForInt32ContractThatDoesNotExist_ShouldReturnZero() { var container = CreateCompositionContainer(); var exportedValue = container.GetExportedValueOrDefault<int>("Contract"); Assert.Equal(0, exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExportedValues<string>(); Assert.Empty(exports); } [Fact] public void GetExportedValuesOfT2_AskingForContractThatDoesNotExist_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var exports = container.GetExports<string>("Contract"); Assert.Empty(exports); } [Fact] public void GetExportOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value")); var export = container.GetExport<string>(); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var export = container.GetExport<string>("Contract"); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value")); var export = container.GetExport<string, object>(); Assert.Equal("Value", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var export = container.GetExport<string, object>("Contract"); Assert.Equal("Value", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExports2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfT1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exports = container.GetExports<string>(); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfT2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exports = container.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exports = container.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Value"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValue = container.GetExportedValue<string>(); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValue = container.GetExportedValue<string>("Contract"); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValue = container.GetExportedValueOrDefault<string>(); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithOneExport_ShouldReturnExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValue = container.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Value", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value")); var exportedValues = container.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Value"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithOneExport_ShouldReturnOneExport() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value")); var exportedValues = container.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Value"); } [Fact] public void GetExportOfT1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>(); }); } [Fact] public void GetExportOfT2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string>("Contract"); }); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(ContractFromType(typeof(string)), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>(); }); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExport<string, object>("Contract"); }); } [Fact] public void GetExports1_AskingForExactlyOneContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); Assert.Equal(0, container.GetExports(definition).Count()); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExports2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfT1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exports = container.GetExports<string>(); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfT2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exports = container.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); var exports = container.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Value1", "Value2"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_AskingForContractWithMultipleExports_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); Assert.Null(container.GetExportedValueOrDefault<string>()); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithMultipleExports_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract", "Value1", "Value2")); Assert.Null(container.GetExportedValueOrDefault<string>("Contract")); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport(typeof(string), "Value1", "Value2")); var exportedValues = container.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Value1", "Value2"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithMultipleExports_ShouldReturnMultipleExports() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), "Value1", "Value2")); var exportedValues = container.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Value1", "Value2"); } [Fact] public void GetExports1_AskingForExactlyOneAndAll_ShouldThrowCardinalityMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneAndAll_ShouldReturnZero() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ZeroOrOne); Assert.Equal(0, container.GetExports(definition).Count()); } [Fact] public void GetExports1_AskingForZeroOrMoreAndAll_ShouldReturnAll() { var container = ContainerFactory.Create(new MicroExport("Contract1", "Value1", "Value2", "Value3"), new MicroExport("Contract2", "Value4", "Value5", "Value6")); var definition = ImportDefinitionFactory.Create(import => true, ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); ExportsAssert.AreEqual(exports, "Value1", "Value2", "Value3", "Value4", "Value5", "Value6"); } [Fact] public void GetExportOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var export = container.GetExport<string>(); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var export = container.GetExport<string>("Contract"); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfTTMetadataView1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var export = container.GetExport<string, object>(); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportOfTTMetadataView2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var export = container.GetExport<string, object>("Contract"); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExports2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports(typeof(string), (Type)null, "Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var exports = container.GetExports<string>(); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports<string>("Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfTTMetadataView1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); var exports = container.GetExports<string, object>(); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportsOfTTMetadataView2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); var exports = container.GetExports<string, object>("Contract"); Assert.Equal(1, exports.Count()); var export = exports.ElementAt(0); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { var value = export.Value; }); } [Fact] public void GetExportedValueOfT1_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValue<string>(); }); } [Fact] public void GetExportedValueOfT2_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValue<string>("Contract"); }); } [Fact] public void GetExportedValueOrDefaultOfT1_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValueOrDefault<string>(); }); } [Fact] public void GetExportedValueOrDefaultOfT2_StringAsTTypeArgumentAskingForContractWithObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValueOrDefault<string>("Contract"); }); } [Fact] public void GetExportedValuesOfT1_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport(typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValues<string>(); }); } [Fact] public void GetExportedValuesOfT2_StringAsTTypeArgumentAskingForContractWithOneObjectExport_ShouldThrowContractMismatch() { var container = ContainerFactory.Create(new MicroExport("Contract", typeof(string), new object())); ExceptionAssert.Throws<CompositionContractMismatchException>(() => { container.GetExportedValues<string>("Contract"); }); } [Fact] public void GetExportOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string>(); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string>("Contract"); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string, object>(); Assert.Equal("Parent", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var export = child.GetExport<string, object>("Contract"); Assert.Equal("Parent", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports1_AskingForZeroOrOneContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExports2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string>(); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exports = child.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Parent"); } [Fact] public void GetExportedValueOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValue<string>(); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValue<string>("Contract"); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValueOrDefault<string>(); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValue = child.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Parent", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent); var exportedValues = child.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Parent"); } [Fact] public void GetExportedValuesOfT2_AskingForContractFromChildWithExportInParentContainer_ShouldReturnExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent); var exportedValues = child.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Parent"); } [Fact] public void GetExportOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var export = child.GetExport<string>(); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var export = child.GetExport<string>("Contract"); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfTTMetadataView1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var export = child.GetExport<string, object>(); Assert.Equal("Child", export.Value); } [Fact] public void GetExportOfTTMetadataView2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var export = child.GetExport<string, object>("Contract"); Assert.Equal("Child", export.Value); } [Fact] public void GetExports1_AskingForExactlyOneContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ExactlyOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child"); } [Fact] public void GetExports1_AskingForZeroOrOneContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrOne); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child"); } [Fact] public void GetExports1_AskingForZeroOrMoreContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var definition = ImportDefinitionFactory.Create("Contract", ImportCardinality.ZeroOrMore); var exports = child.GetExports(definition); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExports2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports(typeof(string), (Type)null, "Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exports = child.GetExports<string>(); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports<string>("Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfTTMetadataView1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exports = child.GetExports<string, object>(); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportsOfTTMetadataView2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exports = child.GetExports<string, object>("Contract"); ExportsAssert.AreEqual(exports, "Child", "Parent"); } [Fact] public void GetExportedValueOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValue = child.GetExportedValue<string>(); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValue = child.GetExportedValue<string>("Contract"); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValue = child.GetExportedValueOrDefault<string>(); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValueOrDefaultOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnChildExport() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValue = child.GetExportedValueOrDefault<string>("Contract"); Assert.Equal("Child", exportedValue); } [Fact] public void GetExportedValuesOfT1_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport(typeof(string), "Parent")); var child = ContainerFactory.Create(parent, new MicroExport(typeof(string), "Child")); var exportedValues = child.GetExportedValues<string>(); EnumerableAssert.AreEqual(exportedValues, "Child", "Parent"); } [Fact] public void GetExportedValuesOfT2_AskingForContractWithExportInBothParentAndChildContainers_ShouldReturnBothExports() { var parent = ContainerFactory.Create(new MicroExport("Contract", "Parent")); var child = ContainerFactory.Create(parent, new MicroExport("Contract", "Child")); var exportedValues = child.GetExportedValues<string>("Contract"); EnumerableAssert.AreEqual(exportedValues, "Child", "Parent"); } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/32295", TestRuntimes.Mono)] public void GetExportOfTTMetadataView1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport(typeof(string), metadata, "Value1"), new MicroExport(typeof(string), "Value2")); var export = container.GetExport<string, IMetadataView>(); var metadataExport = (Lazy<string, IMetadataView>)export; Assert.Equal("Value1", metadataExport.Value); Assert.Equal("MetadataValue1", metadataExport.Metadata.Metadata1); Assert.Equal("MetadataValue2", metadataExport.Metadata.Metadata2); Assert.Equal("MetadataValue3", metadataExport.Metadata.Metadata3); } [Fact] public void GetExportOfTTMetadataView2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var export = container.GetExport<string, IMetadataView>("Contract"); var metadataExport = (Lazy<string, IMetadataView>)export; Assert.Equal("Value1", metadataExport.Value); Assert.Equal("MetadataValue1", metadataExport.Metadata.Metadata1); Assert.Equal("MetadataValue2", metadataExport.Metadata.Metadata2); Assert.Equal("MetadataValue3", metadataExport.Metadata.Metadata3); } [Fact] public void GetExports1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var definition = ImportDefinitionFactory.Create( "Contract", new Dictionary<string, Type> { { "Metadata1", typeof(object) }, { "Metadata2", typeof(object) }, { "Metadata3", typeof(object) } } ); var exports = container.GetExports(definition); Assert.Equal(1, exports.Count()); var export = exports.First(); Assert.Equal("Value1", export.Value); EnumerableAssert.AreEqual(metadata, export.Metadata); } [Fact] public void GetExports2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var exports = container.GetExports(typeof(string), typeof(IMetadataView), "Contract"); Assert.Equal(1, exports.Count()); var export = exports.First(); IMetadataView exportMetadata = export.Metadata as IMetadataView; Assert.Equal("Value1", export.Value); Assert.NotNull(exportMetadata); Assert.Equal("MetadataValue1", exportMetadata.Metadata1); Assert.Equal("MetadataValue2", exportMetadata.Metadata2); Assert.Equal("MetadataValue3", exportMetadata.Metadata3); } [Fact] public void GetExportsOfTTMetadataView1_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport(typeof(string), metadata, "Value1"), new MicroExport(typeof(string), "Value2")); var exports = container.GetExports<string, IMetadataView>(); Assert.Equal(1, exports.Count()); var export = (Lazy<string, IMetadataView>)exports.First(); Assert.Equal("Value1", export.Value); Assert.Equal("MetadataValue1", export.Metadata.Metadata1); Assert.Equal("MetadataValue2", export.Metadata.Metadata2); Assert.Equal("MetadataValue3", export.Metadata.Metadata3); } [Fact] public void GetExportsOfTTMetadataView2_TypeAsMetadataViewTypeArgument_IsUsedAsMetadataConstraint() { var metadata = new Dictionary<string, object>(); metadata.Add("Metadata1", "MetadataValue1"); metadata.Add("Metadata2", "MetadataValue2"); metadata.Add("Metadata3", "MetadataValue3"); var container = ContainerFactory.Create(new MicroExport("Another", metadata, "Value1"), new MicroExport("Contract", metadata, "Value1"), new MicroExport("Contract", "Value2")); var exports = container.GetExports<string, IMetadataView>("Contract"); Assert.Equal(1, exports.Count()); var export = (Lazy<string, IMetadataView>)exports.First(); Assert.Equal("Value1", export.Value); Assert.Equal("MetadataValue1", export.Metadata.Metadata1); Assert.Equal("MetadataValue2", export.Metadata.Metadata2); Assert.Equal("MetadataValue3", export.Metadata.Metadata3); } [Fact] public void GetExports1_AskingForExactlyOneAndAllWhenContainerEmpty_ShouldThrowCardinalityMismatch() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ExactlyOne); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExports(definition); }); } [Fact] public void GetExports1_AskingForZeroOrOneAndAllWhenContainerEmpty_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ZeroOrOne); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void GetExports1_AskingForExactlyOneAndAllWhenContainerEmpty_ShouldReturnEmpty() { var container = CreateCompositionContainer(); var definition = ImportDefinitionFactory.Create(export => true, ImportCardinality.ZeroOrMore); var exports = container.GetExports(definition); Assert.Empty(exports); } [Fact] public void RemovePart_PartNotInContainerAsPartArgument_ShouldNotCauseImportsToBeRebound() { const string contractName = "Contract"; var exporter = PartFactory.CreateExporter(new MicroExport(contractName, 1)); var importer = PartFactory.CreateImporter(contractName); var container = ContainerFactory.Create(exporter, importer); Assert.Equal(1, importer.Value); Assert.Equal(1, importer.ImportSatisfiedCount); var doesNotExistInContainer = PartFactory.CreateExporter(new MicroExport(contractName, 2)); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(doesNotExistInContainer); container.Compose(batch); Assert.Equal(1, importer.ImportSatisfiedCount); } [Fact] public void RemovePart_PartInContainerQueueAsPartArgument_ShouldNotLeavePartInContainer() { const string contractName = "Contract"; var exporter = PartFactory.CreateExporter(new MicroExport(contractName, 1)); var importer = PartFactory.CreateImporter(true, contractName); var container = ContainerFactory.Create(exporter, importer); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.Null(importer.Value); Assert.Equal(2, importer.ImportSatisfiedCount); } [Fact] public void RemovePart_PartAlreadyRemovedAsPartArgument_ShouldNotThrow() { var exporter = PartFactory.CreateExporter(new MicroExport("Contract", 1)); var container = ContainerFactory.Create(exporter); Assert.Equal(1, container.GetExportedValue<int>("Contract")); CompositionBatch batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.False(container.IsPresent("Contract")); batch = new CompositionBatch(); batch.RemovePart(exporter); container.Compose(batch); Assert.False(container.IsPresent("Contract")); } [Fact] public void TryComposeSimple() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void TryComposeSimpleFail() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer); CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PartCannotSetImport, ErrorId.ImportEngine_ImportCardinalityMismatch, RetryMode.DoNotRetry, () => { container.Compose(batch); }); Assert.Equal(0, importer.Value); } [Fact] public void ComposeDisposableChildContainer() { var outerContainer = CreateCompositionContainer(); Int32Importer outerImporter = new Int32Importer(); CompositionBatch outerBatch = new CompositionBatch(); var key = outerBatch.AddExportedValue("Value", 42); outerBatch.AddPart(outerImporter); outerContainer.Compose(outerBatch); Assert.Equal(42, outerImporter.Value); Int32Importer innerImporter = new Int32Importer(); var innerContainer = new CompositionContainer(outerContainer); CompositionBatch innerBatch = new CompositionBatch(); innerBatch.AddPart(innerImporter); innerContainer.Compose(innerBatch); Assert.Equal(42, innerImporter.Value); Assert.Equal(42, outerImporter.Value); outerBatch = new CompositionBatch(); outerBatch.RemovePart(key); key = outerBatch.AddExportedValue("Value", -5); outerContainer.Compose(outerBatch); Assert.Equal(-5, innerImporter.Value); Assert.Equal(-5, outerImporter.Value); innerContainer.Dispose(); outerBatch = new CompositionBatch(); outerBatch.RemovePart(key); key = outerBatch.AddExportedValue("Value", 500); outerContainer.Compose(outerBatch); Assert.Equal(500, outerImporter.Value); Assert.Equal(-5, innerImporter.Value); } [Fact] public void RemoveValueTest() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); var key = batch.AddExportedValue("foo", "hello"); container.Compose(batch); var result = container.GetExportedValue<string>("foo"); Assert.Equal("hello", result); batch = new CompositionBatch(); batch.RemovePart(key); container.Compose(batch); Assert.False(container.IsPresent("foo")); batch = new CompositionBatch(); batch.RemovePart(key); // Remove should be idempotent container.Compose(batch); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfValueTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Equal(0, importer.ValueType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("ValueType"); }); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfNullableValueTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Null(importer.NullableValueType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("NullableValueType"); }); } [Fact] [Trait("Type", "Integration")] public void OptionalImportsOfReferenceTypeBoundToDefaultValueShouldNotAffectAvailableValues() { var container = CreateCompositionContainer(); var importer = new OptionalImporter(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); container.Compose(batch); Assert.Null(importer.ReferenceType); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<int>("ReferenceType"); }); } [Fact] public void ExportsChanged_ExportNothing_ShouldNotFireExportsChanged() { var container = CreateCompositionContainer(); container.ExportsChanged += (sender, args) => { throw new NotImplementedException(); }; CompositionBatch batch = new CompositionBatch(); container.Compose(batch); } [Fact] public void ExportsChanged_ExportAdded_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_ExportRemoved_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; CompositionBatch batch = new CompositionBatch(); var part = batch.AddExportedValue("MyExport", new object()); container.Compose(batch); container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; batch = new CompositionBatch(); batch.RemovePart(part); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_ExportAddAnother_ShouldFireExportsChanged() { var container = CreateCompositionContainer(); IEnumerable<string> changedNames = null; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); container.Compose(batch); container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; batch = new CompositionBatch(); // Adding another should cause an update. batch.AddExportedValue("MyExport", new object()); container.Compose(batch); EnumerableAssert.AreEqual(changedNames, "MyExport"); } [Fact] public void ExportsChanged_AddExportOnParent_ShouldFireExportsChangedOnBoth() { var parent = CreateCompositionContainer(); var child = new CompositionContainer(parent); IEnumerable<string> parentNames = null; parent.ExportsChanged += (sender, args) => { Assert.Same(parent, sender); parentNames = args.ChangedContractNames; }; IEnumerable<string> childNames = null; child.ExportsChanged += (sender, args) => { Assert.Same(child, sender); childNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport", new object()); parent.Compose(batch); EnumerableAssert.AreEqual(parentNames, "MyExport"); EnumerableAssert.AreEqual(childNames, "MyExport"); } [Fact] public void ExportsChanged_AddExportOnChild_ShouldFireExportsChangedOnChildOnly() { var parent = CreateCompositionContainer(); var child = new CompositionContainer(parent); parent.ExportsChanged += (sender, args) => { throw new NotImplementedException(); }; IEnumerable<string> childNames = null; child.ExportsChanged += (sender, args) => { Assert.Same(child, sender); childNames = args.ChangedContractNames; }; CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("MyExport2", new object()); child.Compose(batch); EnumerableAssert.AreEqual(childNames, "MyExport2"); } [Fact] public void ExportsChanged_FromAggregateCatalog_ShouldFireExportsChangedOnce() { var cat = new AggregateCatalog(); var container = new CompositionContainer(cat); IEnumerable<string> changedNames = null; container.ExportsChanged += (sender, args) => { Assert.Same(container, sender); Assert.Null(changedNames); Assert.NotNull(args.AddedExports); Assert.NotNull(args.RemovedExports); Assert.NotNull(args.ChangedContractNames); changedNames = args.ChangedContractNames; }; var typeCatalog = new TypeCatalog(typeof(SimpleExporter)); cat.Catalogs.Add(typeCatalog); Assert.NotNull(changedNames); } [Fact] public void Dispose_BeforeCompose_CanBeCallMultipleTimes() { var container = ContainerFactory.Create(PartFactory.Create(), PartFactory.Create()); container.Dispose(); container.Dispose(); container.Dispose(); } [Fact] public void Dispose_AfterCompose_CanBeCallMultipleTimes() { var container = ContainerFactory.Create(PartFactory.Create(), PartFactory.Create()); container.Dispose(); container.Dispose(); container.Dispose(); } [Fact] public void Dispose_CallsGCSuppressFinalize() { bool finalizerCalled = false; var container = ContainerFactory.CreateDisposable(disposing => { if (!disposing) { finalizerCalled = true; } }); container.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Assert.False(finalizerCalled); } [Fact] public void Dispose_CallsDisposeBoolWithTrue() { var container = ContainerFactory.CreateDisposable(disposing => { Assert.True(disposing); }); container.Dispose(); } [Fact] public void Dispose_CallsDisposeBoolOnce() { int disposeCount = 0; var container = ContainerFactory.CreateDisposable(disposing => { disposeCount++; }); container.Dispose(); Assert.Equal(1, disposeCount); } [Fact] public void Dispose_ContainerAsExportedValue_CanBeDisposed() { using (var container = CreateCompositionContainer()) { CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<ICompositionService>(container); container.Compose(batch); } } [Fact] public void Dispose_ContainerAsPart_CanBeDisposed() { // Tests that when we re-enter CompositionContainer.Dispose, that we don't // stack overflow. using (var container = CreateCompositionContainer()) { var part = PartFactory.CreateExporter(new MicroExport(typeof(ICompositionService), container)); CompositionBatch batch = new CompositionBatch(); batch.AddPart(part); container.Compose(batch); Assert.Same(container, container.GetExportedValue<ICompositionService>()); } } [Fact] public void ICompositionService_ShouldNotBeImplicitlyExported() { var container = CreateCompositionContainer(); Assert.False(container.IsPresent<ICompositionService>()); } [Fact] public void CompositionContainer_ShouldNotBeImplicitlyExported() { var container = CreateCompositionContainer(); Assert.False(container.IsPresent<CompositionContainer>()); } [Fact] public void ICompositionService_ShouldNotBeImplicitlyImported() { var importer = PartFactory.CreateImporter<ICompositionService>(); var container = ContainerFactory.Create(importer); Assert.Null(importer.Value); } [Fact] public void CompositionContainer_ShouldNotBeImplicitlyImported() { var importer = PartFactory.CreateImporter<CompositionContainer>(); var container = ContainerFactory.Create(importer); Assert.Null(importer.Value); } [Fact] public void ICompositionService_CanBeExported() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<ICompositionService>(container); container.Compose(batch); Assert.Same(container, container.GetExportedValue<ICompositionService>()); } [Fact] public void CompositionContainer_CanBeExported() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue<CompositionContainer>(container); container.Compose(batch); Assert.Same(container, container.GetExportedValue<CompositionContainer>()); } [Fact] public void ReleaseExport_Null_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("export", () => container.ReleaseExport(null)); } [Fact] public void ReleaseExports_Null_ShouldThrowArgumentNull() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("exports", () => container.ReleaseExports(null)); } [Fact] public void ReleaseExports_ElementNull_ShouldThrowArgument() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentException>("exports", () => container.ReleaseExports(new Export[] { null })); } public class OptionalImporter { [Import("ValueType", AllowDefault = true)] public int ValueType { get; set; } [Import("NullableValueType", AllowDefault = true)] public int? NullableValueType { get; set; } [Import("ReferenceType", AllowDefault = true)] public string ReferenceType { get; set; } } public class ExportSimpleIntWithException { [Export("SimpleInt")] public int SimpleInt { get { throw new NotImplementedException(); } } } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException) public void TryGetValueWithCatalogVerifyExecptionDuringGet() { var cat = CatalogFactory.CreateDefaultAttributed(); var container = new CompositionContainer(cat); CompositionAssert.ThrowsError(ErrorId.ImportEngine_PartCannotGetExportedValue, () => { container.GetExportedValue<int>("SimpleInt"); }); } [Fact] public void TryGetExportedValueWhileLockedForNotify() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { container.GetExportedValueOrDefault<int>(); })); container.Compose(batch); } [Fact] public void RawExportTests() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("foo", 1); container.Compose(batch); Lazy<int> export = container.GetExport<int>("foo"); Assert.Equal(1, export.Value); } [Export("MyExporterWithNoFoo")] public class MyExporterWithNoFoo { } [Export("MyExporterWithFoo")] [ExportMetadata("Foo", "Foo value")] public class MyExporterWithFoo { } [Export("MyExporterWithFooBar")] [ExportMetadata("Foo", "Foo value")] [ExportMetadata("Bar", "Bar value")] public class MyExporterWithFooBar { } // Silverlight doesn't support strongly typed metadata [Fact] public void ConverterExportTests() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("foo", 1); container.Compose(batch); var export = container.GetExport<int, IDictionary<string, object>>("foo"); Assert.Equal(1, export.Value); Assert.NotNull(export.Metadata); } [Fact] public void RemoveFromWrongContainerTest() { CompositionContainer d1 = CreateCompositionContainer(); CompositionContainer d2 = CreateCompositionContainer(); CompositionBatch batch1 = new CompositionBatch(); var valueKey = batch1.AddExportedValue("a", 1); d1.Compose(batch1); CompositionBatch batch2 = new CompositionBatch(); batch2.RemovePart(valueKey); // removing entry from wrong container, shoudl be a no-op d2.Compose(batch2); } [Fact] [Trait("Type", "Integration")] public void AddPartSimple() { var container = CreateCompositionContainer(); var importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); batch.AddPart(new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] [Trait("Type", "Integration")] public void AddPart() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(AttributedModelServices.CreatePart(importer)); batch.AddPart(new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void ComposeReentrantChildContainerDisposed() { var container = CreateCompositionContainer(); Int32Importer outerImporter = new Int32Importer(); Int32Importer innerImporter = new Int32Importer(); Int32Exporter exporter = new Int32Exporter(42); CompositionBatch batch = new CompositionBatch(); batch.AddPart(exporter); container.Compose(batch); CallbackExecuteCodeDuringCompose callback = new CallbackExecuteCodeDuringCompose(() => { using (CompositionContainer innerContainer = new CompositionContainer(container)) { CompositionBatch nestedBatch = new CompositionBatch(); nestedBatch.AddPart(innerImporter); innerContainer.Compose(nestedBatch); } Assert.Equal(42, innerImporter.Value); }); batch = new CompositionBatch(); batch.AddParts(outerImporter, callback); container.Compose(batch); Assert.Equal(42, outerImporter.Value); Assert.Equal(42, innerImporter.Value); } [Fact] public void ComposeSimple() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.Equal(42, importer.Value); } [Fact] public void ComposeSimpleFail() { var container = CreateCompositionContainer(); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); CompositionAssert.ThrowsChangeRejectedError(ErrorId.ImportEngine_PartCannotSetImport, // Cannot set Int32Importer.Value because ErrorId.ImportEngine_ImportCardinalityMismatch, // No exports are present that match contract RetryMode.DoNotRetry, () => { container.Compose(batch); }); } [Fact] public void ExceptionDuringNotify() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { throw new InvalidOperationException(); })); CompositionAssert.ThrowsError(ErrorId.ImportEngine_PartCannotActivate, // Cannot activate CallbackImportNotify because RetryMode.DoNotRetry, () => { container.Compose(batch); }); } [Fact] public void NeutralComposeWhileNotified() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(new CallbackImportNotify(delegate { // Is this really a supported scenario? container.Compose(batch); })); container.Compose(batch); } public class PartWithReentrantCompose : ComposablePart { private CompositionContainer _container; public PartWithReentrantCompose(CompositionContainer container) { this._container = container; } public override IEnumerable<ExportDefinition> ExportDefinitions { get { this._container.ComposeExportedValue<string>("ExportedString"); return Enumerable.Empty<ExportDefinition>(); } } public override IEnumerable<ImportDefinition> ImportDefinitions { get { return Enumerable.Empty<ImportDefinition>(); } } public override object GetExportedValue(ExportDefinition definition) { throw new NotImplementedException(); } public override void SetImport(ImportDefinition definition, IEnumerable<Export> exports) { throw new NotImplementedException(); } } [Export] public class SimpleExporter { } [Fact] public void ThreadSafeCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, true); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void ThreadSafeCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.IsThreadSafe); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void DisableSilentRejectionCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void DisableSilentRejectionThreadSafeCompositionOptionsCompositionContainer() { TypeCatalog catalog = new TypeCatalog(typeof(SimpleExporter)); CompositionContainer container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe); Int32Importer importer = new Int32Importer(); CompositionBatch batch = new CompositionBatch(); batch.AddParts(importer, new Int32Exporter(42)); container.Compose(batch); Assert.NotNull(container.GetExportedValue<SimpleExporter>()); Assert.Equal(42, importer.Value); container.Dispose(); } [Fact] public void CompositionOptionsInvalidValue() { Assert.Throws<ArgumentOutOfRangeException>("compositionOptions", () => new CompositionContainer((CompositionOptions)0x0400)); } [Fact] public void ReentrantencyDisabledWhileComposing() { var container = CreateCompositionContainer(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(new PartWithReentrantCompose(container)); ExceptionAssert.Throws<InvalidOperationException>(() => container.Compose(batch)); } private static Expression<Func<ExportDefinition, bool>> ConstraintFromContract(string contractName) { return ConstraintFactory.Create(contractName); } private static string ContractFromType(Type type) { return AttributedModelServices.GetContractName(type); } private static CompositionContainer CreateCompositionContainer() { return new CompositionContainer(); } public interface IMetadataView { string Metadata1 { get; } string Metadata2 { get; } string Metadata3 { get; } } [Fact] public void ComposeExportedValueOfT_NullStringAsExportedValueArgument_VerifyCanPullOnValue() { var container = CreateCompositionContainer(); var expectation = (string)null; container.ComposeExportedValue<string>(expectation); var actualValue = container.GetExportedValue<string>(); Assert.Equal(expectation, actualValue); } [Fact] public void ComposeExportedValueOfT_StringAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<string>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectation); var actualValue = container.GetExportedValue<string>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_StringAsIEnumerableOfCharAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<string>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<IEnumerable<char>>(expectation); var actualValue = container.GetExportedValue<IEnumerable<char>>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_ObjectAsExportedValueArgument_VerifyCanPullOnValue() { var expectations = new List<object>(); expectations.Add((string)null); expectations.Add(string.Empty); expectations.Add("Value"); expectations.Add(42); expectations.Add(new object()); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<object>(expectation); var actualValue = container.GetExportedValue<object>(); Assert.Equal(expectation, actualValue); } } [Fact] public void ComposeExportedValueOfT_ExportedValue_ExportedUnderDefaultContractName() { string expectedContractName = AttributedModelServices.GetContractName(typeof(string)); var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(expectedContractName, exports.Single().Definition.ContractName); } [Fact] public void ComposeExportedValueOfT_ExportedValue_ExportContainsEmptyMetadata() { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(1, exports.Single().Metadata.Count); // contains type identity } [Fact] public void ComposeExportedValueOfT_ExportedValue_LazyContainsEmptyMetadata() { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>("Value"); var lazy = container.GetExport<string, IDictionary<string, object>>(); Assert.Equal(1, lazy.Metadata.Count); // contains type identity } [Fact] public void ComposeExportedValueOfT_ExportedValue_ImportsAreNotDiscovered() { var container = CreateCompositionContainer(); var importer = new PartWithRequiredImport(); container.ComposeExportedValue<object>(importer); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); // we only get one if the import was not discovered since the import is not satisfied } [Fact] public void ComposeExportedValueOfT_NullAsContractName_ThrowsArgumentNullException() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentNullException>("contractName", () => container.ComposeExportedValue<string>((string)null, "Value")); } [Fact] public void ComposeExportedValueOfT_EmptyStringAsContractName_ThrowsArgumentException() { var container = CreateCompositionContainer(); Assert.Throws<ArgumentException>("contractName", () => container.ComposeExportedValue<string>(string.Empty, "Value")); } [Fact] public void ComposeExportedValueOfT_ValidContractName_ValidExportedValue_VerifyCanPullOnValue() { var expectations = new List<Tuple<string, string>>(); expectations.Add(new Tuple<string, string>(" ", (string)null)); expectations.Add(new Tuple<string, string>(" ", string.Empty)); expectations.Add(new Tuple<string, string>(" ", "Value")); expectations.Add(new Tuple<string, string>("ContractName", (string)null)); expectations.Add(new Tuple<string, string>("ContractName", string.Empty)); expectations.Add(new Tuple<string, string>("ContractName", "Value")); foreach (var expectation in expectations) { var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectation.Item1, expectation.Item2); var actualValue = container.GetExportedValue<string>(expectation.Item1); Assert.Equal(expectation.Item2, actualValue); ExceptionAssert.Throws<ImportCardinalityMismatchException>(() => container.GetExportedValue<string>()); } } [Fact] public void ComposeExportedValueOfT_ValidContractName_ExportedValue_ExportedUnderSpecifiedContractName() { string expectedContractName = "ContractName"; var container = CreateCompositionContainer(); container.ComposeExportedValue<string>(expectedContractName, "Value"); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); Assert.Equal(expectedContractName, exports.Single().Definition.ContractName); } [Fact] public void ComposeExportedValueOfT_ValidContractName_ExportedValue_ImportsAreNotDiscovered() { var container = CreateCompositionContainer(); var importer = new PartWithRequiredImport(); container.ComposeExportedValue<object>("ContractName", importer); var importDefinition = new ImportDefinition(ed => true, null, ImportCardinality.ZeroOrMore, false, false); var exports = container.GetExports(importDefinition); Assert.Equal(1, exports.Count()); // we only get one if the import was not discovered since the import is not satisfied } [Fact] public void TestExportedValueCachesNullValue() { var container = ContainerFactory.Create(); var exporter = new ExportsMutableProperty(); exporter.Property = null; container.ComposeParts(exporter); Assert.Null(container.GetExportedValue<string>("Property")); exporter.Property = "Value1"; // Exported value should have been cached and so it shouldn't change Assert.Null(container.GetExportedValue<string>("Property")); } [Fact] public void TestExportedValueUsingWhereClause_ExportSuccessful() { CompositionContainer container = new CompositionContainer(new TypeCatalog(typeof(MefCollection<,>))); IMefCollection<DerivedClass, BaseClass> actualValue = container.GetExportedValue<IMefCollection<DerivedClass, BaseClass>>("UsingWhereClause"); Assert.NotNull(actualValue); Assert.IsType<MefCollection<DerivedClass, BaseClass>>(actualValue); } public interface IMefCollection { } public interface IMefCollection<TC, TP> : IList<TC>, IMefCollection where TC : TP { } public class BaseClass { } public class DerivedClass : BaseClass { } [Export("UsingWhereClause", typeof(IMefCollection<,>))] public class MefCollection<TC, TP> : ObservableCollection<TC>, IMefCollection<TC, TP> where TC : TP { } public class ExportsMutableProperty { [Export("Property")] public string Property { get; set; } } public class PartWithRequiredImport { [Import] public object Import { get; set; } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/mono/mono/tests/abort-cctor-2.cs
using System; using System.Threading; public class Critical { static Critical () { Program.mre1.Set (); Program.mre2.WaitOne (); try { throw new Exception (); } catch (Exception) { Console.WriteLine ("Catched exception in cctor"); Program.catched_exception = true; } } } public class Program { public static ManualResetEvent mre1 = new ManualResetEvent (false); public static ManualResetEvent mre2 = new ManualResetEvent (false); public static bool catched_exception, catched_abort; public static int Main (string[] args) { Thread thread = new Thread (DoStuff); thread.Start (); mre1.WaitOne (); thread.Abort (); mre2.Set (); thread.Join (); if (!catched_exception) Environment.Exit (1); if (!catched_abort) Environment.Exit (2); Console.WriteLine ("done, all things good"); return 0; } public static void DoStuff () { try { new Critical (); } catch (ThreadAbortException) { Console.WriteLine ("Catched thread abort"); Program.catched_abort = true; } } }
using System; using System.Threading; public class Critical { static Critical () { Program.mre1.Set (); Program.mre2.WaitOne (); try { throw new Exception (); } catch (Exception) { Console.WriteLine ("Catched exception in cctor"); Program.catched_exception = true; } } } public class Program { public static ManualResetEvent mre1 = new ManualResetEvent (false); public static ManualResetEvent mre2 = new ManualResetEvent (false); public static bool catched_exception, catched_abort; public static int Main (string[] args) { Thread thread = new Thread (DoStuff); thread.Start (); mre1.WaitOne (); thread.Abort (); mre2.Set (); thread.Join (); if (!catched_exception) Environment.Exit (1); if (!catched_abort) Environment.Exit (2); Console.WriteLine ("done, all things good"); return 0; } public static void DoStuff () { try { new Critical (); } catch (ThreadAbortException) { Console.WriteLine ("Catched thread abort"); Program.catched_abort = true; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest1481/Generated1481.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated1481.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated1481.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/MockHostTypes/IWebHost.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace MockHostTypes { public interface IWebHost { IServiceProvider Services { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace MockHostTypes { public interface IWebHost { IServiceProvider Services { get; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.ObjectModel/src/System/Windows/Input/ICommand.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Markup; namespace System.Windows.Input { ///<summary> /// An interface that allows an application author to define a method to be invoked. ///</summary> [TypeForwardedFrom("PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")] [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")] [ValueSerializer("System.Windows.Input.CommandValueSerializer, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")] public interface ICommand { /// <summary> /// Raised when the ability of the command to execute has changed. /// </summary> event EventHandler? CanExecuteChanged; /// <summary> /// Returns whether the command can be executed. /// </summary> /// <param name="parameter">A parameter that may be used in executing the command. This parameter may be ignored by some implementations.</param> /// <returns>true if the command can be executed with the given parameter and current state. false otherwise.</returns> bool CanExecute(object? parameter); /// <summary> /// Defines the method that should be executed when the command is executed. /// </summary> /// <param name="parameter">A parameter that may be used in executing the command. This parameter may be ignored by some implementations.</param> void Execute(object? parameter); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Markup; namespace System.Windows.Input { ///<summary> /// An interface that allows an application author to define a method to be invoked. ///</summary> [TypeForwardedFrom("PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")] [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")] [ValueSerializer("System.Windows.Input.CommandValueSerializer, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")] public interface ICommand { /// <summary> /// Raised when the ability of the command to execute has changed. /// </summary> event EventHandler? CanExecuteChanged; /// <summary> /// Returns whether the command can be executed. /// </summary> /// <param name="parameter">A parameter that may be used in executing the command. This parameter may be ignored by some implementations.</param> /// <returns>true if the command can be executed with the given parameter and current state. false otherwise.</returns> bool CanExecute(object? parameter); /// <summary> /// Defines the method that should be executed when the command is executed. /// </summary> /// <param name="parameter">A parameter that may be used in executing the command. This parameter may be ignored by some implementations.</param> void Execute(object? parameter); } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestUtilities.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #if USE_MDT_EVENTSOURCE using Microsoft.Diagnostics.Tracing; #else using System.Diagnostics.Tracing; #endif using System.Diagnostics; using Xunit; using System; using System.Collections.Generic; namespace BasicEventSourceTests { internal class TestUtilities { // Specifies whether the process is elevated or not. private static readonly Lazy<bool> s_isElevated = new Lazy<bool>(() => AdminHelpers.IsProcessElevated()); internal static bool IsProcessElevated => s_isElevated.Value; /// <summary> /// Confirms that there are no EventSources running. /// </summary> /// <param name="message">Will be printed as part of the Assert</param> public static void CheckNoEventSourcesRunning(string message = "") { var eventSources = EventSource.GetSources(); string eventSourceNames = ""; foreach (var eventSource in EventSource.GetSources()) { // Exempt sources built in to the framework that might be used by types involved in the tests if (eventSource.Name != "System.Threading.Tasks.TplEventSource" && eventSource.Name != "System.Diagnostics.Eventing.FrameworkEventSource" && eventSource.Name != "System.Buffers.ArrayPoolEventSource" && eventSource.Name != "System.Threading.SynchronizationEventSource" && eventSource.Name != "System.Collections.Concurrent.ConcurrentCollectionsEventSource" && eventSource.Name != "System.Runtime.InteropServices.InteropEventProvider" && eventSource.Name != "System.Reflection.Runtime.Tracing" && eventSource.Name != "Microsoft-Windows-DotNETRuntime" && eventSource.Name != "System.Runtime" && // These event sources show up when hosted in the VS test runner eventSource.Name != "System.Net.Sockets" && eventSource.Name != "Private.InternalDiagnostics.System.Net.Sockets" && eventSource.Name != "TestPlatform" ) { eventSourceNames += eventSource.Name + " "; } } Debug.WriteLine(message); Assert.Equal("", eventSourceNames); } /// <summary> /// Unwraps a nullable returned from either ETW or EventListener /// </summary> /// <typeparam name="T">The type to unwrap</typeparam> /// <param name="wrappedValue">Value returned from event payload</param> /// <returns></returns> public static T? UnwrapNullable<T>(object wrappedValue) where T : struct { // ETW will return a collection of key/value pairs if (wrappedValue is IDictionary<string, object> dict) { Assert.True(dict.ContainsKey("HasValue")); Assert.True(dict.ContainsKey("Value")); if ((bool)dict["HasValue"]) { return (T)dict["Value"]; } } // EventListener will return the boxed value of the nullable, which will either be a value or null object reference else if (wrappedValue != null) { Assert.IsType<T>(wrappedValue); return (T?)wrappedValue; } // wrappedValue is null or wrappedValue is IDictionary, but HasValue is false return null; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #if USE_MDT_EVENTSOURCE using Microsoft.Diagnostics.Tracing; #else using System.Diagnostics.Tracing; #endif using System.Diagnostics; using Xunit; using System; using System.Collections.Generic; namespace BasicEventSourceTests { internal class TestUtilities { // Specifies whether the process is elevated or not. private static readonly Lazy<bool> s_isElevated = new Lazy<bool>(() => AdminHelpers.IsProcessElevated()); internal static bool IsProcessElevated => s_isElevated.Value; /// <summary> /// Confirms that there are no EventSources running. /// </summary> /// <param name="message">Will be printed as part of the Assert</param> public static void CheckNoEventSourcesRunning(string message = "") { var eventSources = EventSource.GetSources(); string eventSourceNames = ""; foreach (var eventSource in EventSource.GetSources()) { // Exempt sources built in to the framework that might be used by types involved in the tests if (eventSource.Name != "System.Threading.Tasks.TplEventSource" && eventSource.Name != "System.Diagnostics.Eventing.FrameworkEventSource" && eventSource.Name != "System.Buffers.ArrayPoolEventSource" && eventSource.Name != "System.Threading.SynchronizationEventSource" && eventSource.Name != "System.Collections.Concurrent.ConcurrentCollectionsEventSource" && eventSource.Name != "System.Runtime.InteropServices.InteropEventProvider" && eventSource.Name != "System.Reflection.Runtime.Tracing" && eventSource.Name != "Microsoft-Windows-DotNETRuntime" && eventSource.Name != "System.Runtime" && // These event sources show up when hosted in the VS test runner eventSource.Name != "System.Net.Sockets" && eventSource.Name != "Private.InternalDiagnostics.System.Net.Sockets" && eventSource.Name != "TestPlatform" ) { eventSourceNames += eventSource.Name + " "; } } Debug.WriteLine(message); Assert.Equal("", eventSourceNames); } /// <summary> /// Unwraps a nullable returned from either ETW or EventListener /// </summary> /// <typeparam name="T">The type to unwrap</typeparam> /// <param name="wrappedValue">Value returned from event payload</param> /// <returns></returns> public static T? UnwrapNullable<T>(object wrappedValue) where T : struct { // ETW will return a collection of key/value pairs if (wrappedValue is IDictionary<string, object> dict) { Assert.True(dict.ContainsKey("HasValue")); Assert.True(dict.ContainsKey("Value")); if ((bool)dict["HasValue"]) { return (T)dict["Value"]; } } // EventListener will return the boxed value of the nullable, which will either be a value or null object reference else if (wrappedValue != null) { Assert.IsType<T>(wrappedValue); return (T?)wrappedValue; } // wrappedValue is null or wrappedValue is IDictionary, but HasValue is false return null; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Directed/nullabletypes/hasvalue_do.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> <DebugType>Full</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="hasvalue.cs" /> <Compile Include="invokecommon.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <!-- Set to 'Full' if the Debug? column is marked in the spreadsheet. Leave blank otherwise. --> <DebugType>Full</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="hasvalue.cs" /> <Compile Include="invokecommon.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/jit64/eh/FinallyExec/nonlocalexitinhandler.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern System.Console { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:0:0:0 } .assembly extern mscorlib {} .assembly extern eh_common {} .assembly test {} .module nonlocalexitinhandler.exe .method public static int32 Main() { .entrypoint .maxstack 2 .locals init ( class [mscorlib]System.IO.StringWriter expectedOut, class [eh_common]TestUtil.TestLog testLog ) newobj instance void [mscorlib]System.IO.StringWriter::.ctor() stloc.s expectedOut ldloc.s expectedOut ldstr "in try" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr "in filter" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr "in handler" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr " in try 1" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr " in finally 1" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr " in try 2" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr " in finally 2" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut newobj instance void [eh_common]TestUtil.TestLog::.ctor(object) stloc.s testLog ldloc.s testLog callvirt instance void [eh_common]TestUtil.TestLog::StartRecording() call void Run() ldloc.s testLog callvirt instance void [eh_common]TestUtil.TestLog::StopRecording() ldloc.s testLog callvirt instance int32 [eh_common]TestUtil.TestLog::VerifyOutput() ret } .method public static void Run() { .maxstack 1 .try { ldstr "in try" call void [System.Console]System.Console::WriteLine(string) newobj instance void [mscorlib]System.Exception::.ctor() throw leave.s DONE } filter { pop ldstr "in filter" call void [System.Console]System.Console::WriteLine(string) ldc.i4.1 endfilter } { pop ldstr "in handler" call void [System.Console]System.Console::WriteLine(string) .try { TRY_1: ldstr " in try 1" call void [System.Console]System.Console::WriteLine(string) leave.s TRY_2 } finally { ldstr " in finally 1" call void [System.Console]System.Console::WriteLine(string) endfinally } ldstr "*** UNREACHABLE ***" call void [System.Console]System.Console::WriteLine(string) .try { TRY_2: ldstr " in try 2" call void [System.Console]System.Console::WriteLine(string) leave.s HANDLER_END } finally { ldstr " in finally 2" call void [System.Console]System.Console::WriteLine(string) endfinally } HANDLER_END: leave.s DONE } DONE: ret }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern System.Console { .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) .ver 4:0:0:0 } .assembly extern mscorlib {} .assembly extern eh_common {} .assembly test {} .module nonlocalexitinhandler.exe .method public static int32 Main() { .entrypoint .maxstack 2 .locals init ( class [mscorlib]System.IO.StringWriter expectedOut, class [eh_common]TestUtil.TestLog testLog ) newobj instance void [mscorlib]System.IO.StringWriter::.ctor() stloc.s expectedOut ldloc.s expectedOut ldstr "in try" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr "in filter" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr "in handler" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr " in try 1" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr " in finally 1" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr " in try 2" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut ldstr " in finally 2" callvirt instance void [mscorlib]System.IO.TextWriter::WriteLine(string) ldloc.s expectedOut newobj instance void [eh_common]TestUtil.TestLog::.ctor(object) stloc.s testLog ldloc.s testLog callvirt instance void [eh_common]TestUtil.TestLog::StartRecording() call void Run() ldloc.s testLog callvirt instance void [eh_common]TestUtil.TestLog::StopRecording() ldloc.s testLog callvirt instance int32 [eh_common]TestUtil.TestLog::VerifyOutput() ret } .method public static void Run() { .maxstack 1 .try { ldstr "in try" call void [System.Console]System.Console::WriteLine(string) newobj instance void [mscorlib]System.Exception::.ctor() throw leave.s DONE } filter { pop ldstr "in filter" call void [System.Console]System.Console::WriteLine(string) ldc.i4.1 endfilter } { pop ldstr "in handler" call void [System.Console]System.Console::WriteLine(string) .try { TRY_1: ldstr " in try 1" call void [System.Console]System.Console::WriteLine(string) leave.s TRY_2 } finally { ldstr " in finally 1" call void [System.Console]System.Console::WriteLine(string) endfinally } ldstr "*** UNREACHABLE ***" call void [System.Console]System.Console::WriteLine(string) .try { TRY_2: ldstr " in try 2" call void [System.Console]System.Console::WriteLine(string) leave.s HANDLER_END } finally { ldstr " in finally 2" call void [System.Console]System.Console::WriteLine(string) endfinally } HANDLER_END: leave.s DONE } DONE: ret }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaSet/TC_SchemaSet_XmlNameTable.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; using Xunit.Abstractions; using System.Xml.Schema; namespace System.Xml.Tests { //[TestCase(Name = "TC_SchemaSet_XmlNameTable", Desc = "")] public class TC_SchemaSet_XmlNameTable : TC_SchemaSetBase { private ITestOutputHelper _output; public TC_SchemaSet_XmlNameTable(ITestOutputHelper output) { _output = output; } //----------------------------------------------------------------------------------- //[Variation(Desc = "v1 - Get nametable", Priority = 0)] [Fact] public void v1() { XmlSchemaSet sc = new XmlSchemaSet(); XmlNameTable NT = sc.NameTable; CError.Compare(NT != null, true, "NameTable"); return; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; using Xunit.Abstractions; using System.Xml.Schema; namespace System.Xml.Tests { //[TestCase(Name = "TC_SchemaSet_XmlNameTable", Desc = "")] public class TC_SchemaSet_XmlNameTable : TC_SchemaSetBase { private ITestOutputHelper _output; public TC_SchemaSet_XmlNameTable(ITestOutputHelper output) { _output = output; } //----------------------------------------------------------------------------------- //[Variation(Desc = "v1 - Get nametable", Priority = 0)] [Fact] public void v1() { XmlSchemaSet sc = new XmlSchemaSet(); XmlNameTable NT = sc.NameTable; CError.Compare(NT != null, true, "NameTable"); return; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.ObjectModel/tests/ReadOnlyObservableCollection/ReadOnlyObservableCollection_SerializationTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Runtime.Serialization.Formatters.Tests; using Xunit; namespace System.Collections.ObjectModel.Tests { public partial class ReadOnlyObservableCollection_Serialization { public static IEnumerable<object[]> SerializeDeserialize_Roundtrips_MemberData() { yield return new object[] { new ReadOnlyObservableCollection<int>(new ObservableCollection<int>()) }; yield return new object[] { new ReadOnlyObservableCollection<int>(new ObservableCollection<int>() { 1 }) }; yield return new object[] { new ReadOnlyObservableCollection<int>(new ObservableCollection<int>() { 1, 2 }) }; yield return new object[] { new ReadOnlyObservableCollection<int>(new ObservableCollection<int>() { 1, 2, 3 }) }; } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))] [MemberData(nameof(SerializeDeserialize_Roundtrips_MemberData))] public void SerializeDeserialize_Roundtrips(ReadOnlyObservableCollection<int> c) { ReadOnlyObservableCollection<int> clone = BinaryFormatterHelpers.Clone(c); Assert.NotSame(c, clone); Assert.Equal(c, clone); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Runtime.Serialization.Formatters.Tests; using Xunit; namespace System.Collections.ObjectModel.Tests { public partial class ReadOnlyObservableCollection_Serialization { public static IEnumerable<object[]> SerializeDeserialize_Roundtrips_MemberData() { yield return new object[] { new ReadOnlyObservableCollection<int>(new ObservableCollection<int>()) }; yield return new object[] { new ReadOnlyObservableCollection<int>(new ObservableCollection<int>() { 1 }) }; yield return new object[] { new ReadOnlyObservableCollection<int>(new ObservableCollection<int>() { 1, 2 }) }; yield return new object[] { new ReadOnlyObservableCollection<int>(new ObservableCollection<int>() { 1, 2, 3 }) }; } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported))] [MemberData(nameof(SerializeDeserialize_Roundtrips_MemberData))] public void SerializeDeserialize_Roundtrips(ReadOnlyObservableCollection<int> c) { ReadOnlyObservableCollection<int> clone = BinaryFormatterHelpers.Clone(c); Assert.NotSame(c, clone); Assert.Equal(c, clone); } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/Methodical/Arrays/misc/lengthm2_il_r.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="lengthm2.il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> </PropertyGroup> <ItemGroup> <Compile Include="lengthm2.il" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Private.Xml/tests/Xslt/TestFiles/TestData/xsltc/baseline/bft24a.xsl
<xsl:stylesheet version= '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' > <xsl:import href="bft24b.xsl"/> <xsl:template match="/"> <xsl:for-each select="//foo"> <xsl:value-of select="."/> </xsl:for-each> </xsl:template> </xsl:stylesheet>
<xsl:stylesheet version= '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' > <xsl:import href="bft24b.xsl"/> <xsl:template match="/"> <xsl:for-each select="//foo"> <xsl:value-of select="."/> </xsl:for-each> </xsl:template> </xsl:stylesheet>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Collections.Specialized/tests/NameValueCollection/NameValueCollection.SetItemTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Collections.Specialized.Tests { public class NameValueCollectionSetItemTests { [Fact] public void Item_Set() { NameValueCollection nameValueCollection = new NameValueCollection(); for (int i = 0; i < 10; i++) { string newName = "Name_" + i; string newValue = "Value_" + i; nameValueCollection[newName] = newValue; Assert.Equal(i + 1, nameValueCollection.Count); Assert.Equal(newValue, nameValueCollection[newName]); } } [Fact] public void Item_Set_OvewriteExistingValue() { NameValueCollection nameValueCollection = new NameValueCollection(); string name = "name"; string value = "value"; nameValueCollection.Add(name, "old-value"); nameValueCollection[name] = value; Assert.Equal(value, nameValueCollection[name]); Assert.Equal(new string[] { value }, nameValueCollection.GetValues(name)); } [Theory] [InlineData(0)] [InlineData(5)] public void Item_Set_NullName(int count) { NameValueCollection nameValueCollection = Helpers.CreateNameValueCollection(count); string nullNameValue = "value"; nameValueCollection[null] = nullNameValue; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Equal(nullNameValue, nameValueCollection[null]); string newNullNameValue = "newvalue"; nameValueCollection[null] = newNullNameValue; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Equal(newNullNameValue, nameValueCollection[null]); } [Theory] [InlineData(0)] [InlineData(5)] public void Item_Set_NullValue(int count) { NameValueCollection nameValueCollection = Helpers.CreateNameValueCollection(count); string nullValueName = "name"; nameValueCollection[nullValueName] = null; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Null(nameValueCollection[nullValueName]); nameValueCollection[nullValueName] = "abc"; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Equal("abc", nameValueCollection[nullValueName]); nameValueCollection[nullValueName] = null; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Null(nameValueCollection[nullValueName]); } [Fact] public void Item_Set_IsCaseSensitive() { NameValueCollection nameValueCollection = new NameValueCollection(); nameValueCollection["name"] = "value1"; nameValueCollection["Name"] = "value2"; nameValueCollection["NAME"] = "value3"; Assert.Equal(1, nameValueCollection.Count); Assert.Equal("value3", nameValueCollection["name"]); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.Collections.Specialized.Tests { public class NameValueCollectionSetItemTests { [Fact] public void Item_Set() { NameValueCollection nameValueCollection = new NameValueCollection(); for (int i = 0; i < 10; i++) { string newName = "Name_" + i; string newValue = "Value_" + i; nameValueCollection[newName] = newValue; Assert.Equal(i + 1, nameValueCollection.Count); Assert.Equal(newValue, nameValueCollection[newName]); } } [Fact] public void Item_Set_OvewriteExistingValue() { NameValueCollection nameValueCollection = new NameValueCollection(); string name = "name"; string value = "value"; nameValueCollection.Add(name, "old-value"); nameValueCollection[name] = value; Assert.Equal(value, nameValueCollection[name]); Assert.Equal(new string[] { value }, nameValueCollection.GetValues(name)); } [Theory] [InlineData(0)] [InlineData(5)] public void Item_Set_NullName(int count) { NameValueCollection nameValueCollection = Helpers.CreateNameValueCollection(count); string nullNameValue = "value"; nameValueCollection[null] = nullNameValue; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Equal(nullNameValue, nameValueCollection[null]); string newNullNameValue = "newvalue"; nameValueCollection[null] = newNullNameValue; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Equal(newNullNameValue, nameValueCollection[null]); } [Theory] [InlineData(0)] [InlineData(5)] public void Item_Set_NullValue(int count) { NameValueCollection nameValueCollection = Helpers.CreateNameValueCollection(count); string nullValueName = "name"; nameValueCollection[nullValueName] = null; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Null(nameValueCollection[nullValueName]); nameValueCollection[nullValueName] = "abc"; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Equal("abc", nameValueCollection[nullValueName]); nameValueCollection[nullValueName] = null; Assert.Equal(count + 1, nameValueCollection.Count); Assert.Null(nameValueCollection[nullValueName]); } [Fact] public void Item_Set_IsCaseSensitive() { NameValueCollection nameValueCollection = new NameValueCollection(); nameValueCollection["name"] = "value1"; nameValueCollection["Name"] = "value2"; nameValueCollection["NAME"] = "value3"; Assert.Equal(1, nameValueCollection.Count); Assert.Equal("value3", nameValueCollection["name"]); } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Net.NameResolution/tests/FunctionalTests/System.Net.NameResolution.Functional.Tests.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks> <IncludeRemoteExecutor>true</IncludeRemoteExecutor> <IgnoreForCI Condition="'$(TargetOS)' == 'Browser'">true</IgnoreForCI> </PropertyGroup> <ItemGroup> <Compile Include="AssemblyInfo.cs" /> <Compile Include="GetHostByAddressTest.cs" /> <Compile Include="GetHostByNameTest.cs" /> <Compile Include="ResolveTest.cs" /> <Compile Include="GetHostNameTest.cs" /> <Compile Include="GetHostEntryTest.cs" /> <Compile Include="GetHostAddressesTest.cs" /> <Compile Include="LoggingTest.cs" /> <Compile Include="TelemetryTest.cs" /> <Compile Include="TestSettings.cs" /> <!-- Common test files --> <Compile Include="$(CommonTestPath)System\Threading\Tasks\TaskTimeoutExtensions.cs" Link="Common\System\Threading\Tasks\TaskTimeoutExtensions.cs" /> <Compile Include="$(CommonTestPath)System\Net\Configuration.cs" Link="Common\System\Net\Configuration.cs" /> <Compile Include="$(CommonTestPath)System\Net\Configuration.Sockets.cs" Link="Common\System\Net\Configuration.Sockets.cs" /> <Compile Include="$(CommonTestPath)System\Diagnostics\Tracing\TestEventListener.cs" Link="Common\System\Diagnostics\Tracing\TestEventListener.cs" /> <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs" Link="Common\TestUtilities\System\DisableParallelization.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks> <IncludeRemoteExecutor>true</IncludeRemoteExecutor> <IgnoreForCI Condition="'$(TargetOS)' == 'Browser'">true</IgnoreForCI> </PropertyGroup> <ItemGroup> <Compile Include="AssemblyInfo.cs" /> <Compile Include="GetHostByAddressTest.cs" /> <Compile Include="GetHostByNameTest.cs" /> <Compile Include="ResolveTest.cs" /> <Compile Include="GetHostNameTest.cs" /> <Compile Include="GetHostEntryTest.cs" /> <Compile Include="GetHostAddressesTest.cs" /> <Compile Include="LoggingTest.cs" /> <Compile Include="TelemetryTest.cs" /> <Compile Include="TestSettings.cs" /> <!-- Common test files --> <Compile Include="$(CommonTestPath)System\Threading\Tasks\TaskTimeoutExtensions.cs" Link="Common\System\Threading\Tasks\TaskTimeoutExtensions.cs" /> <Compile Include="$(CommonTestPath)System\Net\Configuration.cs" Link="Common\System\Net\Configuration.cs" /> <Compile Include="$(CommonTestPath)System\Net\Configuration.Sockets.cs" Link="Common\System\Net\Configuration.Sockets.cs" /> <Compile Include="$(CommonTestPath)System\Diagnostics\Tracing\TestEventListener.cs" Link="Common\System\Diagnostics\Tracing\TestEventListener.cs" /> <Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs" Link="Common\TestUtilities\System\DisableParallelization.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/coreclr/pal/tests/palsuite/c_runtime/fprintf/test13/test13.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ ** ** Source: test13.c (fprintf) ** ** Purpose: Tests the (uppercase) hexadecimal specifier (%X). ** This test is modeled after the fprintf series. ** ** **==========================================================================*/ #include <palsuite.h> #include "../fprintf.h" /* * Depends on memcmp, strlen, fopen, fseek and fgets. */ PALTEST(c_runtime_fprintf_test13_paltest_fprintf_test13, "c_runtime/fprintf/test13/paltest_fprintf_test13") { int neg = -42; int pos = 0x1234AB; INT64 l = I64(0x1234567887654321); if (PAL_Initialize(argc, argv) != 0) return(FAIL); DoNumTest("foo %X", pos, "foo 1234AB"); DoNumTest("foo %lX", pos, "foo 1234AB"); DoNumTest("foo %hX", pos, "foo 34AB"); DoNumTest("foo %LX", pos, "foo 1234AB"); DoI64Test("foo %I64X", l, "0x1234567887654321", "foo 1234567887654321", "foo 0x1234567887654321"); DoNumTest("foo %7X", pos, "foo 1234AB"); DoNumTest("foo %-7X", pos, "foo 1234AB "); DoNumTest("foo %.1X", pos, "foo 1234AB"); DoNumTest("foo %.7X", pos, "foo 01234AB"); DoNumTest("foo %07X", pos, "foo 01234AB"); DoNumTest("foo %#X", pos, "foo 0X1234AB"); DoNumTest("foo %+X", pos, "foo 1234AB"); DoNumTest("foo % X", pos, "foo 1234AB"); DoNumTest("foo %+X", neg, "foo FFFFFFD6"); DoNumTest("foo % X", neg, "foo FFFFFFD6"); PAL_Terminate(); return PASS; }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ ** ** Source: test13.c (fprintf) ** ** Purpose: Tests the (uppercase) hexadecimal specifier (%X). ** This test is modeled after the fprintf series. ** ** **==========================================================================*/ #include <palsuite.h> #include "../fprintf.h" /* * Depends on memcmp, strlen, fopen, fseek and fgets. */ PALTEST(c_runtime_fprintf_test13_paltest_fprintf_test13, "c_runtime/fprintf/test13/paltest_fprintf_test13") { int neg = -42; int pos = 0x1234AB; INT64 l = I64(0x1234567887654321); if (PAL_Initialize(argc, argv) != 0) return(FAIL); DoNumTest("foo %X", pos, "foo 1234AB"); DoNumTest("foo %lX", pos, "foo 1234AB"); DoNumTest("foo %hX", pos, "foo 34AB"); DoNumTest("foo %LX", pos, "foo 1234AB"); DoI64Test("foo %I64X", l, "0x1234567887654321", "foo 1234567887654321", "foo 0x1234567887654321"); DoNumTest("foo %7X", pos, "foo 1234AB"); DoNumTest("foo %-7X", pos, "foo 1234AB "); DoNumTest("foo %.1X", pos, "foo 1234AB"); DoNumTest("foo %.7X", pos, "foo 01234AB"); DoNumTest("foo %07X", pos, "foo 01234AB"); DoNumTest("foo %#X", pos, "foo 0X1234AB"); DoNumTest("foo %+X", pos, "foo 1234AB"); DoNumTest("foo % X", pos, "foo 1234AB"); DoNumTest("foo %+X", neg, "foo FFFFFFD6"); DoNumTest("foo % X", neg, "foo FFFFFFD6"); PAL_Terminate(); return PASS; }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/native/external/zlib-intel/crc32.h
/* crc32.h -- tables for rapid CRC calculation * Generated automatically by crc32.c */ local const z_crc_t FAR crc_table[TBLS][256] = { { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 0x2d02ef8dUL #ifdef BYFOUR }, { 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, 0x9324fd72UL }, { 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, 0xbe9834edUL }, { 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, 0xde0506f1UL }, { 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, 0x8def022dUL }, { 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, 0x72fd2493UL }, { 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, 0xed3498beUL }, { 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, 0xf10605deUL #endif } };
/* crc32.h -- tables for rapid CRC calculation * Generated automatically by crc32.c */ local const z_crc_t FAR crc_table[TBLS][256] = { { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 0x2d02ef8dUL #ifdef BYFOUR }, { 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, 0x9324fd72UL }, { 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, 0xbe9834edUL }, { 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, 0xde0506f1UL }, { 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, 0x8def022dUL }, { 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, 0x72fd2493UL }, { 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, 0xed3498beUL }, { 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, 0xf10605deUL #endif } };
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Interop/PInvoke/Generics/GenericsNative.SequentialClassC.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #include <stdio.h> #include <stdint.h> #include <xplatform.h> #include <platformdefines.h> struct SequentialClassC { char16_t value; }; static SequentialClassC SequentialClassCValue = { }; extern "C" DLL_EXPORT SequentialClassC* STDMETHODCALLTYPE GetSequentialClassC(char16_t value) { throw "P/Invoke for SequentialClass<char> should be unsupported."; } extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetSequentialClassCOut(char16_t value, SequentialClassC** pValue) { throw "P/Invoke for SequentialClass<char> should be unsupported."; } extern "C" DLL_EXPORT const SequentialClassC** STDMETHODCALLTYPE GetSequentialClassCPtr(char16_t value) { throw "P/Invoke for SequentialClass<char> should be unsupported."; } extern "C" DLL_EXPORT SequentialClassC* STDMETHODCALLTYPE AddSequentialClassC(SequentialClassC* lhs, SequentialClassC* rhs) { throw "P/Invoke for SequentialClass<char> should be unsupported."; } extern "C" DLL_EXPORT SequentialClassC* STDMETHODCALLTYPE AddSequentialClassCs(const SequentialClassC** pValues, uint32_t count) { throw "P/Invoke for SequentialClass<char> should be unsupported."; }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #include <stdio.h> #include <stdint.h> #include <xplatform.h> #include <platformdefines.h> struct SequentialClassC { char16_t value; }; static SequentialClassC SequentialClassCValue = { }; extern "C" DLL_EXPORT SequentialClassC* STDMETHODCALLTYPE GetSequentialClassC(char16_t value) { throw "P/Invoke for SequentialClass<char> should be unsupported."; } extern "C" DLL_EXPORT void STDMETHODCALLTYPE GetSequentialClassCOut(char16_t value, SequentialClassC** pValue) { throw "P/Invoke for SequentialClass<char> should be unsupported."; } extern "C" DLL_EXPORT const SequentialClassC** STDMETHODCALLTYPE GetSequentialClassCPtr(char16_t value) { throw "P/Invoke for SequentialClass<char> should be unsupported."; } extern "C" DLL_EXPORT SequentialClassC* STDMETHODCALLTYPE AddSequentialClassC(SequentialClassC* lhs, SequentialClassC* rhs) { throw "P/Invoke for SequentialClass<char> should be unsupported."; } extern "C" DLL_EXPORT SequentialClassC* STDMETHODCALLTYPE AddSequentialClassCs(const SequentialClassC** pValues, uint32_t count) { throw "P/Invoke for SequentialClass<char> should be unsupported."; }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaCollection.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Xml.Schema { using System; using System.Threading; using System.Collections; using System.Xml.Schema; using System.Runtime.Versioning; /// <summary> /// The XmlSchemaCollection contains a set of namespace URI's. /// Each namespace also have an associated private data cache /// corresponding to the XML-Data Schema or W3C XML Schema. /// The XmlSchemaCollection will able to load XSD and XDR schemas, /// and compile them into an internal "cooked schema representation". /// The Validate method then uses this internal representation for /// efficient runtime validation of any given subtree. /// </summary> [Obsolete("XmlSchemaCollection has been deprecated. Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation instead.")] public sealed class XmlSchemaCollection : ICollection { private readonly Hashtable _collection; private readonly XmlNameTable _nameTable; private SchemaNames? _schemaNames; private readonly object? _wLock; private readonly bool _isThreadSafe = true; private ValidationEventHandler? _validationEventHandler; private XmlResolver? _xmlResolver; /// <summary> /// Construct a new empty schema collection. /// </summary> public XmlSchemaCollection() : this(new NameTable()) { } /// <summary> /// Construct a new empty schema collection with associated XmlNameTable. /// The XmlNameTable is used when loading schemas. /// </summary> public XmlSchemaCollection(XmlNameTable nametable!!) { _nameTable = nametable; _collection = Hashtable.Synchronized(new Hashtable()); _xmlResolver = null; _isThreadSafe = true; if (_isThreadSafe) { _wLock = new object(); } } /// <summary> /// Returns the number of namespaces defined in this collection /// (whether or not there is an actual schema associated with those namespaces or not). /// </summary> public int Count { get { return _collection.Count; } } /// <summary> /// The default XmlNameTable used by the XmlSchemaCollection when loading new schemas. /// </summary> public XmlNameTable NameTable { get { return _nameTable; } } public event ValidationEventHandler ValidationEventHandler { add { _validationEventHandler += value; } remove { _validationEventHandler -= value; } } internal XmlResolver? XmlResolver { set { _xmlResolver = value; } } /// <summary> /// Add the schema located by the given URL into the schema collection. /// If the given schema references other namespaces, the schemas for those other /// namespaces are NOT automatically loaded. /// </summary> public XmlSchema? Add(string? ns, string uri) { if (uri == null || uri.Length == 0) throw new ArgumentNullException(nameof(uri)); XmlTextReader reader = new XmlTextReader(uri, _nameTable); reader.XmlResolver = _xmlResolver; XmlSchema? schema = null; try { schema = Add(ns, reader, _xmlResolver); while (reader.Read()) ; // wellformness check } finally { reader.Close(); } return schema; } public XmlSchema? Add(string? ns, XmlReader reader) { return Add(ns, reader, _xmlResolver); } /// <summary> /// Add the given schema into the schema collection. /// If the given schema references other namespaces, the schemas for those /// other namespaces are NOT automatically loaded. /// </summary> public XmlSchema? Add(string? ns, XmlReader reader!!, XmlResolver? resolver) { XmlNameTable readerNameTable = reader.NameTable; SchemaInfo schemaInfo = new SchemaInfo(); Parser parser = new Parser(SchemaType.None, readerNameTable, GetSchemaNames(readerNameTable), _validationEventHandler); parser.XmlResolver = resolver; SchemaType schemaType; try { schemaType = parser.Parse(reader, ns); } catch (XmlSchemaException e) { SendValidationEvent(e); return null; } if (schemaType == SchemaType.XSD) { schemaInfo.SchemaType = SchemaType.XSD; return Add(ns, schemaInfo, parser.XmlSchema, true, resolver); } else { return Add(ns, parser.XdrSchema!, null, true, resolver); } } public XmlSchema? Add(XmlSchema schema) { return Add(schema, _xmlResolver); } public XmlSchema? Add(XmlSchema schema!!, XmlResolver? resolver) { SchemaInfo schemaInfo = new SchemaInfo(); schemaInfo.SchemaType = SchemaType.XSD; return Add(schema.TargetNamespace, schemaInfo, schema, true, resolver); } /// <summary> /// Adds all the namespaces defined in the given collection /// (including their associated schemas) to this collection. /// </summary> public void Add(XmlSchemaCollection schema!!) { if (this == schema) return; IDictionaryEnumerator enumerator = schema._collection.GetEnumerator(); while (enumerator.MoveNext()) { XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)enumerator.Value!; Add(node!.NamespaceURI!, node); } } /// <summary> /// Looks up the schema by its associated namespace URI /// </summary> public XmlSchema? this[string? ns] { get { XmlSchemaCollectionNode? node = (XmlSchemaCollectionNode?)_collection[(ns != null) ? ns : string.Empty]; return (node != null) ? node.Schema : null; } } public bool Contains(XmlSchema schema!!) { return this[schema.TargetNamespace] != null; } public bool Contains(string? ns) { return _collection[(ns != null) ? ns : string.Empty] != null; } /// <summary> /// Get a IEnumerator of the XmlSchemaCollection. /// </summary> IEnumerator IEnumerable.GetEnumerator() { return new XmlSchemaCollectionEnumerator(_collection); } public XmlSchemaCollectionEnumerator GetEnumerator() { return new XmlSchemaCollectionEnumerator(_collection); } void ICollection.CopyTo(Array array!!, int index) { if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); for (XmlSchemaCollectionEnumerator e = this.GetEnumerator(); e.MoveNext();) { if (index == array.Length) { throw new ArgumentOutOfRangeException(nameof(index)); } array.SetValue(e.Current, index++); } } public void CopyTo(XmlSchema[] array!!, int index) { if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); for (XmlSchemaCollectionEnumerator e = this.GetEnumerator(); e.MoveNext();) { XmlSchema? schema = e.Current; if (schema != null) { if (index == array.Length) { throw new ArgumentOutOfRangeException(nameof(index)); } array[index++] = e.Current!; } } } bool ICollection.IsSynchronized { get { return true; } } object ICollection.SyncRoot { get { return this; } } int ICollection.Count { get { return _collection.Count; } } internal SchemaInfo? GetSchemaInfo(string? ns) { XmlSchemaCollectionNode? node = (XmlSchemaCollectionNode?)_collection[(ns != null) ? ns : string.Empty]; return (node != null) ? node.SchemaInfo : null; } internal SchemaNames GetSchemaNames(XmlNameTable nt) { if (_nameTable != nt) { return new SchemaNames(nt); } else { if (_schemaNames == null) { _schemaNames = new SchemaNames(_nameTable); } return _schemaNames; } } internal XmlSchema? Add(string? ns, SchemaInfo schemaInfo, XmlSchema? schema, bool compile) { return Add(ns, schemaInfo, schema, compile, _xmlResolver); } private XmlSchema? Add(string? ns, SchemaInfo schemaInfo, XmlSchema? schema, bool compile, XmlResolver? resolver) { int errorCount = 0; if (schema != null) { if (schema.ErrorCount == 0 && compile) { if (!schema.CompileSchema(this, resolver, schemaInfo, ns, _validationEventHandler, _nameTable, true)) { errorCount = 1; } ns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace; } errorCount += schema.ErrorCount; } else { errorCount += schemaInfo.ErrorCount; //ns = ns == null? string.Empty : NameTable.Add(ns); ns = NameTable.Add(ns!); //Added without checking for ns == null, since XDR cannot have null namespace } if (errorCount == 0) { XmlSchemaCollectionNode node = new XmlSchemaCollectionNode(); node.NamespaceURI = ns; node.SchemaInfo = schemaInfo; node.Schema = schema; Add(ns!, node); return schema; } return null; } private void AddNonThreadSafe(string ns, XmlSchemaCollectionNode? node) { if (_collection[ns] != null) _collection.Remove(ns); _collection.Add(ns, node); } private void Add(string ns, XmlSchemaCollectionNode? node) { if (_isThreadSafe) { lock (_wLock!) { AddNonThreadSafe(ns, node); } } else { AddNonThreadSafe(ns, node); } } private void SendValidationEvent(XmlSchemaException e) { if (_validationEventHandler != null) { _validationEventHandler(this, new ValidationEventArgs(e)); } else { throw e; } } internal ValidationEventHandler? EventHandler { get { return _validationEventHandler; } set { _validationEventHandler = value; } } }; internal sealed class XmlSchemaCollectionNode { private string? _namespaceUri; private SchemaInfo? _schemaInfo; private XmlSchema? _schema; internal string? NamespaceURI { get { return _namespaceUri; } set { _namespaceUri = value; } } internal SchemaInfo? SchemaInfo { get { return _schemaInfo; } set { _schemaInfo = value; } } internal XmlSchema? Schema { get { return _schema; } set { _schema = value; } } } public sealed class XmlSchemaCollectionEnumerator : IEnumerator { private readonly IDictionaryEnumerator _enumerator; internal XmlSchemaCollectionEnumerator(Hashtable collection) { _enumerator = collection.GetEnumerator(); } void IEnumerator.Reset() { _enumerator.Reset(); } bool IEnumerator.MoveNext() { return _enumerator.MoveNext(); } public bool MoveNext() { return _enumerator.MoveNext(); } object? IEnumerator.Current { get { return this.Current; } } public XmlSchema? Current { get { XmlSchemaCollectionNode? n = (XmlSchemaCollectionNode?)_enumerator.Value; if (n != null) return n.Schema; else return null; } } internal XmlSchemaCollectionNode? CurrentNode { get { XmlSchemaCollectionNode? n = (XmlSchemaCollectionNode?)_enumerator.Value; return n; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Xml.Schema { using System; using System.Threading; using System.Collections; using System.Xml.Schema; using System.Runtime.Versioning; /// <summary> /// The XmlSchemaCollection contains a set of namespace URI's. /// Each namespace also have an associated private data cache /// corresponding to the XML-Data Schema or W3C XML Schema. /// The XmlSchemaCollection will able to load XSD and XDR schemas, /// and compile them into an internal "cooked schema representation". /// The Validate method then uses this internal representation for /// efficient runtime validation of any given subtree. /// </summary> [Obsolete("XmlSchemaCollection has been deprecated. Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation instead.")] public sealed class XmlSchemaCollection : ICollection { private readonly Hashtable _collection; private readonly XmlNameTable _nameTable; private SchemaNames? _schemaNames; private readonly object? _wLock; private readonly bool _isThreadSafe = true; private ValidationEventHandler? _validationEventHandler; private XmlResolver? _xmlResolver; /// <summary> /// Construct a new empty schema collection. /// </summary> public XmlSchemaCollection() : this(new NameTable()) { } /// <summary> /// Construct a new empty schema collection with associated XmlNameTable. /// The XmlNameTable is used when loading schemas. /// </summary> public XmlSchemaCollection(XmlNameTable nametable!!) { _nameTable = nametable; _collection = Hashtable.Synchronized(new Hashtable()); _xmlResolver = null; _isThreadSafe = true; if (_isThreadSafe) { _wLock = new object(); } } /// <summary> /// Returns the number of namespaces defined in this collection /// (whether or not there is an actual schema associated with those namespaces or not). /// </summary> public int Count { get { return _collection.Count; } } /// <summary> /// The default XmlNameTable used by the XmlSchemaCollection when loading new schemas. /// </summary> public XmlNameTable NameTable { get { return _nameTable; } } public event ValidationEventHandler ValidationEventHandler { add { _validationEventHandler += value; } remove { _validationEventHandler -= value; } } internal XmlResolver? XmlResolver { set { _xmlResolver = value; } } /// <summary> /// Add the schema located by the given URL into the schema collection. /// If the given schema references other namespaces, the schemas for those other /// namespaces are NOT automatically loaded. /// </summary> public XmlSchema? Add(string? ns, string uri) { if (uri == null || uri.Length == 0) throw new ArgumentNullException(nameof(uri)); XmlTextReader reader = new XmlTextReader(uri, _nameTable); reader.XmlResolver = _xmlResolver; XmlSchema? schema = null; try { schema = Add(ns, reader, _xmlResolver); while (reader.Read()) ; // wellformness check } finally { reader.Close(); } return schema; } public XmlSchema? Add(string? ns, XmlReader reader) { return Add(ns, reader, _xmlResolver); } /// <summary> /// Add the given schema into the schema collection. /// If the given schema references other namespaces, the schemas for those /// other namespaces are NOT automatically loaded. /// </summary> public XmlSchema? Add(string? ns, XmlReader reader!!, XmlResolver? resolver) { XmlNameTable readerNameTable = reader.NameTable; SchemaInfo schemaInfo = new SchemaInfo(); Parser parser = new Parser(SchemaType.None, readerNameTable, GetSchemaNames(readerNameTable), _validationEventHandler); parser.XmlResolver = resolver; SchemaType schemaType; try { schemaType = parser.Parse(reader, ns); } catch (XmlSchemaException e) { SendValidationEvent(e); return null; } if (schemaType == SchemaType.XSD) { schemaInfo.SchemaType = SchemaType.XSD; return Add(ns, schemaInfo, parser.XmlSchema, true, resolver); } else { return Add(ns, parser.XdrSchema!, null, true, resolver); } } public XmlSchema? Add(XmlSchema schema) { return Add(schema, _xmlResolver); } public XmlSchema? Add(XmlSchema schema!!, XmlResolver? resolver) { SchemaInfo schemaInfo = new SchemaInfo(); schemaInfo.SchemaType = SchemaType.XSD; return Add(schema.TargetNamespace, schemaInfo, schema, true, resolver); } /// <summary> /// Adds all the namespaces defined in the given collection /// (including their associated schemas) to this collection. /// </summary> public void Add(XmlSchemaCollection schema!!) { if (this == schema) return; IDictionaryEnumerator enumerator = schema._collection.GetEnumerator(); while (enumerator.MoveNext()) { XmlSchemaCollectionNode node = (XmlSchemaCollectionNode)enumerator.Value!; Add(node!.NamespaceURI!, node); } } /// <summary> /// Looks up the schema by its associated namespace URI /// </summary> public XmlSchema? this[string? ns] { get { XmlSchemaCollectionNode? node = (XmlSchemaCollectionNode?)_collection[(ns != null) ? ns : string.Empty]; return (node != null) ? node.Schema : null; } } public bool Contains(XmlSchema schema!!) { return this[schema.TargetNamespace] != null; } public bool Contains(string? ns) { return _collection[(ns != null) ? ns : string.Empty] != null; } /// <summary> /// Get a IEnumerator of the XmlSchemaCollection. /// </summary> IEnumerator IEnumerable.GetEnumerator() { return new XmlSchemaCollectionEnumerator(_collection); } public XmlSchemaCollectionEnumerator GetEnumerator() { return new XmlSchemaCollectionEnumerator(_collection); } void ICollection.CopyTo(Array array!!, int index) { if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); for (XmlSchemaCollectionEnumerator e = this.GetEnumerator(); e.MoveNext();) { if (index == array.Length) { throw new ArgumentOutOfRangeException(nameof(index)); } array.SetValue(e.Current, index++); } } public void CopyTo(XmlSchema[] array!!, int index) { if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); for (XmlSchemaCollectionEnumerator e = this.GetEnumerator(); e.MoveNext();) { XmlSchema? schema = e.Current; if (schema != null) { if (index == array.Length) { throw new ArgumentOutOfRangeException(nameof(index)); } array[index++] = e.Current!; } } } bool ICollection.IsSynchronized { get { return true; } } object ICollection.SyncRoot { get { return this; } } int ICollection.Count { get { return _collection.Count; } } internal SchemaInfo? GetSchemaInfo(string? ns) { XmlSchemaCollectionNode? node = (XmlSchemaCollectionNode?)_collection[(ns != null) ? ns : string.Empty]; return (node != null) ? node.SchemaInfo : null; } internal SchemaNames GetSchemaNames(XmlNameTable nt) { if (_nameTable != nt) { return new SchemaNames(nt); } else { if (_schemaNames == null) { _schemaNames = new SchemaNames(_nameTable); } return _schemaNames; } } internal XmlSchema? Add(string? ns, SchemaInfo schemaInfo, XmlSchema? schema, bool compile) { return Add(ns, schemaInfo, schema, compile, _xmlResolver); } private XmlSchema? Add(string? ns, SchemaInfo schemaInfo, XmlSchema? schema, bool compile, XmlResolver? resolver) { int errorCount = 0; if (schema != null) { if (schema.ErrorCount == 0 && compile) { if (!schema.CompileSchema(this, resolver, schemaInfo, ns, _validationEventHandler, _nameTable, true)) { errorCount = 1; } ns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace; } errorCount += schema.ErrorCount; } else { errorCount += schemaInfo.ErrorCount; //ns = ns == null? string.Empty : NameTable.Add(ns); ns = NameTable.Add(ns!); //Added without checking for ns == null, since XDR cannot have null namespace } if (errorCount == 0) { XmlSchemaCollectionNode node = new XmlSchemaCollectionNode(); node.NamespaceURI = ns; node.SchemaInfo = schemaInfo; node.Schema = schema; Add(ns!, node); return schema; } return null; } private void AddNonThreadSafe(string ns, XmlSchemaCollectionNode? node) { if (_collection[ns] != null) _collection.Remove(ns); _collection.Add(ns, node); } private void Add(string ns, XmlSchemaCollectionNode? node) { if (_isThreadSafe) { lock (_wLock!) { AddNonThreadSafe(ns, node); } } else { AddNonThreadSafe(ns, node); } } private void SendValidationEvent(XmlSchemaException e) { if (_validationEventHandler != null) { _validationEventHandler(this, new ValidationEventArgs(e)); } else { throw e; } } internal ValidationEventHandler? EventHandler { get { return _validationEventHandler; } set { _validationEventHandler = value; } } }; internal sealed class XmlSchemaCollectionNode { private string? _namespaceUri; private SchemaInfo? _schemaInfo; private XmlSchema? _schema; internal string? NamespaceURI { get { return _namespaceUri; } set { _namespaceUri = value; } } internal SchemaInfo? SchemaInfo { get { return _schemaInfo; } set { _schemaInfo = value; } } internal XmlSchema? Schema { get { return _schema; } set { _schema = value; } } } public sealed class XmlSchemaCollectionEnumerator : IEnumerator { private readonly IDictionaryEnumerator _enumerator; internal XmlSchemaCollectionEnumerator(Hashtable collection) { _enumerator = collection.GetEnumerator(); } void IEnumerator.Reset() { _enumerator.Reset(); } bool IEnumerator.MoveNext() { return _enumerator.MoveNext(); } public bool MoveNext() { return _enumerator.MoveNext(); } object? IEnumerator.Current { get { return this.Current; } } public XmlSchema? Current { get { XmlSchemaCollectionNode? n = (XmlSchemaCollectionNode?)_enumerator.Value; if (n != null) return n.Schema; else return null; } } internal XmlSchemaCollectionNode? CurrentNode { get { XmlSchemaCollectionNode? n = (XmlSchemaCollectionNode?)_enumerator.Value; return n; } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/GC/Scenarios/DoublinkList/doublinkstay.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************** /*Test case for testing GC with cyclic double linked list leaks /*In every loop. SetLink() to create a doubLink object array whose size /*is iRep, each DoubLink Object is a iObj node cyclic double /*linked list. MakeLeak() deletes all the object reference in the array /*to make all the cyclic double linked lists become memory leaks. /*objects' life time is longer than DoubLinkGen. /******************************************************************/ namespace DoubLink { using System; using System.Runtime.CompilerServices; public class DoubLinkStay { internal DoubLink[] Mv_Doub; public static int Main(System.String [] Args) { int iRep = 100; int iObj = 10; Console.WriteLine("Test should return with ExitCode 100 ..."); switch( Args.Length ) { case 1: if (!Int32.TryParse( Args[0], out iRep )) { iRep = 100; } break; case 2: if (!Int32.TryParse( Args[0], out iRep )) { iRep = 100; } if (!Int32.TryParse( Args[1], out iObj )) { iObj = 10; } break; default: iRep = 100; iObj = 10; break; } DoubLinkStay Mv_Leak = new DoubLinkStay(); if(Mv_Leak.runTest(iRep, iObj )) { Console.WriteLine("Test Passed"); return 100; } Console.WriteLine("Test Failed"); return 1; } public bool runTest(int iRep, int iObj) { CreateDLinkListsWithLeak(iRep, iObj, 20); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); Console.Write(DLinkNode.FinalCount); Console.WriteLine(" DLinkNodes finalized"); return (DLinkNode.FinalCount==iRep*iObj*20); } [MethodImpl(MethodImplOptions.NoInlining)] // Do not inline the method that creates GC objects, because it could // extend their live intervals until the end of the parent method. public void CreateDLinkListsWithLeak(int iRep, int iObj, int iters) { Mv_Doub = new DoubLink[iRep]; for(int i = 0; i < iters; i++) { SetLink(iRep, iObj); MakeLeak(iRep); } } public void SetLink(int iRep, int iObj) { for(int i=0; i<iRep; i++) { Mv_Doub[i] = new DoubLink(iObj); } } public void MakeLeak(int iRep) { for(int i=0; i<iRep; i++) { Mv_Doub[i] = null; } } } public class DoubLink { internal DLinkNode[] Mv_DLink; public DoubLink(int Num) : this(Num, false) { } public DoubLink(int Num, bool large) { Mv_DLink = new DLinkNode[Num]; if (Num == 0) { return; } if (Num == 1) { // only one element Mv_DLink[0] = new DLinkNode((large ? 250 : 1), Mv_DLink[0], Mv_DLink[0]); return; } // first element Mv_DLink[0] = new DLinkNode((large ? 250 : 1), Mv_DLink[Num - 1], Mv_DLink[1]); // all elements in between for (int i = 1; i < Num - 1; i++) { Mv_DLink[i] = new DLinkNode((large ? 250 : i + 1), Mv_DLink[i - 1], Mv_DLink[i + 1]); } // last element Mv_DLink[Num - 1] = new DLinkNode((large ? 250 : Num), Mv_DLink[Num - 2], Mv_DLink[0]); } public int NodeNum { get { return Mv_DLink.Length; } } public DLinkNode this[int index] { get { return Mv_DLink[index]; } set { Mv_DLink[index] = value; } } } public class DLinkNode { // disabling unused variable warning #pragma warning disable 0414 internal DLinkNode Last; internal DLinkNode Next; internal int[] Size; #pragma warning restore 0414 public static int FinalCount = 0; public DLinkNode(int SizeNum, DLinkNode LastObject, DLinkNode NextObject) { Last = LastObject; Next = NextObject; Size = new int[SizeNum * 1024]; } ~DLinkNode() { FinalCount++; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************** /*Test case for testing GC with cyclic double linked list leaks /*In every loop. SetLink() to create a doubLink object array whose size /*is iRep, each DoubLink Object is a iObj node cyclic double /*linked list. MakeLeak() deletes all the object reference in the array /*to make all the cyclic double linked lists become memory leaks. /*objects' life time is longer than DoubLinkGen. /******************************************************************/ namespace DoubLink { using System; using System.Runtime.CompilerServices; public class DoubLinkStay { internal DoubLink[] Mv_Doub; public static int Main(System.String [] Args) { int iRep = 100; int iObj = 10; Console.WriteLine("Test should return with ExitCode 100 ..."); switch( Args.Length ) { case 1: if (!Int32.TryParse( Args[0], out iRep )) { iRep = 100; } break; case 2: if (!Int32.TryParse( Args[0], out iRep )) { iRep = 100; } if (!Int32.TryParse( Args[1], out iObj )) { iObj = 10; } break; default: iRep = 100; iObj = 10; break; } DoubLinkStay Mv_Leak = new DoubLinkStay(); if(Mv_Leak.runTest(iRep, iObj )) { Console.WriteLine("Test Passed"); return 100; } Console.WriteLine("Test Failed"); return 1; } public bool runTest(int iRep, int iObj) { CreateDLinkListsWithLeak(iRep, iObj, 20); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); Console.Write(DLinkNode.FinalCount); Console.WriteLine(" DLinkNodes finalized"); return (DLinkNode.FinalCount==iRep*iObj*20); } [MethodImpl(MethodImplOptions.NoInlining)] // Do not inline the method that creates GC objects, because it could // extend their live intervals until the end of the parent method. public void CreateDLinkListsWithLeak(int iRep, int iObj, int iters) { Mv_Doub = new DoubLink[iRep]; for(int i = 0; i < iters; i++) { SetLink(iRep, iObj); MakeLeak(iRep); } } public void SetLink(int iRep, int iObj) { for(int i=0; i<iRep; i++) { Mv_Doub[i] = new DoubLink(iObj); } } public void MakeLeak(int iRep) { for(int i=0; i<iRep; i++) { Mv_Doub[i] = null; } } } public class DoubLink { internal DLinkNode[] Mv_DLink; public DoubLink(int Num) : this(Num, false) { } public DoubLink(int Num, bool large) { Mv_DLink = new DLinkNode[Num]; if (Num == 0) { return; } if (Num == 1) { // only one element Mv_DLink[0] = new DLinkNode((large ? 250 : 1), Mv_DLink[0], Mv_DLink[0]); return; } // first element Mv_DLink[0] = new DLinkNode((large ? 250 : 1), Mv_DLink[Num - 1], Mv_DLink[1]); // all elements in between for (int i = 1; i < Num - 1; i++) { Mv_DLink[i] = new DLinkNode((large ? 250 : i + 1), Mv_DLink[i - 1], Mv_DLink[i + 1]); } // last element Mv_DLink[Num - 1] = new DLinkNode((large ? 250 : Num), Mv_DLink[Num - 2], Mv_DLink[0]); } public int NodeNum { get { return Mv_DLink.Length; } } public DLinkNode this[int index] { get { return Mv_DLink[index]; } set { Mv_DLink[index] = value; } } } public class DLinkNode { // disabling unused variable warning #pragma warning disable 0414 internal DLinkNode Last; internal DLinkNode Next; internal int[] Size; #pragma warning restore 0414 public static int FinalCount = 0; public DLinkNode(int SizeNum, DLinkNode LastObject, DLinkNode NextObject) { Last = LastObject; Next = NextObject; Size = new int[SizeNum * 1024]; } ~DLinkNode() { FinalCount++; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/HardwareIntrinsics/General/Vector256/EqualsAny.SByte.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void EqualsAnySByte() { var test = new VectorBooleanBinaryOpTest__EqualsAnySByte(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBooleanBinaryOpTest__EqualsAnySByte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private GCHandle inHandle1; private GCHandle inHandle2; private ulong alignment; public DataTable(SByte[] inArray1, SByte[] inArray2, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<SByte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<SByte>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<SByte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<SByte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<SByte> _fld1; public Vector256<SByte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref testStruct._fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref testStruct._fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); return testStruct; } public void RunStructFldScenario(VectorBooleanBinaryOpTest__EqualsAnySByte testClass) { var result = Vector256.EqualsAny(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<SByte>>() / sizeof(SByte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<SByte>>() / sizeof(SByte); private static SByte[] _data1 = new SByte[Op1ElementCount]; private static SByte[] _data2 = new SByte[Op2ElementCount]; private static Vector256<SByte> _clsVar1; private static Vector256<SByte> _clsVar2; private Vector256<SByte> _fld1; private Vector256<SByte> _fld2; private DataTable _dataTable; static VectorBooleanBinaryOpTest__EqualsAnySByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); } public VectorBooleanBinaryOpTest__EqualsAnySByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } _dataTable = new DataTable(_data1, _data2, LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector256.EqualsAny( Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector256).GetMethod(nameof(Vector256.EqualsAny), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) }); if (method is null) { method = typeof(Vector256).GetMethod(nameof(Vector256.EqualsAny), 1, new Type[] { typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(SByte)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector256.EqualsAny( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr); var result = Vector256.EqualsAny(op1, op2); ValidateResult(op1, op2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBooleanBinaryOpTest__EqualsAnySByte(); var result = Vector256.EqualsAny(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector256.EqualsAny(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector256.EqualsAny(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<SByte> op1, Vector256<SByte> op2, bool result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), op2); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(void* op1, void* op2, bool result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<SByte>>()); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(SByte[] left, SByte[] right, bool result, [CallerMemberName] string method = "") { bool succeeded = true; var expectedResult = false; for (var i = 0; i < Op1ElementCount; i++) { expectedResult |= (left[i] == right[i]); } succeeded = (expectedResult == result); if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.EqualsAny)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({result})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void EqualsAnySByte() { var test = new VectorBooleanBinaryOpTest__EqualsAnySByte(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBooleanBinaryOpTest__EqualsAnySByte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private GCHandle inHandle1; private GCHandle inHandle2; private ulong alignment; public DataTable(SByte[] inArray1, SByte[] inArray2, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<SByte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<SByte>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<SByte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<SByte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<SByte> _fld1; public Vector256<SByte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref testStruct._fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref testStruct._fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); return testStruct; } public void RunStructFldScenario(VectorBooleanBinaryOpTest__EqualsAnySByte testClass) { var result = Vector256.EqualsAny(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<SByte>>() / sizeof(SByte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<SByte>>() / sizeof(SByte); private static SByte[] _data1 = new SByte[Op1ElementCount]; private static SByte[] _data2 = new SByte[Op2ElementCount]; private static Vector256<SByte> _clsVar1; private static Vector256<SByte> _clsVar2; private Vector256<SByte> _fld1; private Vector256<SByte> _fld2; private DataTable _dataTable; static VectorBooleanBinaryOpTest__EqualsAnySByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); } public VectorBooleanBinaryOpTest__EqualsAnySByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<SByte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } _dataTable = new DataTable(_data1, _data2, LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector256.EqualsAny( Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr) ); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector256).GetMethod(nameof(Vector256.EqualsAny), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) }); if (method is null) { method = typeof(Vector256).GetMethod(nameof(Vector256.EqualsAny), 1, new Type[] { typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(SByte)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr) }); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result)); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector256.EqualsAny( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr); var result = Vector256.EqualsAny(op1, op2); ValidateResult(op1, op2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBooleanBinaryOpTest__EqualsAnySByte(); var result = Vector256.EqualsAny(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector256.EqualsAny(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector256.EqualsAny(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<SByte> op1, Vector256<SByte> op2, bool result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), op2); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(void* op1, void* op2, bool result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<SByte>>()); ValidateResult(inArray1, inArray2, result, method); } private void ValidateResult(SByte[] left, SByte[] right, bool result, [CallerMemberName] string method = "") { bool succeeded = true; var expectedResult = false; for (var i = 0; i < Op1ElementCount; i++) { expectedResult |= (left[i] == right[i]); } succeeded = (expectedResult == result); if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.EqualsAny)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({result})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/coreclr/pal/tests/palsuite/c_runtime/modf/test1/test1.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================= ** ** Source: test1.c (modf) ** ** Purpose: Test to ensure that modf return the correct values ** ** Dependencies: PAL_Initialize ** PAL_Terminate ** Fail ** fabs ** **===========================================================================*/ #include <palsuite.h> // binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this // is slightly too accurate when writing tests meant to run against libm implementations // for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. // // The tests themselves will take PAL_EPSILON and adjust it according to the expected result // so that the delta used for comparison will compare the most significant digits and ignore // any digits that are outside the double precision range (15-17 digits). // For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use // PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx // will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will // use PAL_EPSILON * 10. #define PAL_EPSILON 8.8817841970012523e-16 #define PAL_NAN sqrt(-1.0) #define PAL_POSINF -log(0.0) #define PAL_NEGINF log(0.0) /** * Helper test structure */ struct test { double value; /* value to test the function with */ double expected; /* expected result */ double variance; /* maximum delta between the expected and actual result */ double expected_intpart; /* expected result */ double variance_intpart; /* maximum delta between the expected and actual result */ }; /** * modf_test1_validate * * test validation function */ void __cdecl modf_test1_validate(double value, double expected, double variance, double expected_intpart, double variance_intpart) { double result_intpart; double result = modf(value, &result_intpart); /* * The test is valid when the difference between result * and expected is less than or equal to variance */ double delta = fabs(result - expected); double delta_intpart = fabs(result_intpart - expected_intpart); if ((delta > variance) || (delta_intpart > variance_intpart)) { Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g", value, result, result_intpart, expected, expected_intpart); } } /** * modf_test1_validate * * test validation function for values returning NaN */ void __cdecl modf_test1_validate_isnan(double value) { double result_intpart; double result = modf(value, &result_intpart); if (!_isnan(result) || !_isnan(result_intpart)) { Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g", value, result, result_intpart, PAL_NAN, PAL_NAN); } } /** * main * * executable entry point */ PALTEST(c_runtime_modf_test1_paltest_modf_test1, "c_runtime/modf/test1/paltest_modf_test1") { struct test tests[] = { /* value expected variance expected_intpart variance_intpart */ { 0, 0, PAL_EPSILON, 0, PAL_EPSILON }, { 0.31830988618379067, 0.31830988618379067, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / pi { 0.43429448190325183, 0.43429448190325183, PAL_EPSILON, 0, PAL_EPSILON }, // value: log10(e) { 0.63661977236758134, 0.63661977236758134, PAL_EPSILON, 0, PAL_EPSILON }, // value: 2 / pi { 0.69314718055994531, 0.69314718055994531, PAL_EPSILON, 0, PAL_EPSILON }, // value: ln(2) { 0.70710678118654752, 0.70710678118654752, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / sqrt(2) { 0.78539816339744831, 0.78539816339744831, PAL_EPSILON, 0, PAL_EPSILON }, // value: pi / 4 { 1, 0, PAL_EPSILON, 1, PAL_EPSILON * 10 }, { 1.1283791670955126, 0.1283791670955126, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) { 1.4142135623730950, 0.4142135623730950, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: sqrt(2) { 1.4426950408889634, 0.4426950408889634, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: log2(e) { 1.5707963267948966, 0.5707963267948966, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: pi / 2 { 2.3025850929940457, 0.3025850929940457, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: ln(10) { 2.7182818284590452, 0.7182818284590452, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: e { 3.1415926535897932, 0.1415926535897932, PAL_EPSILON, 3, PAL_EPSILON * 10 }, // value: pi { PAL_POSINF, 0, PAL_EPSILON, PAL_POSINF, 0 } }; /* PAL initialization */ if (PAL_Initialize(argc, argv) != 0) { return FAIL; } for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) { modf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance, tests[i].expected_intpart, tests[i].variance_intpart); modf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance, -tests[i].expected_intpart, tests[i].variance_intpart); } modf_test1_validate_isnan(PAL_NAN); PAL_Terminate(); return PASS; }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================= ** ** Source: test1.c (modf) ** ** Purpose: Test to ensure that modf return the correct values ** ** Dependencies: PAL_Initialize ** PAL_Terminate ** Fail ** fabs ** **===========================================================================*/ #include <palsuite.h> // binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this // is slightly too accurate when writing tests meant to run against libm implementations // for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. // // The tests themselves will take PAL_EPSILON and adjust it according to the expected result // so that the delta used for comparison will compare the most significant digits and ignore // any digits that are outside the double precision range (15-17 digits). // For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use // PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx // will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will // use PAL_EPSILON * 10. #define PAL_EPSILON 8.8817841970012523e-16 #define PAL_NAN sqrt(-1.0) #define PAL_POSINF -log(0.0) #define PAL_NEGINF log(0.0) /** * Helper test structure */ struct test { double value; /* value to test the function with */ double expected; /* expected result */ double variance; /* maximum delta between the expected and actual result */ double expected_intpart; /* expected result */ double variance_intpart; /* maximum delta between the expected and actual result */ }; /** * modf_test1_validate * * test validation function */ void __cdecl modf_test1_validate(double value, double expected, double variance, double expected_intpart, double variance_intpart) { double result_intpart; double result = modf(value, &result_intpart); /* * The test is valid when the difference between result * and expected is less than or equal to variance */ double delta = fabs(result - expected); double delta_intpart = fabs(result_intpart - expected_intpart); if ((delta > variance) || (delta_intpart > variance_intpart)) { Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g", value, result, result_intpart, expected, expected_intpart); } } /** * modf_test1_validate * * test validation function for values returning NaN */ void __cdecl modf_test1_validate_isnan(double value) { double result_intpart; double result = modf(value, &result_intpart); if (!_isnan(result) || !_isnan(result_intpart)) { Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g", value, result, result_intpart, PAL_NAN, PAL_NAN); } } /** * main * * executable entry point */ PALTEST(c_runtime_modf_test1_paltest_modf_test1, "c_runtime/modf/test1/paltest_modf_test1") { struct test tests[] = { /* value expected variance expected_intpart variance_intpart */ { 0, 0, PAL_EPSILON, 0, PAL_EPSILON }, { 0.31830988618379067, 0.31830988618379067, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / pi { 0.43429448190325183, 0.43429448190325183, PAL_EPSILON, 0, PAL_EPSILON }, // value: log10(e) { 0.63661977236758134, 0.63661977236758134, PAL_EPSILON, 0, PAL_EPSILON }, // value: 2 / pi { 0.69314718055994531, 0.69314718055994531, PAL_EPSILON, 0, PAL_EPSILON }, // value: ln(2) { 0.70710678118654752, 0.70710678118654752, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / sqrt(2) { 0.78539816339744831, 0.78539816339744831, PAL_EPSILON, 0, PAL_EPSILON }, // value: pi / 4 { 1, 0, PAL_EPSILON, 1, PAL_EPSILON * 10 }, { 1.1283791670955126, 0.1283791670955126, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) { 1.4142135623730950, 0.4142135623730950, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: sqrt(2) { 1.4426950408889634, 0.4426950408889634, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: log2(e) { 1.5707963267948966, 0.5707963267948966, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: pi / 2 { 2.3025850929940457, 0.3025850929940457, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: ln(10) { 2.7182818284590452, 0.7182818284590452, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: e { 3.1415926535897932, 0.1415926535897932, PAL_EPSILON, 3, PAL_EPSILON * 10 }, // value: pi { PAL_POSINF, 0, PAL_EPSILON, PAL_POSINF, 0 } }; /* PAL initialization */ if (PAL_Initialize(argc, argv) != 0) { return FAIL; } for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) { modf_test1_validate( tests[i].value, tests[i].expected, tests[i].variance, tests[i].expected_intpart, tests[i].variance_intpart); modf_test1_validate(-tests[i].value, -tests[i].expected, tests[i].variance, -tests[i].expected_intpart, tests[i].variance_intpart); } modf_test1_validate_isnan(PAL_NAN); PAL_Terminate(); return PASS; }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/Microsoft.Extensions.Logging/src/ProviderAliasAttribute.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace Microsoft.Extensions.Logging { /// <summary> /// Defines alias for <see cref="ILoggerProvider"/> implementation to be used in filtering rules. /// </summary> [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public class ProviderAliasAttribute : Attribute { /// <summary> /// Creates a new <see cref="ProviderAliasAttribute"/> instance. /// </summary> /// <param name="alias">The alias to set.</param> public ProviderAliasAttribute(string alias) { Alias = alias; } /// <summary> /// The alias of the provider. /// </summary> public string Alias { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; namespace Microsoft.Extensions.Logging { /// <summary> /// Defines alias for <see cref="ILoggerProvider"/> implementation to be used in filtering rules. /// </summary> [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public class ProviderAliasAttribute : Attribute { /// <summary> /// Creates a new <see cref="ProviderAliasAttribute"/> instance. /// </summary> /// <param name="alias">The alias to set.</param> public ProviderAliasAttribute(string alias) { Alias = alias; } /// <summary> /// The alias of the provider. /// </summary> public string Alias { get; } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/HardwareIntrinsics/General/Vector128/BitwiseOr.Double.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void BitwiseOrDouble() { var test = new VectorBinaryOpTest__BitwiseOrDouble(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__BitwiseOrDouble { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, Double[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Double>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Double> _fld1; public Vector128<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__BitwiseOrDouble testClass) { var result = Vector128.BitwiseOr(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector128<Double> _clsVar1; private static Vector128<Double> _clsVar2; private Vector128<Double> _fld1; private Vector128<Double> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__BitwiseOrDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); } public VectorBinaryOpTest__BitwiseOrDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector128.BitwiseOr( Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector128).GetMethod(nameof(Vector128.BitwiseOr), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>) }); if (method is null) { method = typeof(Vector128).GetMethod(nameof(Vector128.BitwiseOr), 1, new Type[] { typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Double)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector128.BitwiseOr( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr); var result = Vector128.BitwiseOr(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__BitwiseOrDouble(); var result = Vector128.BitwiseOr(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector128.BitwiseOr(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector128.BitwiseOr(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector128<Double> op1, Vector128<Double> op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.DoubleToInt64Bits(result[0]) != (BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0]))) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(result[i]) != (BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i]))) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector128)}.{nameof(Vector128.BitwiseOr)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void BitwiseOrDouble() { var test = new VectorBinaryOpTest__BitwiseOrDouble(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__BitwiseOrDouble { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Double[] inArray1, Double[] inArray2, Double[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Double>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Double>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Double>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Double, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Double, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Double> _fld1; public Vector128<Double> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__BitwiseOrDouble testClass) { var result = Vector128.BitwiseOr(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Vector128<Double> _clsVar1; private static Vector128<Double> _clsVar2; private Vector128<Double> _fld1; private Vector128<Double> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__BitwiseOrDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); } public VectorBinaryOpTest__BitwiseOrDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector128.BitwiseOr( Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector128).GetMethod(nameof(Vector128.BitwiseOr), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>) }); if (method is null) { method = typeof(Vector128).GetMethod(nameof(Vector128.BitwiseOr), 1, new Type[] { typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Double)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector128.BitwiseOr( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr); var result = Vector128.BitwiseOr(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__BitwiseOrDouble(); var result = Vector128.BitwiseOr(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector128.BitwiseOr(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector128.BitwiseOr(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector128<Double> op1, Vector128<Double> op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.DoubleToInt64Bits(result[0]) != (BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0]))) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(result[i]) != (BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i]))) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector128)}.{nameof(Vector128.BitwiseOr)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./docs/design/coreclr/botr/threading.md
CLR Threading Overview ====================== Managed vs. Native Threads ========================== Managed code executes on "managed threads," which are distinct from the native threads provided by the operating system. A native thread is a thread of execution of native code on a physical machine; a managed thread is a virtual thread of execution on the CLR's virtual machine. Just as the JIT compiler maps "virtual" IL instructions into native instructions that execute on the physical machine, the CLR's threading infrastructure maps "virtual" managed threads onto the native threads provided by the operating system. At any given time, a managed thread may or may not be assigned to a native thread for execution. For example, a managed thread that has been created (via "new System.Threading.Thread") but not yet started (via System.Threading.Thread.Start) is a managed thread that has not yet been assigned to a native thread. Similarly, a managed thread may, in principle, move between multiple native threads over the course of its execution, though in practice the CLR does not currently support this. The public Thread interface available to managed code intentionally hides the details of the underlying native threads. because: - Managed threads are not necessarily mapped to a single native thread (and may not be mapped to a native thread at all). - Different operating systems expose different abstractions for native threads. - In principle, managed threads are "virtualized". The CLR provides equivalent abstractions for managed threads, implemented by the CLR itself. For example, it does not expose the operating system's thread-local storage (TLS) mechanism, but instead provides managed "thread-static" variables. Similarly, it does not expose the native thread's "thread ID," but instead provides a "managed thread ID" which is generated independently of the OS. However, for diagnostic purposes, some details of the underlying native thread may be obtained via types in the System.Diagnostics namespace. Managed threads require additional functionality typically not needed by native threads. First, managed threads hold GC references on their stacks, so the CLR must be able to enumerate (and possibly modify) these references every time a GC occurs. To do this, the CLR must "suspend" each managed thread (stop it at a point where all of its GC references can be found). Second, when an AppDomain is unloaded, the CLR must ensure that no thread is executing code in that AppDomain. This requires the ability to force a thread to unwind out of that AppDomain. The CLR does this by injecting a ThreadAbortException into such threads. Data Structures =============== Every managed thread has an associated Thread object, defined in [threads.h][threads.h]. This object tracks everything the VM needs to know about the managed thread. This includes things that are _necessary_, such as the thread's current GC mode and Frame chain, as well as many things that are allocated per-thread simply for performance reasons (such as some fast arena-style allocators). All Thread objects are stored in the ThreadStore (also defined in [threads.h][threads.h]), which is a simple list of all known Thread objects. To enumerate all managed threads, one must first acquire the ThreadStoreLock, then use ThreadStore::GetAllThreadList to enumerate all Thread objects. This list may include managed threads which are not currently assigned to native threads (for example, they may not yet be started, or the native thread may already have exited). [threads.h]: ../../../../src/coreclr/vm/threads.h Each managed thread that is currently assigned to a native thread is reachable via a native thread-local storage (TLS) slot on that native thread. This allows code that is executing on that native thread to get the corresponding Thread object, via GetThread(). Additionally, many managed threads have a _managed_ Thread object (System.Threading.Thread) which is distinct from the native Thread object. The managed Thread object provides methods for managed code to interact with the thread, and is mostly a wrapper around functionality offered by the native Thread object. The current managed Thread object is reachable (from managed code) via Thread.CurrentThread. In a debugger, the SOS extension command "!Threads" can be used to enumerate all Thread objects in the ThreadStore. Thread Lifetimes ================ A managed thread is created in the following situations: 1. Managed code explicitly asks the CLR to create a new thread via System.Threading.Thread. 2. The CLR creates the managed thread directly (see ["special threads"](#special-threads) below). 3. Native code calls managed code on a native thread which is not yet associated with a managed thread (via "reverse p/invoke" or COM interop). 4. A managed process starts (invoking its Main method on the process' Main thread). In cases #1 and #2, the CLR is responsible for creating a native thread to back the managed thread. This is not done until the thread is actually _started_. In such cases, the native thread is "owned" by the CLR; the CLR is responsible for the native thread's lifetime. In these cases, the CLR is aware of the existence of the thread by virtue of the fact that the CLR created it in the first place. In cases #3 and #4, the native thread already existed prior to the creation of the managed thread, and is owned by code external to the CLR. The CLR is not responsible for the native thread's lifetime. The CLR becomes aware of these threads the first time they attempt to call managed code. When a native thread dies, the CLR is notified via its DllMain function. This happens inside of the OS "loader lock," so there is little that can be done (safely) while processing this notification. So rather than destroying the data structures associated with the managed thread, the thread is simply marked as "dead" and signals the finalizer thread to run. The finalizer thread then sweeps through the threads in the ThreadStore and destroys any that are both dead _and_ unreachable via managed code. Suspension ========== The CLR must be able to find all references to managed objects in order to perform a GC. Managed code is constantly accessing the GC heap, and manipulating references stored on the stack and in registers. The CLR must ensure that all managed threads are stopped (so they aren't modifying the heap) to safely and reliably find all managed objects. It only stops at _safe points_, when registers and stack locations can be inspected for live references. Another way of putting this is that the GC heap, and every thread's stack and register state, are "shared state," accessed by multiple threads. As with most shared state, some sort of "lock" is required to protect it. Managed code must hold this lock while accessing the heap, and can only release the lock at safe points. The CLR refers to this "lock" as the thread's "GC mode." A thread which is in "cooperative mode" holds its lock; it must "cooperate" with the GC (by releasing the lock) in order for a GC to proceed. A thread which is in "preemptive" mode does not hold its lock – the GC may proceed "preemptively" because the thread is known to not be accessing the GC heap. A GC may only proceed when all managed threads are in "preemptive" mode (not holding the lock). The process of moving all managed threads to preemptive mode is known as "GC suspension" or "suspending the Execution Engine (EE)." A naïve implementation of this "lock" would be for each managed thread to actually acquire and release a real lock around each access to the GC heap. Then the GC would simply attempt to acquire the lock on each thread; once it had acquired all threads' locks, it would be safe to perform the GC. However, this naïve approach is unsatisfactory for two reasons. First, it would require managed code to spend a lot of time acquiring and releasing the lock (or at least checking whether the GC was attempting to acquire the lock – known as "GC polling.") Second, it would require the JIT to emit "GC info" describing the layout of the stack and registers for every point in JIT'd code; this information would consume large amounts of memory. We refined this naïve approach by separating JIT'd managed code into "partially interruptible" and "fully interruptible" code. In partially interruptible code, the only safe points are calls to other methods, and explicit "GC poll" locations where the JIT emits code to check whether a GC is pending. GC info need only be emitted for these locations. In fully interruptible code, every instruction is a safe point, and the JIT emits GC info for every instruction – but it does not emit GC polls. Instead, fully interruptible code may be "interrupted" by hijacking the thread (a process which is discussed later in this document). The JIT chooses whether to emit fully- or partially-interruptible code based on heuristics to find the best tradeoff between code quality, size of the GC info, and GC suspension latency. Given the above, there are three fundamental operations to define: entering cooperative mode, leaving cooperative mode, and suspending the EE. Entering Cooperative Mode ------------------------- A thread enters cooperative mode by calling Thread::DisablePreemptiveGC. This acquires the "lock" for the current thread, as follows: 1. If a GC is in progress (the GC holds the lock) then block until the GC is complete. 2. Mark the thread as being in cooperative mode. No GC may proceed until the thread reenters preemptive mode. These two steps proceed as if they were atomic. Entering Preemptive Mode ------------------------ A thread enters preemptive mode (releases the lock) by calling Thread::EnablePreemptiveGC. This simply marks the thread as no longer being in cooperative mode, and informs the GC thread that it may be able to proceed. Suspending the EE ----------------- When a GC needs to occur, the first step is to suspend the EE. This is done by GCHeap::SuspendEE, which proceeds as follows: 1. Set a global flag (g\_fTrapReturningThreads) to indicate that a GC is in progress. Any threads that attempt to enter cooperative mode will block until the GC is complete. 2. Find all threads currently executing in cooperative mode. For each such thread, attempt to hijack the thread and force it to leave cooperative mode. 3. Repeat until no threads are running in cooperative mode. Hijacking --------- Hijacking for GC suspension is done by Thread::SysSuspendForGC. This method attempts to force any managed thread that is currently running in cooperative mode, to leave cooperative mode at a "safe point." It does this by enumerating all managed threads (walking the ThreadStore), and for each managed thread currently running in cooperative mode. 1. Suspend the underlying native thread. This is done with the Win32 SuspendThread API. This API forcibly stops the thread from running, at some random point in its execution (not necessarily a safe point). 2. Get the current CONTEXT for the thread, via GetThreadContext. This is an OS concept; CONTEXT represents the current register state of the thread. This allows us to inspect its instruction pointer, and thus determine what type of code it is currently executing. 3. Check again if the thread is in cooperative mode, as it may have already left cooperative mode before it could be suspended. If so, the thread is in dangerous territory: the thread may be executing arbitrary native code, and must be resumed immediately to avoid deadlocks. 4. Check if the thread is running managed code. It is possible that it is executing native VM code in cooperative mode (see Synchronization, below), in which case the thread must be immediately resumed as in the previous step. 5. Now the thread is suspended in managed code. Depending on whether that code is fully- or partially-interruptable, one of the following is performed: * If fully interruptable, it is safe to perform a GC at any point, since the thread is, by definition, at a safe point. It is reasonable to leave the thread suspended at this point (because it's safe) but various historical OS bugs prevent this from working, because the CONTEXT retrieved earlier may be corrupt). Instead, the thread's instruction pointer is overwritten, redirecting it to a stub that will capture a more complete CONTEXT, leave cooperative mode, wait for the GC to complete, reenter cooperative mode, and restore the thread to its previous state. * If partially-interruptable, the thread is, by definition, not at a safe point. However, the caller will be at a safe point (method transition). Using that knowledge, the CLR "hijacks" the top-most stack frame's return address (physically overwrite that location on the stack) with a stub similar to the one used for fully-interruptable code. When the method returns, it will no longer return to its actual caller, but rather to the stub (the method may also perform a GC poll, inserted by the JIT, before that point, which will cause it to leave cooperative mode and undo the hijack). ThreadAbort / AppDomain-Unload ============================== In order to unload an AppDomain, the CLR must ensure that no thread is running in that AppDomain. To accomplish this, all managed threads are enumerated, and "abort" any threads which have stack frames belonging to the AppDomain being unloaded. A ThreadAbortException is "injected" into the running thread, which causes the thread to unwind (executing backout code along the way) until it is no longer executing in the AppDomain, at which point the ThreadAbortException is translated into an AppDomainUnloaded exception. ThreadAbortException is a special type of exception. It can be caught by user code, but the CLR ensures that the exception will be rethrown after the user's exception handler is executed. Thus ThreadAbortException is sometimes referred to as "uncatchable," though this is not strictly true. A ThreadAbortException is typically 'thrown' by simply setting a bit on the managed thread marking it as "aborting." This bit is checked by various parts of the CLR (most notably, every return from a p/invoke) and often times setting this bit is all that is needed to get the thread aborted in a timely manner. However, if the thread is, for example, executing a long-running managed loop, it may never check this bit. To get such a thread to abort faster, the thread is "hijacked" and forced to raise a ThreadAbortException. This hijacking is done in the same way as GC suspension, except that the stubs that the thread is redirected to will cause a ThreadAbortException to be raised, rather than waiting for a GC to complete. This hijacking means that a ThreadAbortException can be raised at essentially any arbitrary point in managed code. This makes it extremely difficult for managed code to deal successfully with a ThreadAbortException. It is therefore unwise to use this mechanism for any purpose other than AppDomain-Unload, which ensures that any state corrupted by the ThreadAbort will be cleaned up along with the AppDomain. Synchronization: Managed ======================== Managed code has access to many synchronization primitives, collected within the System.Threading namespace. These include wrappers for native OS primitives like Mutex, Event, and Semaphore objects, as well as some abstractions such as Barriers and SpinLocks. However, the primary synchronization mechanism used by most managed code is System.Threading.Monitor, which provides a high-performance locking facility on _any managed object_, and additionally provides "condition variable" semantics for signaling changes in the state protected by a lock. Monitor is implemented as a "hybrid lock;" it has features of both a spin-lock and a kernel-based lock like a Mutex. The idea is that most locks are held only briefly, so it takes less time to simply spin-wait for the lock to be released, than it would to make a call into the kernel to block the thread. It is important not to waste CPU cycles spinning, so if the lock has not been acquired after a brief period of spinning, the implementation falls back to blocking in the kernel. Because any object may potentially be used as a lock/condition variable, every object must have a location in which to store the lock information. This is done with "object headers" and "sync blocks." The object header is a machine-word-sized field that precedes every managed object. It is used for many purposes, such as storing the object's hash code. One such purpose is holding the object's lock state. If more per-object data is needed than will fit in the object header, we "inflate" the object by creating a "sync block." Sync blocks are stored in the Sync Block Table, and are addressed by sync block indexes. Each object with an associated sync block has the index of that index in the object's object header. The details of object headers and sync blocks are defined in [syncblk.h][syncblk.h]/[.cpp][syncblk.cpp]. [syncblk.h]: ../../../../src/coreclr/vm/syncblk.h [syncblk.cpp]: ../../../../src/coreclr/vm/syncblk.cpp If there is room on the object header, Monitor stores the managed thread ID of the thread that currently holds the lock on the object (or zero (0) if no thread holds the lock). Acquiring the lock in this case is a simple matter of spin-waiting until the object header's thread ID is zero, and then atomically setting it to the current thread's managed thread ID. If the lock cannot be acquired in this manner after some number of spins, or the object header is already being used for other purposes, a sync block must be created for the object. This has additional data, including an event that can be used to block the current thread, allowing us to stop spinning and efficiently wait for the lock to be released. An object that is used as a condition variable (via Monitor.Wait and Monitor.Pulse) must always be inflated, as there is not enough room in the sync block to hold the required state. Synchronization: Native ======================= The native portion of the CLR must also be aware of threading, as it will be invoked by managed code on multiple threads. This requires native synchronization mechanisms, such as locks, events, etc. The ITaskHost API allows a host to override many aspects of managed threading, including thread creation, destruction, and synchronization. The ability of a host to override native synchronization means that VM code can generally not use native synchronization primitives (Critical Sections, Mutexes, Events, etc.) directly, but rather must use the VM's wrappers over these. Additionally, as described above, GC suspension is a special kind of "lock" that affects nearly every aspect of the CLR. Native code in the VM may enter "cooperative" mode if it must manipulate GC heap objects, and thus the "GC suspension lock" becomes one of the most important synchronization mechanisms in native VM code, as well as managed. The major synchronization mechanisms used in native VM code are the GC mode, and Crst. GC Mode ------- As discussed above, all managed code runs in cooperative mode, because it may manipulate the GC heap. Generally, native code does not touch managed objects, and thus runs in preemptive mode. But some native code in the VM must access the GC heap, and thus must run in cooperative mode. Native code generally does not manipulate the GC mode directly, but rather uses two macros: GCX\_COOP and GCX\_PREEMP. These enter the desired mode, and erect "holders" to cause the thread to revert to the previous mode when the scope is exited. It is important to understand that GCX\_COOP effectively acquires a lock on the GC heap. No GC may proceed while the thread is in cooperative mode. And native code cannot be "hijacked" as is done for managed code, so the thread will remain in cooperative mode until it explicitly switches back to preemptive mode. Thus entering cooperative mode in native code is discouraged. In cases where cooperative mode must be entered, it should be kept to as short a time as possible. The thread should not be blocked in this mode, and in particular cannot generally acquire locks safely. Similarly, GCX\_PREEMP potentially _releases_ a lock that had been held by the thread. Great care must be taken to ensure that all GC references are properly protected before entering preemptive mode. The [Rules of the Code](../../../coding-guidelines/clr-code-guide.md) document describes the disciplines needed to ensure safety around GC mode switches. Crst ---- Just as Monitor is the preferred locking mechanism for managed code, Crst is the preferred mechanism for VM code. Like Monitor, Crst is a hybrid lock that is aware of hosts and GC modes. Crst also implements deadlock avoidance via "lock leveling," described in the [Crst Leveling chapter of the BotR](../../../coding-guidelines/clr-code-guide.md#2.6.4). It is generally illegal to acquire a Crst while in cooperative mode, though exceptions are made where absolutely necessary. Special Threads =============== In addition to managing threads created by managed code, the CLR creates several "special" threads for its own use. Finalizer Thread ---------------- This thread is created in every process that runs managed code. When the GC determines that a finalizable object is no longer reachable, it places that object on a finalization queue. At the end of a GC, the finalizer thread is signaled to process all finalizers currently in this queue. Each object is then dequeued, one by one, and its finalizer is executed. This thread is also used to perform various CLR-internal housekeeping tasks, and to wait for notifications of some external events (such as a low-memory condition, which signals the GC to collect more aggressively). See GCHeap::FinalizerThreadStart for the details. GC Threads ---------- When running in "concurrent" or "server" modes, the GC creates one or more background threads to perform various stages of garbage collection in parallel. These threads are wholly owned and managed by the GC, and never run managed code. Debugger Thread --------------- The CLR maintains a single native thread in each managed process, which performs various tasks on behalf of attached managed debuggers. AppDomain-Unload Thread ----------------------- This thread is responsible for unloading AppDomains. This is done on a separate, CLR-internal thread, rather than the thread that requests the AD-unload, to a) provide guaranteed stack space for the unload logic, and b) allow the thread that requested the unload to be unwound out of the AD, if needed. ThreadPool Threads ------------------ The CLR's ThreadPool maintains a collection of managed threads for executing user "work items." These managed threads are bound to native threads owned by the ThreadPool. The ThreadPool also maintains a small number of native threads to handle functions like "thread injection," timers, and "registered waits."
CLR Threading Overview ====================== Managed vs. Native Threads ========================== Managed code executes on "managed threads," which are distinct from the native threads provided by the operating system. A native thread is a thread of execution of native code on a physical machine; a managed thread is a virtual thread of execution on the CLR's virtual machine. Just as the JIT compiler maps "virtual" IL instructions into native instructions that execute on the physical machine, the CLR's threading infrastructure maps "virtual" managed threads onto the native threads provided by the operating system. At any given time, a managed thread may or may not be assigned to a native thread for execution. For example, a managed thread that has been created (via "new System.Threading.Thread") but not yet started (via System.Threading.Thread.Start) is a managed thread that has not yet been assigned to a native thread. Similarly, a managed thread may, in principle, move between multiple native threads over the course of its execution, though in practice the CLR does not currently support this. The public Thread interface available to managed code intentionally hides the details of the underlying native threads. because: - Managed threads are not necessarily mapped to a single native thread (and may not be mapped to a native thread at all). - Different operating systems expose different abstractions for native threads. - In principle, managed threads are "virtualized". The CLR provides equivalent abstractions for managed threads, implemented by the CLR itself. For example, it does not expose the operating system's thread-local storage (TLS) mechanism, but instead provides managed "thread-static" variables. Similarly, it does not expose the native thread's "thread ID," but instead provides a "managed thread ID" which is generated independently of the OS. However, for diagnostic purposes, some details of the underlying native thread may be obtained via types in the System.Diagnostics namespace. Managed threads require additional functionality typically not needed by native threads. First, managed threads hold GC references on their stacks, so the CLR must be able to enumerate (and possibly modify) these references every time a GC occurs. To do this, the CLR must "suspend" each managed thread (stop it at a point where all of its GC references can be found). Second, when an AppDomain is unloaded, the CLR must ensure that no thread is executing code in that AppDomain. This requires the ability to force a thread to unwind out of that AppDomain. The CLR does this by injecting a ThreadAbortException into such threads. Data Structures =============== Every managed thread has an associated Thread object, defined in [threads.h][threads.h]. This object tracks everything the VM needs to know about the managed thread. This includes things that are _necessary_, such as the thread's current GC mode and Frame chain, as well as many things that are allocated per-thread simply for performance reasons (such as some fast arena-style allocators). All Thread objects are stored in the ThreadStore (also defined in [threads.h][threads.h]), which is a simple list of all known Thread objects. To enumerate all managed threads, one must first acquire the ThreadStoreLock, then use ThreadStore::GetAllThreadList to enumerate all Thread objects. This list may include managed threads which are not currently assigned to native threads (for example, they may not yet be started, or the native thread may already have exited). [threads.h]: ../../../../src/coreclr/vm/threads.h Each managed thread that is currently assigned to a native thread is reachable via a native thread-local storage (TLS) slot on that native thread. This allows code that is executing on that native thread to get the corresponding Thread object, via GetThread(). Additionally, many managed threads have a _managed_ Thread object (System.Threading.Thread) which is distinct from the native Thread object. The managed Thread object provides methods for managed code to interact with the thread, and is mostly a wrapper around functionality offered by the native Thread object. The current managed Thread object is reachable (from managed code) via Thread.CurrentThread. In a debugger, the SOS extension command "!Threads" can be used to enumerate all Thread objects in the ThreadStore. Thread Lifetimes ================ A managed thread is created in the following situations: 1. Managed code explicitly asks the CLR to create a new thread via System.Threading.Thread. 2. The CLR creates the managed thread directly (see ["special threads"](#special-threads) below). 3. Native code calls managed code on a native thread which is not yet associated with a managed thread (via "reverse p/invoke" or COM interop). 4. A managed process starts (invoking its Main method on the process' Main thread). In cases #1 and #2, the CLR is responsible for creating a native thread to back the managed thread. This is not done until the thread is actually _started_. In such cases, the native thread is "owned" by the CLR; the CLR is responsible for the native thread's lifetime. In these cases, the CLR is aware of the existence of the thread by virtue of the fact that the CLR created it in the first place. In cases #3 and #4, the native thread already existed prior to the creation of the managed thread, and is owned by code external to the CLR. The CLR is not responsible for the native thread's lifetime. The CLR becomes aware of these threads the first time they attempt to call managed code. When a native thread dies, the CLR is notified via its DllMain function. This happens inside of the OS "loader lock," so there is little that can be done (safely) while processing this notification. So rather than destroying the data structures associated with the managed thread, the thread is simply marked as "dead" and signals the finalizer thread to run. The finalizer thread then sweeps through the threads in the ThreadStore and destroys any that are both dead _and_ unreachable via managed code. Suspension ========== The CLR must be able to find all references to managed objects in order to perform a GC. Managed code is constantly accessing the GC heap, and manipulating references stored on the stack and in registers. The CLR must ensure that all managed threads are stopped (so they aren't modifying the heap) to safely and reliably find all managed objects. It only stops at _safe points_, when registers and stack locations can be inspected for live references. Another way of putting this is that the GC heap, and every thread's stack and register state, are "shared state," accessed by multiple threads. As with most shared state, some sort of "lock" is required to protect it. Managed code must hold this lock while accessing the heap, and can only release the lock at safe points. The CLR refers to this "lock" as the thread's "GC mode." A thread which is in "cooperative mode" holds its lock; it must "cooperate" with the GC (by releasing the lock) in order for a GC to proceed. A thread which is in "preemptive" mode does not hold its lock – the GC may proceed "preemptively" because the thread is known to not be accessing the GC heap. A GC may only proceed when all managed threads are in "preemptive" mode (not holding the lock). The process of moving all managed threads to preemptive mode is known as "GC suspension" or "suspending the Execution Engine (EE)." A naïve implementation of this "lock" would be for each managed thread to actually acquire and release a real lock around each access to the GC heap. Then the GC would simply attempt to acquire the lock on each thread; once it had acquired all threads' locks, it would be safe to perform the GC. However, this naïve approach is unsatisfactory for two reasons. First, it would require managed code to spend a lot of time acquiring and releasing the lock (or at least checking whether the GC was attempting to acquire the lock – known as "GC polling.") Second, it would require the JIT to emit "GC info" describing the layout of the stack and registers for every point in JIT'd code; this information would consume large amounts of memory. We refined this naïve approach by separating JIT'd managed code into "partially interruptible" and "fully interruptible" code. In partially interruptible code, the only safe points are calls to other methods, and explicit "GC poll" locations where the JIT emits code to check whether a GC is pending. GC info need only be emitted for these locations. In fully interruptible code, every instruction is a safe point, and the JIT emits GC info for every instruction – but it does not emit GC polls. Instead, fully interruptible code may be "interrupted" by hijacking the thread (a process which is discussed later in this document). The JIT chooses whether to emit fully- or partially-interruptible code based on heuristics to find the best tradeoff between code quality, size of the GC info, and GC suspension latency. Given the above, there are three fundamental operations to define: entering cooperative mode, leaving cooperative mode, and suspending the EE. Entering Cooperative Mode ------------------------- A thread enters cooperative mode by calling Thread::DisablePreemptiveGC. This acquires the "lock" for the current thread, as follows: 1. If a GC is in progress (the GC holds the lock) then block until the GC is complete. 2. Mark the thread as being in cooperative mode. No GC may proceed until the thread reenters preemptive mode. These two steps proceed as if they were atomic. Entering Preemptive Mode ------------------------ A thread enters preemptive mode (releases the lock) by calling Thread::EnablePreemptiveGC. This simply marks the thread as no longer being in cooperative mode, and informs the GC thread that it may be able to proceed. Suspending the EE ----------------- When a GC needs to occur, the first step is to suspend the EE. This is done by GCHeap::SuspendEE, which proceeds as follows: 1. Set a global flag (g\_fTrapReturningThreads) to indicate that a GC is in progress. Any threads that attempt to enter cooperative mode will block until the GC is complete. 2. Find all threads currently executing in cooperative mode. For each such thread, attempt to hijack the thread and force it to leave cooperative mode. 3. Repeat until no threads are running in cooperative mode. Hijacking --------- Hijacking for GC suspension is done by Thread::SysSuspendForGC. This method attempts to force any managed thread that is currently running in cooperative mode, to leave cooperative mode at a "safe point." It does this by enumerating all managed threads (walking the ThreadStore), and for each managed thread currently running in cooperative mode. 1. Suspend the underlying native thread. This is done with the Win32 SuspendThread API. This API forcibly stops the thread from running, at some random point in its execution (not necessarily a safe point). 2. Get the current CONTEXT for the thread, via GetThreadContext. This is an OS concept; CONTEXT represents the current register state of the thread. This allows us to inspect its instruction pointer, and thus determine what type of code it is currently executing. 3. Check again if the thread is in cooperative mode, as it may have already left cooperative mode before it could be suspended. If so, the thread is in dangerous territory: the thread may be executing arbitrary native code, and must be resumed immediately to avoid deadlocks. 4. Check if the thread is running managed code. It is possible that it is executing native VM code in cooperative mode (see Synchronization, below), in which case the thread must be immediately resumed as in the previous step. 5. Now the thread is suspended in managed code. Depending on whether that code is fully- or partially-interruptable, one of the following is performed: * If fully interruptable, it is safe to perform a GC at any point, since the thread is, by definition, at a safe point. It is reasonable to leave the thread suspended at this point (because it's safe) but various historical OS bugs prevent this from working, because the CONTEXT retrieved earlier may be corrupt). Instead, the thread's instruction pointer is overwritten, redirecting it to a stub that will capture a more complete CONTEXT, leave cooperative mode, wait for the GC to complete, reenter cooperative mode, and restore the thread to its previous state. * If partially-interruptable, the thread is, by definition, not at a safe point. However, the caller will be at a safe point (method transition). Using that knowledge, the CLR "hijacks" the top-most stack frame's return address (physically overwrite that location on the stack) with a stub similar to the one used for fully-interruptable code. When the method returns, it will no longer return to its actual caller, but rather to the stub (the method may also perform a GC poll, inserted by the JIT, before that point, which will cause it to leave cooperative mode and undo the hijack). ThreadAbort / AppDomain-Unload ============================== In order to unload an AppDomain, the CLR must ensure that no thread is running in that AppDomain. To accomplish this, all managed threads are enumerated, and "abort" any threads which have stack frames belonging to the AppDomain being unloaded. A ThreadAbortException is "injected" into the running thread, which causes the thread to unwind (executing backout code along the way) until it is no longer executing in the AppDomain, at which point the ThreadAbortException is translated into an AppDomainUnloaded exception. ThreadAbortException is a special type of exception. It can be caught by user code, but the CLR ensures that the exception will be rethrown after the user's exception handler is executed. Thus ThreadAbortException is sometimes referred to as "uncatchable," though this is not strictly true. A ThreadAbortException is typically 'thrown' by simply setting a bit on the managed thread marking it as "aborting." This bit is checked by various parts of the CLR (most notably, every return from a p/invoke) and often times setting this bit is all that is needed to get the thread aborted in a timely manner. However, if the thread is, for example, executing a long-running managed loop, it may never check this bit. To get such a thread to abort faster, the thread is "hijacked" and forced to raise a ThreadAbortException. This hijacking is done in the same way as GC suspension, except that the stubs that the thread is redirected to will cause a ThreadAbortException to be raised, rather than waiting for a GC to complete. This hijacking means that a ThreadAbortException can be raised at essentially any arbitrary point in managed code. This makes it extremely difficult for managed code to deal successfully with a ThreadAbortException. It is therefore unwise to use this mechanism for any purpose other than AppDomain-Unload, which ensures that any state corrupted by the ThreadAbort will be cleaned up along with the AppDomain. Synchronization: Managed ======================== Managed code has access to many synchronization primitives, collected within the System.Threading namespace. These include wrappers for native OS primitives like Mutex, Event, and Semaphore objects, as well as some abstractions such as Barriers and SpinLocks. However, the primary synchronization mechanism used by most managed code is System.Threading.Monitor, which provides a high-performance locking facility on _any managed object_, and additionally provides "condition variable" semantics for signaling changes in the state protected by a lock. Monitor is implemented as a "hybrid lock;" it has features of both a spin-lock and a kernel-based lock like a Mutex. The idea is that most locks are held only briefly, so it takes less time to simply spin-wait for the lock to be released, than it would to make a call into the kernel to block the thread. It is important not to waste CPU cycles spinning, so if the lock has not been acquired after a brief period of spinning, the implementation falls back to blocking in the kernel. Because any object may potentially be used as a lock/condition variable, every object must have a location in which to store the lock information. This is done with "object headers" and "sync blocks." The object header is a machine-word-sized field that precedes every managed object. It is used for many purposes, such as storing the object's hash code. One such purpose is holding the object's lock state. If more per-object data is needed than will fit in the object header, we "inflate" the object by creating a "sync block." Sync blocks are stored in the Sync Block Table, and are addressed by sync block indexes. Each object with an associated sync block has the index of that index in the object's object header. The details of object headers and sync blocks are defined in [syncblk.h][syncblk.h]/[.cpp][syncblk.cpp]. [syncblk.h]: ../../../../src/coreclr/vm/syncblk.h [syncblk.cpp]: ../../../../src/coreclr/vm/syncblk.cpp If there is room on the object header, Monitor stores the managed thread ID of the thread that currently holds the lock on the object (or zero (0) if no thread holds the lock). Acquiring the lock in this case is a simple matter of spin-waiting until the object header's thread ID is zero, and then atomically setting it to the current thread's managed thread ID. If the lock cannot be acquired in this manner after some number of spins, or the object header is already being used for other purposes, a sync block must be created for the object. This has additional data, including an event that can be used to block the current thread, allowing us to stop spinning and efficiently wait for the lock to be released. An object that is used as a condition variable (via Monitor.Wait and Monitor.Pulse) must always be inflated, as there is not enough room in the sync block to hold the required state. Synchronization: Native ======================= The native portion of the CLR must also be aware of threading, as it will be invoked by managed code on multiple threads. This requires native synchronization mechanisms, such as locks, events, etc. The ITaskHost API allows a host to override many aspects of managed threading, including thread creation, destruction, and synchronization. The ability of a host to override native synchronization means that VM code can generally not use native synchronization primitives (Critical Sections, Mutexes, Events, etc.) directly, but rather must use the VM's wrappers over these. Additionally, as described above, GC suspension is a special kind of "lock" that affects nearly every aspect of the CLR. Native code in the VM may enter "cooperative" mode if it must manipulate GC heap objects, and thus the "GC suspension lock" becomes one of the most important synchronization mechanisms in native VM code, as well as managed. The major synchronization mechanisms used in native VM code are the GC mode, and Crst. GC Mode ------- As discussed above, all managed code runs in cooperative mode, because it may manipulate the GC heap. Generally, native code does not touch managed objects, and thus runs in preemptive mode. But some native code in the VM must access the GC heap, and thus must run in cooperative mode. Native code generally does not manipulate the GC mode directly, but rather uses two macros: GCX\_COOP and GCX\_PREEMP. These enter the desired mode, and erect "holders" to cause the thread to revert to the previous mode when the scope is exited. It is important to understand that GCX\_COOP effectively acquires a lock on the GC heap. No GC may proceed while the thread is in cooperative mode. And native code cannot be "hijacked" as is done for managed code, so the thread will remain in cooperative mode until it explicitly switches back to preemptive mode. Thus entering cooperative mode in native code is discouraged. In cases where cooperative mode must be entered, it should be kept to as short a time as possible. The thread should not be blocked in this mode, and in particular cannot generally acquire locks safely. Similarly, GCX\_PREEMP potentially _releases_ a lock that had been held by the thread. Great care must be taken to ensure that all GC references are properly protected before entering preemptive mode. The [Rules of the Code](../../../coding-guidelines/clr-code-guide.md) document describes the disciplines needed to ensure safety around GC mode switches. Crst ---- Just as Monitor is the preferred locking mechanism for managed code, Crst is the preferred mechanism for VM code. Like Monitor, Crst is a hybrid lock that is aware of hosts and GC modes. Crst also implements deadlock avoidance via "lock leveling," described in the [Crst Leveling chapter of the BotR](../../../coding-guidelines/clr-code-guide.md#2.6.4). It is generally illegal to acquire a Crst while in cooperative mode, though exceptions are made where absolutely necessary. Special Threads =============== In addition to managing threads created by managed code, the CLR creates several "special" threads for its own use. Finalizer Thread ---------------- This thread is created in every process that runs managed code. When the GC determines that a finalizable object is no longer reachable, it places that object on a finalization queue. At the end of a GC, the finalizer thread is signaled to process all finalizers currently in this queue. Each object is then dequeued, one by one, and its finalizer is executed. This thread is also used to perform various CLR-internal housekeeping tasks, and to wait for notifications of some external events (such as a low-memory condition, which signals the GC to collect more aggressively). See GCHeap::FinalizerThreadStart for the details. GC Threads ---------- When running in "concurrent" or "server" modes, the GC creates one or more background threads to perform various stages of garbage collection in parallel. These threads are wholly owned and managed by the GC, and never run managed code. Debugger Thread --------------- The CLR maintains a single native thread in each managed process, which performs various tasks on behalf of attached managed debuggers. AppDomain-Unload Thread ----------------------- This thread is responsible for unloading AppDomains. This is done on a separate, CLR-internal thread, rather than the thread that requests the AD-unload, to a) provide guaranteed stack space for the unload logic, and b) allow the thread that requested the unload to be unwound out of the AD, if needed. ThreadPool Threads ------------------ The CLR's ThreadPool maintains a collection of managed threads for executing user "work items." These managed threads are bound to native threads owned by the ThreadPool. The ThreadPool also maintains a small number of native threads to handle functions like "thread injection," timers, and "registered waits."
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/libraries/System.IO.Compression.ZipFile/System.IO.Compression.ZipFile.sln
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{0869556F-E34F-4284-B985-CB6D3B6AD954}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.ZipFile", "ref\System.IO.Compression.ZipFile.csproj", "{E91931AD-977E-4608-9F40-997163322D8B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.ZipFile", "src\System.IO.Compression.ZipFile.csproj", "{A3C36A2F-2586-43DF-B39C-A9D14DF8524E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.ZipFile.Tests", "tests\System.IO.Compression.ZipFile.Tests.csproj", "{D5A89FC9-7913-4F80-BA16-6587EB6140E3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{AE18A377-AAE7-488B-A873-8463A2706BC0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5DC533A5-D0F0-488B-81C2-7AD7546528DD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A46DB030-84B9-49C0-8F75-98FE1290EF88}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A8BAE96C-3EAD-4E68-BBB0-A4854F386CC4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5C592E59-B3F3-4743-BC80-F5C799B16B74}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{82C30050-0689-4C48-AA32-E7137F0417DC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0869556F-E34F-4284-B985-CB6D3B6AD954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0869556F-E34F-4284-B985-CB6D3B6AD954}.Debug|Any CPU.Build.0 = Debug|Any CPU {0869556F-E34F-4284-B985-CB6D3B6AD954}.Release|Any CPU.ActiveCfg = Release|Any CPU {0869556F-E34F-4284-B985-CB6D3B6AD954}.Release|Any CPU.Build.0 = Release|Any CPU {E91931AD-977E-4608-9F40-997163322D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E91931AD-977E-4608-9F40-997163322D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU {E91931AD-977E-4608-9F40-997163322D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU {E91931AD-977E-4608-9F40-997163322D8B}.Release|Any CPU.Build.0 = Release|Any CPU {A3C36A2F-2586-43DF-B39C-A9D14DF8524E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A3C36A2F-2586-43DF-B39C-A9D14DF8524E}.Debug|Any CPU.Build.0 = Debug|Any CPU {A3C36A2F-2586-43DF-B39C-A9D14DF8524E}.Release|Any CPU.ActiveCfg = Release|Any CPU {A3C36A2F-2586-43DF-B39C-A9D14DF8524E}.Release|Any CPU.Build.0 = Release|Any CPU {D5A89FC9-7913-4F80-BA16-6587EB6140E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D5A89FC9-7913-4F80-BA16-6587EB6140E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5A89FC9-7913-4F80-BA16-6587EB6140E3}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5A89FC9-7913-4F80-BA16-6587EB6140E3}.Release|Any CPU.Build.0 = Release|Any CPU {AE18A377-AAE7-488B-A873-8463A2706BC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AE18A377-AAE7-488B-A873-8463A2706BC0}.Debug|Any CPU.Build.0 = Debug|Any CPU {AE18A377-AAE7-488B-A873-8463A2706BC0}.Release|Any CPU.ActiveCfg = Release|Any CPU {AE18A377-AAE7-488B-A873-8463A2706BC0}.Release|Any CPU.Build.0 = Release|Any CPU {5DC533A5-D0F0-488B-81C2-7AD7546528DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5DC533A5-D0F0-488B-81C2-7AD7546528DD}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DC533A5-D0F0-488B-81C2-7AD7546528DD}.Release|Any CPU.ActiveCfg = Release|Any CPU {5DC533A5-D0F0-488B-81C2-7AD7546528DD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {0869556F-E34F-4284-B985-CB6D3B6AD954} = {A46DB030-84B9-49C0-8F75-98FE1290EF88} {D5A89FC9-7913-4F80-BA16-6587EB6140E3} = {A46DB030-84B9-49C0-8F75-98FE1290EF88} {E91931AD-977E-4608-9F40-997163322D8B} = {A8BAE96C-3EAD-4E68-BBB0-A4854F386CC4} {A3C36A2F-2586-43DF-B39C-A9D14DF8524E} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} {AE18A377-AAE7-488B-A873-8463A2706BC0} = {82C30050-0689-4C48-AA32-E7137F0417DC} {5DC533A5-D0F0-488B-81C2-7AD7546528DD} = {82C30050-0689-4C48-AA32-E7137F0417DC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D2E26432-A647-4E61-9A30-DE6C62BBD632} EndGlobalSection EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{0869556F-E34F-4284-B985-CB6D3B6AD954}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.ZipFile", "ref\System.IO.Compression.ZipFile.csproj", "{E91931AD-977E-4608-9F40-997163322D8B}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.ZipFile", "src\System.IO.Compression.ZipFile.csproj", "{A3C36A2F-2586-43DF-B39C-A9D14DF8524E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Compression.ZipFile.Tests", "tests\System.IO.Compression.ZipFile.Tests.csproj", "{D5A89FC9-7913-4F80-BA16-6587EB6140E3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{AE18A377-AAE7-488B-A873-8463A2706BC0}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{5DC533A5-D0F0-488B-81C2-7AD7546528DD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A46DB030-84B9-49C0-8F75-98FE1290EF88}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{A8BAE96C-3EAD-4E68-BBB0-A4854F386CC4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5C592E59-B3F3-4743-BC80-F5C799B16B74}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{82C30050-0689-4C48-AA32-E7137F0417DC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0869556F-E34F-4284-B985-CB6D3B6AD954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0869556F-E34F-4284-B985-CB6D3B6AD954}.Debug|Any CPU.Build.0 = Debug|Any CPU {0869556F-E34F-4284-B985-CB6D3B6AD954}.Release|Any CPU.ActiveCfg = Release|Any CPU {0869556F-E34F-4284-B985-CB6D3B6AD954}.Release|Any CPU.Build.0 = Release|Any CPU {E91931AD-977E-4608-9F40-997163322D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E91931AD-977E-4608-9F40-997163322D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU {E91931AD-977E-4608-9F40-997163322D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU {E91931AD-977E-4608-9F40-997163322D8B}.Release|Any CPU.Build.0 = Release|Any CPU {A3C36A2F-2586-43DF-B39C-A9D14DF8524E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A3C36A2F-2586-43DF-B39C-A9D14DF8524E}.Debug|Any CPU.Build.0 = Debug|Any CPU {A3C36A2F-2586-43DF-B39C-A9D14DF8524E}.Release|Any CPU.ActiveCfg = Release|Any CPU {A3C36A2F-2586-43DF-B39C-A9D14DF8524E}.Release|Any CPU.Build.0 = Release|Any CPU {D5A89FC9-7913-4F80-BA16-6587EB6140E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D5A89FC9-7913-4F80-BA16-6587EB6140E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5A89FC9-7913-4F80-BA16-6587EB6140E3}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5A89FC9-7913-4F80-BA16-6587EB6140E3}.Release|Any CPU.Build.0 = Release|Any CPU {AE18A377-AAE7-488B-A873-8463A2706BC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AE18A377-AAE7-488B-A873-8463A2706BC0}.Debug|Any CPU.Build.0 = Debug|Any CPU {AE18A377-AAE7-488B-A873-8463A2706BC0}.Release|Any CPU.ActiveCfg = Release|Any CPU {AE18A377-AAE7-488B-A873-8463A2706BC0}.Release|Any CPU.Build.0 = Release|Any CPU {5DC533A5-D0F0-488B-81C2-7AD7546528DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5DC533A5-D0F0-488B-81C2-7AD7546528DD}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DC533A5-D0F0-488B-81C2-7AD7546528DD}.Release|Any CPU.ActiveCfg = Release|Any CPU {5DC533A5-D0F0-488B-81C2-7AD7546528DD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {0869556F-E34F-4284-B985-CB6D3B6AD954} = {A46DB030-84B9-49C0-8F75-98FE1290EF88} {D5A89FC9-7913-4F80-BA16-6587EB6140E3} = {A46DB030-84B9-49C0-8F75-98FE1290EF88} {E91931AD-977E-4608-9F40-997163322D8B} = {A8BAE96C-3EAD-4E68-BBB0-A4854F386CC4} {A3C36A2F-2586-43DF-B39C-A9D14DF8524E} = {5C592E59-B3F3-4743-BC80-F5C799B16B74} {AE18A377-AAE7-488B-A873-8463A2706BC0} = {82C30050-0689-4C48-AA32-E7137F0417DC} {5DC533A5-D0F0-488B-81C2-7AD7546528DD} = {82C30050-0689-4C48-AA32-E7137F0417DC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D2E26432-A647-4E61-9A30-DE6C62BBD632} EndGlobalSection EndGlobal
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/JIT/HardwareIntrinsics/General/Vector128/Sqrt.Int64.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void SqrtInt64() { var test = new VectorUnaryOpTest__SqrtInt64(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorUnaryOpTest__SqrtInt64 { private struct DataTable { private byte[] inArray1; private byte[] outArray; private GCHandle inHandle1; private GCHandle outHandle; private ulong alignment; public DataTable(Int64[] inArray1, Int64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int64> _fld1; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); return testStruct; } public void RunStructFldScenario(VectorUnaryOpTest__SqrtInt64 testClass) { var result = Vector128.Sqrt(_fld1); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static Int64[] _data1 = new Int64[Op1ElementCount]; private static Vector128<Int64> _clsVar1; private Vector128<Int64> _fld1; private DataTable _dataTable; static VectorUnaryOpTest__SqrtInt64() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); } public VectorUnaryOpTest__SqrtInt64() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } _dataTable = new DataTable(_data1, new Int64[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector128.Sqrt( Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector128).GetMethod(nameof(Vector128.Sqrt), new Type[] { typeof(Vector128<Int64>) }); if (method is null) { method = typeof(Vector128).GetMethod(nameof(Vector128.Sqrt), 1, new Type[] { typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Int64)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector128.Sqrt( _clsVar1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr); var result = Vector128.Sqrt(op1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorUnaryOpTest__SqrtInt64(); var result = Vector128.Sqrt(test._fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector128.Sqrt(_fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector128.Sqrt(test._fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector128<Int64> op1, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); ValidateResult(inArray1, outArray, method); } private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); ValidateResult(inArray1, outArray, method); } private void ValidateResult(Int64[] firstOp, Int64[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != (long)(Math.Sqrt(firstOp[0]))) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != (long)(Math.Sqrt(firstOp[i]))) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector128)}.{nameof(Vector128.Sqrt)}<Int64>(Vector128<Int64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void SqrtInt64() { var test = new VectorUnaryOpTest__SqrtInt64(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorUnaryOpTest__SqrtInt64 { private struct DataTable { private byte[] inArray1; private byte[] outArray; private GCHandle inHandle1; private GCHandle outHandle; private ulong alignment; public DataTable(Int64[] inArray1, Int64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Int64> _fld1; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); return testStruct; } public void RunStructFldScenario(VectorUnaryOpTest__SqrtInt64 testClass) { var result = Vector128.Sqrt(_fld1); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static Int64[] _data1 = new Int64[Op1ElementCount]; private static Vector128<Int64> _clsVar1; private Vector128<Int64> _fld1; private DataTable _dataTable; static VectorUnaryOpTest__SqrtInt64() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); } public VectorUnaryOpTest__SqrtInt64() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } _dataTable = new DataTable(_data1, new Int64[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector128.Sqrt( Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector128).GetMethod(nameof(Vector128.Sqrt), new Type[] { typeof(Vector128<Int64>) }); if (method is null) { method = typeof(Vector128).GetMethod(nameof(Vector128.Sqrt), 1, new Type[] { typeof(Vector128<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Int64)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector128.Sqrt( _clsVar1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr); var result = Vector128.Sqrt(op1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorUnaryOpTest__SqrtInt64(); var result = Vector128.Sqrt(test._fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector128.Sqrt(_fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector128.Sqrt(test._fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector128<Int64> op1, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); ValidateResult(inArray1, outArray, method); } private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); ValidateResult(inArray1, outArray, method); } private void ValidateResult(Int64[] firstOp, Int64[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != (long)(Math.Sqrt(firstOp[0]))) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != (long)(Math.Sqrt(firstOp[i]))) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector128)}.{nameof(Vector128.Sqrt)}<Int64>(Vector128<Int64>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest747/Generated747.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated747.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated747.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tests/GC/Features/Finalizer/finalizeother/finalizenested.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Tests Nested Finalize() using System; using System.Threading; using System.Runtime.CompilerServices; public class Test_finalizenested { public class D { ~D() { Console.WriteLine("In Finalize() of D"); Thread.Sleep(1000); } } public class C { public D d; public C() { d = new D(); } ~C() { Console.WriteLine("In Finalize() of C"); d=null; Thread.Sleep(1000); } } public class B { public C c; public B() { c = new C(); } ~B() { Console.WriteLine("In Finalize() of B"); c=null; Thread.Sleep(1000); } } public class A { public B b; public A() { b = new B(); } ~A() { Console.WriteLine("In Finalize() of A"); b=null; Thread.Sleep(1000); } } public class Dummy { public A a; public static bool visited; public Dummy() { a = new A(); } ~Dummy() { Console.WriteLine("In Finalize() of Dummy"); a=null; visited=true; } } public class CreateObj { // disabling unused variable warning #pragma warning disable 0414 Dummy obj; #pragma warning restore 0414 public CreateObj() { obj=new Dummy(); } public void RunTest() { obj=null; } } [MethodImpl(MethodImplOptions.NoInlining)] public static void AllocAndDealloc() { CreateObj temp = new CreateObj(); temp.RunTest(); } public static int Main() { AllocAndDealloc(); GC.Collect(); GC.WaitForPendingFinalizers(); // makes sure Finalize() is called. GC.Collect(); if (Dummy.visited) { Console.WriteLine("Test Passed"); return 100; } Console.WriteLine("Test Failed"); return 1; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Tests Nested Finalize() using System; using System.Threading; using System.Runtime.CompilerServices; public class Test_finalizenested { public class D { ~D() { Console.WriteLine("In Finalize() of D"); Thread.Sleep(1000); } } public class C { public D d; public C() { d = new D(); } ~C() { Console.WriteLine("In Finalize() of C"); d=null; Thread.Sleep(1000); } } public class B { public C c; public B() { c = new C(); } ~B() { Console.WriteLine("In Finalize() of B"); c=null; Thread.Sleep(1000); } } public class A { public B b; public A() { b = new B(); } ~A() { Console.WriteLine("In Finalize() of A"); b=null; Thread.Sleep(1000); } } public class Dummy { public A a; public static bool visited; public Dummy() { a = new A(); } ~Dummy() { Console.WriteLine("In Finalize() of Dummy"); a=null; visited=true; } } public class CreateObj { // disabling unused variable warning #pragma warning disable 0414 Dummy obj; #pragma warning restore 0414 public CreateObj() { obj=new Dummy(); } public void RunTest() { obj=null; } } [MethodImpl(MethodImplOptions.NoInlining)] public static void AllocAndDealloc() { CreateObj temp = new CreateObj(); temp.RunTest(); } public static int Main() { AllocAndDealloc(); GC.Collect(); GC.WaitForPendingFinalizers(); // makes sure Finalize() is called. GC.Collect(); if (Dummy.visited) { Console.WriteLine("Test Passed"); return 100; } Console.WriteLine("Test Failed"); return 1; } }
-1
dotnet/runtime
66,292
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete
Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
rzikm
2022-03-07T12:54:44Z
2022-03-08T17:44:17Z
627851323fe8f15539c163aabd7d7c644766c549
00ed84ae9ba5c68ada6041ca4aa8083cc89e0669
Mark EncryptionPolicy.NoEncryption and EncryptionPolicy.AllowNoEncryption as obsolete. Fixes #65545 I don't think the current wording of the warning message is appropriate, but I could not come up with anything better for now. Suggestions welcome.
./src/tasks/MonoTargetsTasks/ILStrip/AssemblyStripper/AssemblyStripper.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>$(TargetFrameworkForNETCoreTasks);$(TargetFrameworkForNETFrameworkTasks)</TargetFrameworks> <EnableDefaultCompileItems>false</EnableDefaultCompileItems> <!-- CilStrip.Sources doesn't play nicely with nullability --> <Nullable>disable</Nullable> <!-- SYSLIB0003: Mono.Cecil uses Code Access Security types CS0618: Mono.Cecil uses a number of other obsolete types CS0649: Mono.Cecil.Binary.ExportTable has some unused fields --> <NoWarn>$(NoWarn),CS0618,CS0649,SYSLIB0003</NoWarn> <!-- the analyzers don't like Mono.Cecil either --> <RunAnalyzers>false</RunAnalyzers> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.DotNet.CilStrip.Sources" Version="$(MicrosoftDotNetCilStripSourcesVersion)" /> </ItemGroup> <ItemGroup> <Compile Include="AssemblyStripper.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>$(TargetFrameworkForNETCoreTasks);$(TargetFrameworkForNETFrameworkTasks)</TargetFrameworks> <EnableDefaultCompileItems>false</EnableDefaultCompileItems> <!-- CilStrip.Sources doesn't play nicely with nullability --> <Nullable>disable</Nullable> <!-- SYSLIB0003: Mono.Cecil uses Code Access Security types CS0618: Mono.Cecil uses a number of other obsolete types CS0649: Mono.Cecil.Binary.ExportTable has some unused fields --> <NoWarn>$(NoWarn),CS0618,CS0649,SYSLIB0003</NoWarn> <!-- the analyzers don't like Mono.Cecil either --> <RunAnalyzers>false</RunAnalyzers> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.DotNet.CilStrip.Sources" Version="$(MicrosoftDotNetCilStripSourcesVersion)" /> </ItemGroup> <ItemGroup> <Compile Include="AssemblyStripper.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableMethodNode.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; namespace ILCompiler.DependencyAnalysis { /// <summary> /// Represents a method that is visible to reflection. /// </summary> public class ReflectableMethodNode : DependencyNodeCore<NodeFactory> { private readonly MethodDesc _method; public ReflectableMethodNode(MethodDesc method) { Debug.Assert(!method.IsCanonicalMethod(CanonicalFormKind.Any) || method.GetCanonMethodTarget(CanonicalFormKind.Specific) == method); _method = method; } public MethodDesc Method => _method; public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory factory) { Debug.Assert(!factory.MetadataManager.IsReflectionBlocked(_method.GetTypicalMethodDefinition())); // Depends on static virtual method support. Turning off reflection for now. if (_method.IsVirtual && _method.Signature.IsStatic) return null; DependencyList dependencies = new DependencyList(); factory.MetadataManager.GetDependenciesDueToReflectability(ref dependencies, factory, _method); // No runtime artifacts needed if this is a generic definition if (_method.IsGenericMethodDefinition || _method.OwningType.IsGenericDefinition) { return dependencies; } // Ensure we consistently apply reflectability to all methods sharing the same definition. // Different instantiations of the method have a conditional dependency on the definition node that // brings a ReflectableMethod of the instantiated method if it's necessary for it to be reflectable. MethodDesc typicalMethod = _method.GetTypicalMethodDefinition(); if (typicalMethod != _method) { dependencies.Add(factory.ReflectableMethod(typicalMethod), "Definition of the reflectable method"); } MethodDesc canonMethod = _method.GetCanonMethodTarget(CanonicalFormKind.Specific); if (canonMethod != _method) { dependencies.Add(factory.ReflectableMethod(canonMethod), "Canonical version of the reflectable method"); } // Make sure we generate the method body and other artifacts. if (MetadataManager.IsMethodSupportedInReflectionInvoke(_method)) { if (_method.IsVirtual) { if (_method.HasInstantiation) { dependencies.Add(factory.GVMDependencies(_method.GetCanonMethodTarget(CanonicalFormKind.Specific)), "GVM callable reflectable method"); } else { // Virtual method use is tracked on the slot defining method only. MethodDesc slotDefiningMethod = MetadataVirtualMethodAlgorithm.FindSlotDefiningMethodForVirtualMethod(_method); if (!factory.VTable(slotDefiningMethod.OwningType).HasFixedSlots) dependencies.Add(factory.VirtualMethodUse(slotDefiningMethod), "Virtually callable reflectable method"); } } if (!_method.IsAbstract) { dependencies.Add(factory.MethodEntrypoint(canonMethod), "Body of a reflectable method"); if (_method.HasInstantiation && _method != canonMethod) dependencies.Add(factory.MethodGenericDictionary(_method), "Dictionary of a reflectable method"); } } return dependencies; } protected override string GetName(NodeFactory factory) { return "Reflectable method: " + _method.ToString(); } public override bool InterestingForDynamicDependencyAnalysis => false; public override bool HasDynamicDependencies => false; public override bool HasConditionalStaticDependencies => false; public override bool StaticDependenciesAreComputed => true; public override IEnumerable<CombinedDependencyListEntry> GetConditionalStaticDependencies(NodeFactory factory) => null; public override IEnumerable<CombinedDependencyListEntry> SearchDynamicDependencies(List<DependencyNodeCore<NodeFactory>> markedNodes, int firstNode, NodeFactory factory) => null; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using ILCompiler.DependencyAnalysisFramework; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; namespace ILCompiler.DependencyAnalysis { /// <summary> /// Represents a method that is visible to reflection. /// </summary> public class ReflectableMethodNode : DependencyNodeCore<NodeFactory> { private readonly MethodDesc _method; public ReflectableMethodNode(MethodDesc method) { Debug.Assert(!method.IsCanonicalMethod(CanonicalFormKind.Any) || method.GetCanonMethodTarget(CanonicalFormKind.Specific) == method); _method = method; } public MethodDesc Method => _method; public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory factory) { Debug.Assert(!factory.MetadataManager.IsReflectionBlocked(_method.GetTypicalMethodDefinition())); DependencyList dependencies = new DependencyList(); factory.MetadataManager.GetDependenciesDueToReflectability(ref dependencies, factory, _method); // No runtime artifacts needed if this is a generic definition if (_method.IsGenericMethodDefinition || _method.OwningType.IsGenericDefinition) { return dependencies; } // Ensure we consistently apply reflectability to all methods sharing the same definition. // Different instantiations of the method have a conditional dependency on the definition node that // brings a ReflectableMethod of the instantiated method if it's necessary for it to be reflectable. MethodDesc typicalMethod = _method.GetTypicalMethodDefinition(); if (typicalMethod != _method) { dependencies.Add(factory.ReflectableMethod(typicalMethod), "Definition of the reflectable method"); } MethodDesc canonMethod = _method.GetCanonMethodTarget(CanonicalFormKind.Specific); if (canonMethod != _method) { dependencies.Add(factory.ReflectableMethod(canonMethod), "Canonical version of the reflectable method"); } // Make sure we generate the method body and other artifacts. if (MetadataManager.IsMethodSupportedInReflectionInvoke(_method)) { if (_method.IsVirtual) { if (_method.HasInstantiation) { dependencies.Add(factory.GVMDependencies(_method.GetCanonMethodTarget(CanonicalFormKind.Specific)), "GVM callable reflectable method"); } else { // Virtual method use is tracked on the slot defining method only. MethodDesc slotDefiningMethod = MetadataVirtualMethodAlgorithm.FindSlotDefiningMethodForVirtualMethod(_method); if (!factory.VTable(slotDefiningMethod.OwningType).HasFixedSlots) dependencies.Add(factory.VirtualMethodUse(slotDefiningMethod), "Virtually callable reflectable method"); } } if (!_method.IsAbstract) { dependencies.Add(factory.MethodEntrypoint(canonMethod), "Body of a reflectable method"); if (_method.HasInstantiation && _method != canonMethod) dependencies.Add(factory.MethodGenericDictionary(_method), "Dictionary of a reflectable method"); } } return dependencies; } protected override string GetName(NodeFactory factory) { return "Reflectable method: " + _method.ToString(); } public override bool InterestingForDynamicDependencyAnalysis => false; public override bool HasDynamicDependencies => false; public override bool HasConditionalStaticDependencies => false; public override bool StaticDependenciesAreComputed => true; public override IEnumerable<CombinedDependencyListEntry> GetConditionalStaticDependencies(NodeFactory factory) => null; public override IEnumerable<CombinedDependencyListEntry> SearchDynamicDependencies(List<DependencyNodeCore<NodeFactory>> markedNodes, int firstNode, NodeFactory factory) => null; } }
1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/MetadataManager.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using Internal.TypeSystem; using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; using Debug = System.Diagnostics.Debug; using ReadyToRunSectionType = Internal.Runtime.ReadyToRunSectionType; using ReflectionMapBlob = Internal.Runtime.ReflectionMapBlob; using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore<ILCompiler.DependencyAnalysis.NodeFactory>.DependencyList; using CombinedDependencyList = System.Collections.Generic.List<ILCompiler.DependencyAnalysisFramework.DependencyNodeCore<ILCompiler.DependencyAnalysis.NodeFactory>.CombinedDependencyListEntry>; using MethodIL = Internal.IL.MethodIL; using CustomAttributeValue = System.Reflection.Metadata.CustomAttributeValue<Internal.TypeSystem.TypeDesc>; using MetadataRecord = Internal.Metadata.NativeFormat.Writer.MetadataRecord; using MemberReference = Internal.Metadata.NativeFormat.Writer.MemberReference; using TypeReference = Internal.Metadata.NativeFormat.Writer.TypeReference; using TypeSpecification = Internal.Metadata.NativeFormat.Writer.TypeSpecification; using ConstantStringValue = Internal.Metadata.NativeFormat.Writer.ConstantStringValue; using TypeInstantiationSignature = Internal.Metadata.NativeFormat.Writer.TypeInstantiationSignature; using MethodInstantiation = Internal.Metadata.NativeFormat.Writer.MethodInstantiation; namespace ILCompiler { /// <summary> /// This class is responsible for managing native metadata to be emitted into the compiled /// module. It also helps facilitate mappings between generated runtime structures or code, /// and the native metadata. /// </summary> public abstract class MetadataManager : ICompilationRootProvider { internal const int MetadataOffsetMask = 0xFFFFFF; private byte[] _metadataBlob; private List<MetadataMapping<MetadataType>> _typeMappings; private List<MetadataMapping<FieldDesc>> _fieldMappings; private List<MetadataMapping<MethodDesc>> _methodMappings; private List<MetadataMapping<MethodDesc>> _stackTraceMappings; protected readonly CompilerTypeSystemContext _typeSystemContext; protected readonly MetadataBlockingPolicy _blockingPolicy; protected readonly ManifestResourceBlockingPolicy _resourceBlockingPolicy; protected readonly DynamicInvokeThunkGenerationPolicy _dynamicInvokeThunkGenerationPolicy; private List<NonGCStaticsNode> _cctorContextsGenerated = new List<NonGCStaticsNode>(); private readonly HashSet<TypeDesc> _typesWithEETypesGenerated = new HashSet<TypeDesc>(); private readonly HashSet<TypeDesc> _typesWithConstructedEETypesGenerated = new HashSet<TypeDesc>(); private HashSet<MethodDesc> _methodsGenerated = new HashSet<MethodDesc>(); private HashSet<MethodDesc> _reflectableMethods = new HashSet<MethodDesc>(); private HashSet<GenericDictionaryNode> _genericDictionariesGenerated = new HashSet<GenericDictionaryNode>(); private HashSet<IMethodBodyNode> _methodBodiesGenerated = new HashSet<IMethodBodyNode>(); private List<TypeGVMEntriesNode> _typeGVMEntries = new List<TypeGVMEntriesNode>(); private HashSet<DefType> _typesWithDelegateMarshalling = new HashSet<DefType>(); private HashSet<DefType> _typesWithStructMarshalling = new HashSet<DefType>(); private HashSet<MethodDesc> _dynamicInvokeTemplates = new HashSet<MethodDesc>(); private HashSet<NativeLayoutTemplateMethodSignatureVertexNode> _templateMethodEntries = new HashSet<NativeLayoutTemplateMethodSignatureVertexNode>(); internal NativeLayoutInfoNode NativeLayoutInfo { get; private set; } internal DynamicInvokeTemplateDataNode DynamicInvokeTemplateData { get; private set; } public MetadataManager(CompilerTypeSystemContext typeSystemContext, MetadataBlockingPolicy blockingPolicy, ManifestResourceBlockingPolicy resourceBlockingPolicy, DynamicInvokeThunkGenerationPolicy dynamicInvokeThunkGenerationPolicy) { _typeSystemContext = typeSystemContext; _blockingPolicy = blockingPolicy; _resourceBlockingPolicy = resourceBlockingPolicy; _dynamicInvokeThunkGenerationPolicy = dynamicInvokeThunkGenerationPolicy; } public void AttachToDependencyGraph(DependencyAnalyzerBase<NodeFactory> graph) { graph.NewMarkedNode += Graph_NewMarkedNode; } internal static ReadyToRunSectionType BlobIdToReadyToRunSection(ReflectionMapBlob blobId) { var result = (ReadyToRunSectionType)((int)blobId + (int)ReadyToRunSectionType.ReadonlyBlobRegionStart); Debug.Assert(result <= ReadyToRunSectionType.ReadonlyBlobRegionEnd); return result; } public virtual void AddToReadyToRunHeader(ReadyToRunHeaderNode header, NodeFactory nodeFactory, ExternalReferencesTableNode commonFixupsTableNode) { var metadataNode = new MetadataNode(); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.EmbeddedMetadata), metadataNode, metadataNode, metadataNode.EndSymbol); var nativeReferencesTableNode = new ExternalReferencesTableNode("NativeReferences", nodeFactory); var nativeStaticsTableNode = new ExternalReferencesTableNode("NativeStatics", nodeFactory); var resourceDataNode = new ResourceDataNode(); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.BlobIdResourceData), resourceDataNode, resourceDataNode, resourceDataNode.EndSymbol); var resourceIndexNode = new ResourceIndexNode(resourceDataNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.BlobIdResourceIndex), resourceIndexNode, resourceIndexNode, resourceIndexNode.EndSymbol); var typeMapNode = new TypeMetadataMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.TypeMap), typeMapNode, typeMapNode, typeMapNode.EndSymbol); var cctorContextMapNode = new ClassConstructorContextMap(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.CCtorContextMap), cctorContextMapNode, cctorContextMapNode, cctorContextMapNode.EndSymbol); DynamicInvokeTemplateData = new DynamicInvokeTemplateDataNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.DynamicInvokeTemplateData), DynamicInvokeTemplateData, DynamicInvokeTemplateData, DynamicInvokeTemplateData.EndSymbol); var invokeMapNode = new ReflectionInvokeMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.InvokeMap), invokeMapNode, invokeMapNode, invokeMapNode.EndSymbol); var arrayMapNode = new ArrayMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.ArrayMap), arrayMapNode, arrayMapNode, arrayMapNode.EndSymbol); var fieldMapNode = new ReflectionFieldMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.FieldAccessMap), fieldMapNode, fieldMapNode, fieldMapNode.EndSymbol); NativeLayoutInfo = new NativeLayoutInfoNode(nativeReferencesTableNode, nativeStaticsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.NativeLayoutInfo), NativeLayoutInfo, NativeLayoutInfo, NativeLayoutInfo.EndSymbol); var exactMethodInstantiations = new ExactMethodInstantiationsNode(nativeReferencesTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.ExactMethodInstantiationsHashtable), exactMethodInstantiations, exactMethodInstantiations, exactMethodInstantiations.EndSymbol); var genericsTypesHashtableNode = new GenericTypesHashtableNode(nativeReferencesTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericsHashtable), genericsTypesHashtableNode, genericsTypesHashtableNode, genericsTypesHashtableNode.EndSymbol); var genericMethodsHashtableNode = new GenericMethodsHashtableNode(nativeReferencesTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericMethodsHashtable), genericMethodsHashtableNode, genericMethodsHashtableNode, genericMethodsHashtableNode.EndSymbol); var genericVirtualMethodTableNode = new GenericVirtualMethodTableNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericVirtualMethodTable), genericVirtualMethodTableNode, genericVirtualMethodTableNode, genericVirtualMethodTableNode.EndSymbol); var interfaceGenericVirtualMethodTableNode = new InterfaceGenericVirtualMethodTableNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.InterfaceGenericVirtualMethodTable), interfaceGenericVirtualMethodTableNode, interfaceGenericVirtualMethodTableNode, interfaceGenericVirtualMethodTableNode.EndSymbol); var genericMethodsTemplatesMapNode = new GenericMethodsTemplateMap(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericMethodsTemplateMap), genericMethodsTemplatesMapNode, genericMethodsTemplatesMapNode, genericMethodsTemplatesMapNode.EndSymbol); var genericTypesTemplatesMapNode = new GenericTypesTemplateMap(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.TypeTemplateMap), genericTypesTemplatesMapNode, genericTypesTemplatesMapNode, genericTypesTemplatesMapNode.EndSymbol); var blockReflectionTypeMapNode = new BlockReflectionTypeMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.BlockReflectionTypeMap), blockReflectionTypeMapNode, blockReflectionTypeMapNode, blockReflectionTypeMapNode.EndSymbol); var staticsInfoHashtableNode = new StaticsInfoHashtableNode(nativeReferencesTableNode, nativeStaticsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.StaticsInfoHashtable), staticsInfoHashtableNode, staticsInfoHashtableNode, staticsInfoHashtableNode.EndSymbol); var virtualInvokeMapNode = new ReflectionVirtualInvokeMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.VirtualInvokeMap), virtualInvokeMapNode, virtualInvokeMapNode, virtualInvokeMapNode.EndSymbol); var defaultConstructorMapNode = new DefaultConstructorMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.DefaultConstructorMap), defaultConstructorMapNode, defaultConstructorMapNode, defaultConstructorMapNode.EndSymbol); var stackTraceMethodMappingNode = new StackTraceMethodMappingNode(); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.BlobIdStackTraceMethodRvaToTokenMapping), stackTraceMethodMappingNode, stackTraceMethodMappingNode, stackTraceMethodMappingNode.EndSymbol); // The external references tables should go last header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.NativeReferences), nativeReferencesTableNode, nativeReferencesTableNode, nativeReferencesTableNode.EndSymbol); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.NativeStatics), nativeStaticsTableNode, nativeStaticsTableNode, nativeStaticsTableNode.EndSymbol); } protected virtual void Graph_NewMarkedNode(DependencyNodeCore<NodeFactory> obj) { var eetypeNode = obj as EETypeNode; if (eetypeNode != null) { _typesWithEETypesGenerated.Add(eetypeNode.Type); if (eetypeNode is ConstructedEETypeNode || eetypeNode is CanonicalEETypeNode) { _typesWithConstructedEETypesGenerated.Add(eetypeNode.Type); } return; } IMethodBodyNode methodBodyNode = obj as IMethodBodyNode; if (methodBodyNode != null) { _methodBodiesGenerated.Add(methodBodyNode); } IMethodNode methodNode = methodBodyNode; if (methodNode == null) methodNode = obj as ShadowConcreteMethodNode; if (methodNode != null) { _methodsGenerated.Add(methodNode.Method); if (AllMethodsCanBeReflectable) _reflectableMethods.Add(methodNode.Method); return; } var reflectableMethodNode = obj as ReflectableMethodNode; if (reflectableMethodNode != null) { _reflectableMethods.Add(reflectableMethodNode.Method); } var nonGcStaticSectionNode = obj as NonGCStaticsNode; if (nonGcStaticSectionNode != null && nonGcStaticSectionNode.HasCCtorContext) { _cctorContextsGenerated.Add(nonGcStaticSectionNode); } var gvmEntryNode = obj as TypeGVMEntriesNode; if (gvmEntryNode != null) { _typeGVMEntries.Add(gvmEntryNode); } var dictionaryNode = obj as GenericDictionaryNode; if (dictionaryNode != null) { _genericDictionariesGenerated.Add(dictionaryNode); } if (obj is StructMarshallingDataNode structMarshallingDataNode) { _typesWithStructMarshalling.Add(structMarshallingDataNode.Type); } if (obj is DelegateMarshallingDataNode delegateMarshallingDataNode) { _typesWithDelegateMarshalling.Add(delegateMarshallingDataNode.Type); } if (obj is DynamicInvokeTemplateNode dynamicInvokeTemplate) { _dynamicInvokeTemplates.Add(dynamicInvokeTemplate.Method); } if (obj is NativeLayoutTemplateMethodSignatureVertexNode templateMethodEntry) { _templateMethodEntries.Add(templateMethodEntry); } } protected virtual bool AllMethodsCanBeReflectable => false; /// <summary> /// Is a method that is reflectable a method which should be placed into the invoke map as invokable? /// </summary> public virtual bool IsReflectionInvokable(MethodDesc method) { return Internal.IL.Stubs.DynamicInvokeMethodThunk.SupportsSignature(method.Signature) && IsMethodSupportedInReflectionInvoke(method); } public static bool IsMethodSupportedInReflectionInvoke(MethodDesc method) { TypeDesc owningType = method.OwningType; // Methods on nullable are special cased in the runtime reflection if (owningType.IsNullable) return false; // Methods on arrays are special cased in the runtime reflection if (owningType.IsArray) return false; // Finalizers are not reflection invokable if (method.IsFinalizer) return false; // Static constructors are not reflection invokable if (method.IsStaticConstructor) return false; if (method.IsConstructor) { // Delegate construction is only allowed through specific IL sequences if (owningType.IsDelegate) return false; // String constructors are intrinsic and special cased in runtime reflection if (owningType.IsString) return false; } // Everything else can go in the mapping table. return true; } /// <summary> /// Is there a reflection invoke stub for a method that is invokable? /// </summary> public bool HasReflectionInvokeStub(MethodDesc method) { if (!IsReflectionInvokable(method)) return false; return HasReflectionInvokeStubForInvokableMethod(method); } /// <summary> /// Is there a reflection invoke stub for a method that is invokable? /// </summary> public bool ShouldMethodBeInInvokeMap(MethodDesc method) { // The current format requires us to have an MethodTable for the owning type. We might want to lift this. if (!TypeGeneratesEEType(method.OwningType)) return false; // We have a method body, we have a metadata token, but we can't get an invoke stub. Bail. if (!IsReflectionInvokable(method)) return false; return true; } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to compiled method bodies. /// </summary> public void GetDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { MetadataCategory category = GetMetadataCategory(method); if ((category & MetadataCategory.Description) != 0) { GetMetadataDependenciesDueToReflectability(ref dependencies, factory, method); } if ((category & MetadataCategory.RuntimeMapping) != 0) { if (IsReflectionInvokable(method)) { // We're going to generate a mapping table entry for this. Collect dependencies. ReflectionInvokeMapNode.AddDependenciesDueToReflectability(ref dependencies, factory, method); ReflectionInvokeSupportDependencyAlgorithm.GetDependenciesFromParamsArray(ref dependencies, factory, method); } } } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies on a virtual method. /// </summary> public virtual void GetDependenciesDueToVirtualMethodReflectability(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { } protected virtual void GetMetadataDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { // MetadataManagers can override this to provide additional dependencies caused by the emission of metadata // (E.g. dependencies caused by the method having custom attributes applied to it: making sure we compile the attribute constructor // and property setters) } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to generated EETypes. /// </summary> public void GetDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { MetadataCategory category = GetMetadataCategory(type); if ((category & MetadataCategory.Description) != 0) { GetMetadataDependenciesDueToReflectability(ref dependencies, factory, type); } if ((category & MetadataCategory.RuntimeMapping) != 0) { // We're going to generate a mapping table entry for this. Collect dependencies. // Nothing special is needed for the mapping table (we only emit the MethodTable and we already // have one, since we got this callback). But check if a child wants to do something extra. GetRuntimeMappingDependenciesDueToReflectability(ref dependencies, factory, type); } GetDependenciesDueToEETypePresence(ref dependencies, factory, type); } protected virtual void GetMetadataDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { // MetadataManagers can override this to provide additional dependencies caused by the emission of metadata // (E.g. dependencies caused by the type having custom attributes applied to it: making sure we compile the attribute constructor // and property setters) } protected virtual void GetRuntimeMappingDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { // MetadataManagers can override this to provide additional dependencies caused by the emission of a runtime // mapping for a type. } protected virtual void GetDependenciesDueToEETypePresence(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { // MetadataManagers can override this to provide additional dependencies caused by the emission of an MethodTable. } public virtual void GetConditionalDependenciesDueToEETypePresence(ref CombinedDependencyList dependencies, NodeFactory factory, TypeDesc type) { // MetadataManagers can override this to provide additional dependencies caused by the presence of // an MethodTable. } public virtual bool HasConditionalDependenciesDueToEETypePresence(TypeDesc type) { return false; } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to generated RuntimeMethodHandles. /// </summary> public virtual void GetDependenciesDueToLdToken(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { // MetadataManagers can override this to provide additional dependencies caused by the presence of a // RuntimeMethodHandle data structure. } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to generated RuntimeFieldHandles. /// </summary> public virtual void GetDependenciesDueToLdToken(ref DependencyList dependencies, NodeFactory factory, FieldDesc field) { // MetadataManagers can override this to provide additional dependencies caused by the presence of a // RuntimeFieldHandle data structure. } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to generated method bodies. /// </summary> public void GetDependenciesDueToMethodCodePresence(ref DependencyList dependencies, NodeFactory factory, MethodDesc method, MethodIL methodIL) { if (method.HasInstantiation) { ExactMethodInstantiationsNode.GetExactMethodInstantiationDependenciesForMethod(ref dependencies, factory, method); } GetDependenciesDueToTemplateTypeLoader(ref dependencies, factory, method); GetDependenciesDueToMethodCodePresenceInternal(ref dependencies, factory, method, methodIL); } public virtual void GetConditionalDependenciesDueToMethodCodePresence(ref CombinedDependencyList dependencies, NodeFactory factory, MethodDesc method) { // MetadataManagers can override this to provide additional dependencies caused by the presence of // method code. } private void GetDependenciesDueToTemplateTypeLoader(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { // TODO-SIZE: this is overly generous in the templates we create if (_blockingPolicy is FullyBlockedMetadataBlockingPolicy) return; if (method.HasInstantiation) { GenericMethodsTemplateMap.GetTemplateMethodDependencies(ref dependencies, factory, method); } else { TypeDesc owningTemplateType = method.OwningType; // Unboxing and Instantiating stubs use a different type as their template if (factory.TypeSystemContext.IsSpecialUnboxingThunk(method)) owningTemplateType = factory.TypeSystemContext.GetTargetOfSpecialUnboxingThunk(method).OwningType; GenericTypesTemplateMap.GetTemplateTypeDependencies(ref dependencies, factory, owningTemplateType); } } protected virtual void GetDependenciesDueToMethodCodePresenceInternal(ref DependencyList dependencies, NodeFactory factory, MethodDesc method, MethodIL methodIL) { // MetadataManagers can override this to provide additional dependencies caused by the presence of a // compiled method body. } /// <summary> /// Given that a method is invokable, does there exist a reflection invoke stub? /// </summary> public bool HasReflectionInvokeStubForInvokableMethod(MethodDesc method) { Debug.Assert(IsReflectionInvokable(method)); return _dynamicInvokeThunkGenerationPolicy.HasStaticInvokeThunk(method); } /// <summary> /// Given that a method is invokable, if it is inserted into the reflection invoke table /// will it use a method token to be referenced, or not? /// </summary> public abstract bool WillUseMetadataTokenToReferenceMethod(MethodDesc method); /// <summary> /// Given that a method is invokable, if it is inserted into the reflection invoke table /// will it use a field token to be referenced, or not? /// </summary> public abstract bool WillUseMetadataTokenToReferenceField(FieldDesc field); /// <summary> /// Gets a stub that can be used to reflection-invoke a method with a given signature. /// </summary> public abstract MethodDesc GetCanonicalReflectionInvokeStub(MethodDesc method); /// <summary> /// Compute the canonical instantiation of a dynamic invoke thunk needed to invoke a method /// This algorithm is shared with the runtime, so if a thunk requires generic instantiation /// to be used, it must match this algorithm, and cannot be different with different MetadataManagers /// NOTE: This function may return null in cases where an exact instantiation does not exist. (Universal Generics) /// </summary> protected MethodDesc InstantiateCanonicalDynamicInvokeMethodForMethod(MethodDesc thunk, MethodDesc method) { if (thunk.Instantiation.Length == 0) { // nothing to instantiate return thunk; } MethodSignature sig = method.Signature; TypeSystemContext context = method.Context; // // Instantiate the generic thunk over the parameters and the return type of the target method // TypeDesc[] instantiation = Internal.IL.Stubs.DynamicInvokeMethodThunk.GetThunkInstantiationForMethod(method); Debug.Assert(thunk.Instantiation.Length == instantiation.Length); // Check if at least one of the instantiation arguments is a universal canonical type, and if so, we // won't create a dynamic invoker instantiation. The arguments will be interpreted at runtime by the // calling convention converter during the dynamic invocation foreach (TypeDesc type in instantiation) { if (type.IsCanonicalSubtype(CanonicalFormKind.Universal)) return null; } // If the thunk ends up being shared code, return the canonical method body. // The concrete dictionary for the thunk will be built at runtime and is not interesting for the compiler. Instantiation canonInstantiation = context.ConvertInstantiationToCanonForm(new Instantiation(instantiation), CanonicalFormKind.Specific); MethodDesc instantiatedDynamicInvokeMethod = thunk.Context.GetInstantiatedMethod(thunk, canonInstantiation); return instantiatedDynamicInvokeMethod; } protected void EnsureMetadataGenerated(NodeFactory factory) { if (_metadataBlob != null) return; ComputeMetadata(factory, out _metadataBlob, out _typeMappings, out _methodMappings, out _fieldMappings, out _stackTraceMappings); } void ICompilationRootProvider.AddCompilationRoots(IRootingServiceProvider rootProvider) { // MetadataManagers can override this to provide metadata compilation roots that need to be added to the graph ahead of time. // (E.g. reflection roots computed by IL analyzers, or non-compilation-based roots) } protected abstract void ComputeMetadata(NodeFactory factory, out byte[] metadataBlob, out List<MetadataMapping<MetadataType>> typeMappings, out List<MetadataMapping<MethodDesc>> methodMappings, out List<MetadataMapping<FieldDesc>> fieldMappings, out List<MetadataMapping<MethodDesc>> stackTraceMapping); protected MetadataRecord CreateStackTraceRecord(Metadata.MetadataTransform transform, MethodDesc method) { // In the metadata, we only represent the generic definition MethodDesc methodToGenerateMetadataFor = method.GetTypicalMethodDefinition(); MetadataRecord record = transform.HandleQualifiedMethod(methodToGenerateMetadataFor); // If we're generating a MemberReference to a method on a generic type, the owning type // should appear as if instantiated over its formals TypeDesc owningTypeToGenerateMetadataFor = methodToGenerateMetadataFor.OwningType; if (owningTypeToGenerateMetadataFor.HasInstantiation && record is MemberReference memberRefRecord && memberRefRecord.Parent is TypeReference) { List<MetadataRecord> genericArgs = new List<MetadataRecord>(); foreach (Internal.TypeSystem.Ecma.EcmaGenericParameter genericParam in owningTypeToGenerateMetadataFor.Instantiation) { genericArgs.Add(new TypeReference { TypeName = (ConstantStringValue)genericParam.Name, }); } memberRefRecord.Parent = new TypeSpecification { Signature = new TypeInstantiationSignature { GenericType = memberRefRecord.Parent, GenericTypeArguments = genericArgs, } }; } // As a twist, instantiated generic methods appear as if instantiated over their formals. if (methodToGenerateMetadataFor.HasInstantiation) { var methodInst = new MethodInstantiation { Method = record, }; methodInst.GenericTypeArguments.Capacity = methodToGenerateMetadataFor.Instantiation.Length; foreach (Internal.TypeSystem.Ecma.EcmaGenericParameter typeArgument in methodToGenerateMetadataFor.Instantiation) { var genericParam = new TypeReference { TypeName = (ConstantStringValue)typeArgument.Name, }; methodInst.GenericTypeArguments.Add(genericParam); } record = methodInst; } return record; } /// <summary> /// Returns a set of modules that will get some metadata emitted into the output module /// </summary> public abstract IEnumerable<ModuleDesc> GetCompilationModulesWithMetadata(); public byte[] GetMetadataBlob(NodeFactory factory) { EnsureMetadataGenerated(factory); return _metadataBlob; } public IEnumerable<MetadataMapping<MetadataType>> GetTypeDefinitionMapping(NodeFactory factory) { EnsureMetadataGenerated(factory); return _typeMappings; } public IEnumerable<MetadataMapping<MethodDesc>> GetMethodMapping(NodeFactory factory) { EnsureMetadataGenerated(factory); return _methodMappings; } public IEnumerable<MetadataMapping<FieldDesc>> GetFieldMapping(NodeFactory factory) { EnsureMetadataGenerated(factory); return _fieldMappings; } public IEnumerable<MetadataMapping<MethodDesc>> GetStackTraceMapping(NodeFactory factory) { EnsureMetadataGenerated(factory); return _stackTraceMappings; } internal IEnumerable<NonGCStaticsNode> GetCctorContextMapping() { return _cctorContextsGenerated; } internal IEnumerable<TypeGVMEntriesNode> GetTypeGVMEntries() { return _typeGVMEntries; } internal IReadOnlyCollection<GenericDictionaryNode> GetCompiledGenericDictionaries() { return _genericDictionariesGenerated; } internal IEnumerable<DefType> GetTypesWithStructMarshalling() { return _typesWithStructMarshalling; } internal IEnumerable<DefType> GetTypesWithDelegateMarshalling() { return _typesWithDelegateMarshalling; } public IEnumerable<MethodDesc> GetCompiledMethods() { return _methodsGenerated; } public IEnumerable<MethodDesc> GetReflectableMethods() { return _reflectableMethods; } internal IEnumerable<IMethodBodyNode> GetCompiledMethodBodies() { return _methodBodiesGenerated; } internal bool TypeGeneratesEEType(TypeDesc type) { return _typesWithEETypesGenerated.Contains(type); } internal IEnumerable<TypeDesc> GetTypesWithEETypes() { return _typesWithEETypesGenerated; } internal IEnumerable<TypeDesc> GetTypesWithConstructedEETypes() { return _typesWithConstructedEETypesGenerated; } internal IEnumerable<MethodDesc> GetDynamicInvokeTemplateMethods() { return _dynamicInvokeTemplates; } internal IEnumerable<NativeLayoutTemplateMethodSignatureVertexNode> GetTemplateMethodEntries() { return _templateMethodEntries; } public bool IsReflectionBlocked(TypeDesc type) { switch (type.Category) { case TypeFlags.SzArray: case TypeFlags.Array: case TypeFlags.Pointer: case TypeFlags.ByRef: return IsReflectionBlocked(((ParameterizedType)type).ParameterType); case TypeFlags.FunctionPointer: MethodSignature pointerSignature = ((FunctionPointerType)type).Signature; for (int i = 0; i < pointerSignature.Length; i++) if (IsReflectionBlocked(pointerSignature[i])) return true; return IsReflectionBlocked(pointerSignature.ReturnType); default: Debug.Assert(type.IsDefType); TypeDesc typeDefinition = type.GetTypeDefinition(); if (type != typeDefinition) { if (_blockingPolicy.IsBlocked((MetadataType)typeDefinition)) return true; if (IsReflectionBlocked(type.Instantiation)) return true; return false; } return _blockingPolicy.IsBlocked((MetadataType)type); } } protected bool IsReflectionBlocked(Instantiation instantiation) { foreach (TypeDesc type in instantiation) { if (IsReflectionBlocked(type) && !type.IsCanonicalDefinitionType(CanonicalFormKind.Any)) return true; } return false; } public bool IsReflectionBlocked(FieldDesc field) { FieldDesc typicalFieldDefinition = field.GetTypicalFieldDefinition(); if (typicalFieldDefinition != field && IsReflectionBlocked(field.OwningType.Instantiation)) { return true; } return _blockingPolicy.IsBlocked(typicalFieldDefinition); } public bool IsReflectionBlocked(MethodDesc method) { MethodDesc methodDefinition = method.GetMethodDefinition(); if (method != methodDefinition && IsReflectionBlocked(method.Instantiation)) { return true; } MethodDesc typicalMethodDefinition = methodDefinition.GetTypicalMethodDefinition(); if (typicalMethodDefinition != methodDefinition && IsReflectionBlocked(method.OwningType.Instantiation)) { return true; } return _blockingPolicy.IsBlocked(typicalMethodDefinition); } public bool IsManifestResourceBlocked(ModuleDesc module, string resourceName) { return _resourceBlockingPolicy.IsManifestResourceBlocked(module, resourceName); } public bool CanGenerateMetadata(MetadataType type) { return (GetMetadataCategory(type) & MetadataCategory.Description) != 0; } public bool CanGenerateMetadata(MethodDesc method) { Debug.Assert(method.IsTypicalMethodDefinition); return (GetMetadataCategory(method) & MetadataCategory.Description) != 0; } public bool CanGenerateMetadata(FieldDesc field) { Debug.Assert(field.IsTypicalFieldDefinition); return (GetMetadataCategory(field) & MetadataCategory.Description) != 0; } /// <summary> /// Gets the metadata category for a compiled method body in the current compilation. /// The method will only get called with '<paramref name="method"/>' that has a compiled method body /// in this compilation. /// Note that if this method doesn't return <see cref="MetadataCategory.Description"/>, it doesn't mean /// that the method never has metadata. The metadata might just be generated in a different compilation. /// </summary> protected abstract MetadataCategory GetMetadataCategory(MethodDesc method); /// <summary> /// Gets the metadata category for a generated type in the current compilation. /// The method can assume it will only get called with '<paramref name="type"/>' that has an MethodTable generated /// in the current compilation. /// Note that if this method doesn't return <see cref="MetadataCategory.Description"/>, it doesn't mean /// that the method never has metadata. The metadata might just be generated in a different compilation. /// </summary> protected abstract MetadataCategory GetMetadataCategory(TypeDesc type); protected abstract MetadataCategory GetMetadataCategory(FieldDesc field); public virtual void GetDependenciesDueToAccess(ref DependencyList dependencies, NodeFactory factory, MethodIL methodIL, MethodDesc calledMethod) { } public virtual void GetDependenciesDueToAccess(ref DependencyList dependencies, NodeFactory factory, MethodIL methodIL, FieldDesc writtenField) { } public virtual DependencyList GetDependenciesForCustomAttribute(NodeFactory factory, MethodDesc attributeCtor, CustomAttributeValue decodedValue) { return null; } public virtual void GetDependenciesForGenericDictionary(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { } public virtual void GetDependenciesForGenericDictionary(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { } public virtual void NoteOverridingMethod(MethodDesc baseMethod, MethodDesc overridingMethod) { } } public struct MetadataMapping<TEntity> { public readonly TEntity Entity; public readonly int MetadataHandle; public MetadataMapping(TEntity entity, int metadataHandle) { Entity = entity; MetadataHandle = metadataHandle; } } [Flags] public enum MetadataCategory { None = 0x00, Description = 0x01, RuntimeMapping = 0x02, } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using Internal.TypeSystem; using ILCompiler.DependencyAnalysis; using ILCompiler.DependencyAnalysisFramework; using Debug = System.Diagnostics.Debug; using ReadyToRunSectionType = Internal.Runtime.ReadyToRunSectionType; using ReflectionMapBlob = Internal.Runtime.ReflectionMapBlob; using DependencyList = ILCompiler.DependencyAnalysisFramework.DependencyNodeCore<ILCompiler.DependencyAnalysis.NodeFactory>.DependencyList; using CombinedDependencyList = System.Collections.Generic.List<ILCompiler.DependencyAnalysisFramework.DependencyNodeCore<ILCompiler.DependencyAnalysis.NodeFactory>.CombinedDependencyListEntry>; using MethodIL = Internal.IL.MethodIL; using CustomAttributeValue = System.Reflection.Metadata.CustomAttributeValue<Internal.TypeSystem.TypeDesc>; using MetadataRecord = Internal.Metadata.NativeFormat.Writer.MetadataRecord; using MemberReference = Internal.Metadata.NativeFormat.Writer.MemberReference; using TypeReference = Internal.Metadata.NativeFormat.Writer.TypeReference; using TypeSpecification = Internal.Metadata.NativeFormat.Writer.TypeSpecification; using ConstantStringValue = Internal.Metadata.NativeFormat.Writer.ConstantStringValue; using TypeInstantiationSignature = Internal.Metadata.NativeFormat.Writer.TypeInstantiationSignature; using MethodInstantiation = Internal.Metadata.NativeFormat.Writer.MethodInstantiation; namespace ILCompiler { /// <summary> /// This class is responsible for managing native metadata to be emitted into the compiled /// module. It also helps facilitate mappings between generated runtime structures or code, /// and the native metadata. /// </summary> public abstract class MetadataManager : ICompilationRootProvider { internal const int MetadataOffsetMask = 0xFFFFFF; private byte[] _metadataBlob; private List<MetadataMapping<MetadataType>> _typeMappings; private List<MetadataMapping<FieldDesc>> _fieldMappings; private List<MetadataMapping<MethodDesc>> _methodMappings; private List<MetadataMapping<MethodDesc>> _stackTraceMappings; protected readonly CompilerTypeSystemContext _typeSystemContext; protected readonly MetadataBlockingPolicy _blockingPolicy; protected readonly ManifestResourceBlockingPolicy _resourceBlockingPolicy; protected readonly DynamicInvokeThunkGenerationPolicy _dynamicInvokeThunkGenerationPolicy; private List<NonGCStaticsNode> _cctorContextsGenerated = new List<NonGCStaticsNode>(); private readonly HashSet<TypeDesc> _typesWithEETypesGenerated = new HashSet<TypeDesc>(); private readonly HashSet<TypeDesc> _typesWithConstructedEETypesGenerated = new HashSet<TypeDesc>(); private HashSet<MethodDesc> _methodsGenerated = new HashSet<MethodDesc>(); private HashSet<MethodDesc> _reflectableMethods = new HashSet<MethodDesc>(); private HashSet<GenericDictionaryNode> _genericDictionariesGenerated = new HashSet<GenericDictionaryNode>(); private HashSet<IMethodBodyNode> _methodBodiesGenerated = new HashSet<IMethodBodyNode>(); private List<TypeGVMEntriesNode> _typeGVMEntries = new List<TypeGVMEntriesNode>(); private HashSet<DefType> _typesWithDelegateMarshalling = new HashSet<DefType>(); private HashSet<DefType> _typesWithStructMarshalling = new HashSet<DefType>(); private HashSet<MethodDesc> _dynamicInvokeTemplates = new HashSet<MethodDesc>(); private HashSet<NativeLayoutTemplateMethodSignatureVertexNode> _templateMethodEntries = new HashSet<NativeLayoutTemplateMethodSignatureVertexNode>(); internal NativeLayoutInfoNode NativeLayoutInfo { get; private set; } internal DynamicInvokeTemplateDataNode DynamicInvokeTemplateData { get; private set; } public MetadataManager(CompilerTypeSystemContext typeSystemContext, MetadataBlockingPolicy blockingPolicy, ManifestResourceBlockingPolicy resourceBlockingPolicy, DynamicInvokeThunkGenerationPolicy dynamicInvokeThunkGenerationPolicy) { _typeSystemContext = typeSystemContext; _blockingPolicy = blockingPolicy; _resourceBlockingPolicy = resourceBlockingPolicy; _dynamicInvokeThunkGenerationPolicy = dynamicInvokeThunkGenerationPolicy; } public void AttachToDependencyGraph(DependencyAnalyzerBase<NodeFactory> graph) { graph.NewMarkedNode += Graph_NewMarkedNode; } internal static ReadyToRunSectionType BlobIdToReadyToRunSection(ReflectionMapBlob blobId) { var result = (ReadyToRunSectionType)((int)blobId + (int)ReadyToRunSectionType.ReadonlyBlobRegionStart); Debug.Assert(result <= ReadyToRunSectionType.ReadonlyBlobRegionEnd); return result; } public virtual void AddToReadyToRunHeader(ReadyToRunHeaderNode header, NodeFactory nodeFactory, ExternalReferencesTableNode commonFixupsTableNode) { var metadataNode = new MetadataNode(); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.EmbeddedMetadata), metadataNode, metadataNode, metadataNode.EndSymbol); var nativeReferencesTableNode = new ExternalReferencesTableNode("NativeReferences", nodeFactory); var nativeStaticsTableNode = new ExternalReferencesTableNode("NativeStatics", nodeFactory); var resourceDataNode = new ResourceDataNode(); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.BlobIdResourceData), resourceDataNode, resourceDataNode, resourceDataNode.EndSymbol); var resourceIndexNode = new ResourceIndexNode(resourceDataNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.BlobIdResourceIndex), resourceIndexNode, resourceIndexNode, resourceIndexNode.EndSymbol); var typeMapNode = new TypeMetadataMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.TypeMap), typeMapNode, typeMapNode, typeMapNode.EndSymbol); var cctorContextMapNode = new ClassConstructorContextMap(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.CCtorContextMap), cctorContextMapNode, cctorContextMapNode, cctorContextMapNode.EndSymbol); DynamicInvokeTemplateData = new DynamicInvokeTemplateDataNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.DynamicInvokeTemplateData), DynamicInvokeTemplateData, DynamicInvokeTemplateData, DynamicInvokeTemplateData.EndSymbol); var invokeMapNode = new ReflectionInvokeMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.InvokeMap), invokeMapNode, invokeMapNode, invokeMapNode.EndSymbol); var arrayMapNode = new ArrayMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.ArrayMap), arrayMapNode, arrayMapNode, arrayMapNode.EndSymbol); var fieldMapNode = new ReflectionFieldMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.FieldAccessMap), fieldMapNode, fieldMapNode, fieldMapNode.EndSymbol); NativeLayoutInfo = new NativeLayoutInfoNode(nativeReferencesTableNode, nativeStaticsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.NativeLayoutInfo), NativeLayoutInfo, NativeLayoutInfo, NativeLayoutInfo.EndSymbol); var exactMethodInstantiations = new ExactMethodInstantiationsNode(nativeReferencesTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.ExactMethodInstantiationsHashtable), exactMethodInstantiations, exactMethodInstantiations, exactMethodInstantiations.EndSymbol); var genericsTypesHashtableNode = new GenericTypesHashtableNode(nativeReferencesTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericsHashtable), genericsTypesHashtableNode, genericsTypesHashtableNode, genericsTypesHashtableNode.EndSymbol); var genericMethodsHashtableNode = new GenericMethodsHashtableNode(nativeReferencesTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericMethodsHashtable), genericMethodsHashtableNode, genericMethodsHashtableNode, genericMethodsHashtableNode.EndSymbol); var genericVirtualMethodTableNode = new GenericVirtualMethodTableNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericVirtualMethodTable), genericVirtualMethodTableNode, genericVirtualMethodTableNode, genericVirtualMethodTableNode.EndSymbol); var interfaceGenericVirtualMethodTableNode = new InterfaceGenericVirtualMethodTableNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.InterfaceGenericVirtualMethodTable), interfaceGenericVirtualMethodTableNode, interfaceGenericVirtualMethodTableNode, interfaceGenericVirtualMethodTableNode.EndSymbol); var genericMethodsTemplatesMapNode = new GenericMethodsTemplateMap(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.GenericMethodsTemplateMap), genericMethodsTemplatesMapNode, genericMethodsTemplatesMapNode, genericMethodsTemplatesMapNode.EndSymbol); var genericTypesTemplatesMapNode = new GenericTypesTemplateMap(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.TypeTemplateMap), genericTypesTemplatesMapNode, genericTypesTemplatesMapNode, genericTypesTemplatesMapNode.EndSymbol); var blockReflectionTypeMapNode = new BlockReflectionTypeMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.BlockReflectionTypeMap), blockReflectionTypeMapNode, blockReflectionTypeMapNode, blockReflectionTypeMapNode.EndSymbol); var staticsInfoHashtableNode = new StaticsInfoHashtableNode(nativeReferencesTableNode, nativeStaticsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.StaticsInfoHashtable), staticsInfoHashtableNode, staticsInfoHashtableNode, staticsInfoHashtableNode.EndSymbol); var virtualInvokeMapNode = new ReflectionVirtualInvokeMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.VirtualInvokeMap), virtualInvokeMapNode, virtualInvokeMapNode, virtualInvokeMapNode.EndSymbol); var defaultConstructorMapNode = new DefaultConstructorMapNode(commonFixupsTableNode); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.DefaultConstructorMap), defaultConstructorMapNode, defaultConstructorMapNode, defaultConstructorMapNode.EndSymbol); var stackTraceMethodMappingNode = new StackTraceMethodMappingNode(); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.BlobIdStackTraceMethodRvaToTokenMapping), stackTraceMethodMappingNode, stackTraceMethodMappingNode, stackTraceMethodMappingNode.EndSymbol); // The external references tables should go last header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.NativeReferences), nativeReferencesTableNode, nativeReferencesTableNode, nativeReferencesTableNode.EndSymbol); header.Add(BlobIdToReadyToRunSection(ReflectionMapBlob.NativeStatics), nativeStaticsTableNode, nativeStaticsTableNode, nativeStaticsTableNode.EndSymbol); } protected virtual void Graph_NewMarkedNode(DependencyNodeCore<NodeFactory> obj) { var eetypeNode = obj as EETypeNode; if (eetypeNode != null) { _typesWithEETypesGenerated.Add(eetypeNode.Type); if (eetypeNode is ConstructedEETypeNode || eetypeNode is CanonicalEETypeNode) { _typesWithConstructedEETypesGenerated.Add(eetypeNode.Type); } return; } IMethodBodyNode methodBodyNode = obj as IMethodBodyNode; if (methodBodyNode != null) { _methodBodiesGenerated.Add(methodBodyNode); } IMethodNode methodNode = methodBodyNode; if (methodNode == null) methodNode = obj as ShadowConcreteMethodNode; if (methodNode != null) { _methodsGenerated.Add(methodNode.Method); if (AllMethodsCanBeReflectable) _reflectableMethods.Add(methodNode.Method); return; } var reflectableMethodNode = obj as ReflectableMethodNode; if (reflectableMethodNode != null) { _reflectableMethods.Add(reflectableMethodNode.Method); } var nonGcStaticSectionNode = obj as NonGCStaticsNode; if (nonGcStaticSectionNode != null && nonGcStaticSectionNode.HasCCtorContext) { _cctorContextsGenerated.Add(nonGcStaticSectionNode); } var gvmEntryNode = obj as TypeGVMEntriesNode; if (gvmEntryNode != null) { _typeGVMEntries.Add(gvmEntryNode); } var dictionaryNode = obj as GenericDictionaryNode; if (dictionaryNode != null) { _genericDictionariesGenerated.Add(dictionaryNode); } if (obj is StructMarshallingDataNode structMarshallingDataNode) { _typesWithStructMarshalling.Add(structMarshallingDataNode.Type); } if (obj is DelegateMarshallingDataNode delegateMarshallingDataNode) { _typesWithDelegateMarshalling.Add(delegateMarshallingDataNode.Type); } if (obj is DynamicInvokeTemplateNode dynamicInvokeTemplate) { _dynamicInvokeTemplates.Add(dynamicInvokeTemplate.Method); } if (obj is NativeLayoutTemplateMethodSignatureVertexNode templateMethodEntry) { _templateMethodEntries.Add(templateMethodEntry); } } protected virtual bool AllMethodsCanBeReflectable => false; /// <summary> /// Is a method that is reflectable a method which should be placed into the invoke map as invokable? /// </summary> public virtual bool IsReflectionInvokable(MethodDesc method) { return Internal.IL.Stubs.DynamicInvokeMethodThunk.SupportsSignature(method.Signature) && IsMethodSupportedInReflectionInvoke(method); } public static bool IsMethodSupportedInReflectionInvoke(MethodDesc method) { TypeDesc owningType = method.OwningType; // Methods on nullable are special cased in the runtime reflection if (owningType.IsNullable) return false; // Methods on arrays are special cased in the runtime reflection if (owningType.IsArray) return false; // Finalizers are not reflection invokable if (method.IsFinalizer) return false; // Static constructors are not reflection invokable if (method.IsStaticConstructor) return false; if (method.IsConstructor) { // Delegate construction is only allowed through specific IL sequences if (owningType.IsDelegate) return false; // String constructors are intrinsic and special cased in runtime reflection if (owningType.IsString) return false; } // TODO: Reflection invoking static virtual methods if (method.IsVirtual && method.Signature.IsStatic) return false; // Everything else can go in the mapping table. return true; } /// <summary> /// Is there a reflection invoke stub for a method that is invokable? /// </summary> public bool HasReflectionInvokeStub(MethodDesc method) { if (!IsReflectionInvokable(method)) return false; return HasReflectionInvokeStubForInvokableMethod(method); } /// <summary> /// Is there a reflection invoke stub for a method that is invokable? /// </summary> public bool ShouldMethodBeInInvokeMap(MethodDesc method) { // The current format requires us to have an MethodTable for the owning type. We might want to lift this. if (!TypeGeneratesEEType(method.OwningType)) return false; // We have a method body, we have a metadata token, but we can't get an invoke stub. Bail. if (!IsReflectionInvokable(method)) return false; return true; } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to compiled method bodies. /// </summary> public void GetDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { MetadataCategory category = GetMetadataCategory(method); if ((category & MetadataCategory.Description) != 0) { GetMetadataDependenciesDueToReflectability(ref dependencies, factory, method); } if ((category & MetadataCategory.RuntimeMapping) != 0) { if (IsReflectionInvokable(method)) { // We're going to generate a mapping table entry for this. Collect dependencies. ReflectionInvokeMapNode.AddDependenciesDueToReflectability(ref dependencies, factory, method); ReflectionInvokeSupportDependencyAlgorithm.GetDependenciesFromParamsArray(ref dependencies, factory, method); } } } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies on a virtual method. /// </summary> public virtual void GetDependenciesDueToVirtualMethodReflectability(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { } protected virtual void GetMetadataDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { // MetadataManagers can override this to provide additional dependencies caused by the emission of metadata // (E.g. dependencies caused by the method having custom attributes applied to it: making sure we compile the attribute constructor // and property setters) } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to generated EETypes. /// </summary> public void GetDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { MetadataCategory category = GetMetadataCategory(type); if ((category & MetadataCategory.Description) != 0) { GetMetadataDependenciesDueToReflectability(ref dependencies, factory, type); } if ((category & MetadataCategory.RuntimeMapping) != 0) { // We're going to generate a mapping table entry for this. Collect dependencies. // Nothing special is needed for the mapping table (we only emit the MethodTable and we already // have one, since we got this callback). But check if a child wants to do something extra. GetRuntimeMappingDependenciesDueToReflectability(ref dependencies, factory, type); } GetDependenciesDueToEETypePresence(ref dependencies, factory, type); } protected virtual void GetMetadataDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { // MetadataManagers can override this to provide additional dependencies caused by the emission of metadata // (E.g. dependencies caused by the type having custom attributes applied to it: making sure we compile the attribute constructor // and property setters) } protected virtual void GetRuntimeMappingDependenciesDueToReflectability(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { // MetadataManagers can override this to provide additional dependencies caused by the emission of a runtime // mapping for a type. } protected virtual void GetDependenciesDueToEETypePresence(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { // MetadataManagers can override this to provide additional dependencies caused by the emission of an MethodTable. } public virtual void GetConditionalDependenciesDueToEETypePresence(ref CombinedDependencyList dependencies, NodeFactory factory, TypeDesc type) { // MetadataManagers can override this to provide additional dependencies caused by the presence of // an MethodTable. } public virtual bool HasConditionalDependenciesDueToEETypePresence(TypeDesc type) { return false; } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to generated RuntimeMethodHandles. /// </summary> public virtual void GetDependenciesDueToLdToken(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { // MetadataManagers can override this to provide additional dependencies caused by the presence of a // RuntimeMethodHandle data structure. } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to generated RuntimeFieldHandles. /// </summary> public virtual void GetDependenciesDueToLdToken(ref DependencyList dependencies, NodeFactory factory, FieldDesc field) { // MetadataManagers can override this to provide additional dependencies caused by the presence of a // RuntimeFieldHandle data structure. } /// <summary> /// This method is an extension point that can provide additional metadata-based dependencies to generated method bodies. /// </summary> public void GetDependenciesDueToMethodCodePresence(ref DependencyList dependencies, NodeFactory factory, MethodDesc method, MethodIL methodIL) { if (method.HasInstantiation) { ExactMethodInstantiationsNode.GetExactMethodInstantiationDependenciesForMethod(ref dependencies, factory, method); } GetDependenciesDueToTemplateTypeLoader(ref dependencies, factory, method); GetDependenciesDueToMethodCodePresenceInternal(ref dependencies, factory, method, methodIL); } public virtual void GetConditionalDependenciesDueToMethodCodePresence(ref CombinedDependencyList dependencies, NodeFactory factory, MethodDesc method) { // MetadataManagers can override this to provide additional dependencies caused by the presence of // method code. } private void GetDependenciesDueToTemplateTypeLoader(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { // TODO-SIZE: this is overly generous in the templates we create if (_blockingPolicy is FullyBlockedMetadataBlockingPolicy) return; if (method.HasInstantiation) { GenericMethodsTemplateMap.GetTemplateMethodDependencies(ref dependencies, factory, method); } else { TypeDesc owningTemplateType = method.OwningType; // Unboxing and Instantiating stubs use a different type as their template if (factory.TypeSystemContext.IsSpecialUnboxingThunk(method)) owningTemplateType = factory.TypeSystemContext.GetTargetOfSpecialUnboxingThunk(method).OwningType; GenericTypesTemplateMap.GetTemplateTypeDependencies(ref dependencies, factory, owningTemplateType); } } protected virtual void GetDependenciesDueToMethodCodePresenceInternal(ref DependencyList dependencies, NodeFactory factory, MethodDesc method, MethodIL methodIL) { // MetadataManagers can override this to provide additional dependencies caused by the presence of a // compiled method body. } /// <summary> /// Given that a method is invokable, does there exist a reflection invoke stub? /// </summary> public bool HasReflectionInvokeStubForInvokableMethod(MethodDesc method) { Debug.Assert(IsReflectionInvokable(method)); return _dynamicInvokeThunkGenerationPolicy.HasStaticInvokeThunk(method); } /// <summary> /// Given that a method is invokable, if it is inserted into the reflection invoke table /// will it use a method token to be referenced, or not? /// </summary> public abstract bool WillUseMetadataTokenToReferenceMethod(MethodDesc method); /// <summary> /// Given that a method is invokable, if it is inserted into the reflection invoke table /// will it use a field token to be referenced, or not? /// </summary> public abstract bool WillUseMetadataTokenToReferenceField(FieldDesc field); /// <summary> /// Gets a stub that can be used to reflection-invoke a method with a given signature. /// </summary> public abstract MethodDesc GetCanonicalReflectionInvokeStub(MethodDesc method); /// <summary> /// Compute the canonical instantiation of a dynamic invoke thunk needed to invoke a method /// This algorithm is shared with the runtime, so if a thunk requires generic instantiation /// to be used, it must match this algorithm, and cannot be different with different MetadataManagers /// NOTE: This function may return null in cases where an exact instantiation does not exist. (Universal Generics) /// </summary> protected MethodDesc InstantiateCanonicalDynamicInvokeMethodForMethod(MethodDesc thunk, MethodDesc method) { if (thunk.Instantiation.Length == 0) { // nothing to instantiate return thunk; } MethodSignature sig = method.Signature; TypeSystemContext context = method.Context; // // Instantiate the generic thunk over the parameters and the return type of the target method // TypeDesc[] instantiation = Internal.IL.Stubs.DynamicInvokeMethodThunk.GetThunkInstantiationForMethod(method); Debug.Assert(thunk.Instantiation.Length == instantiation.Length); // Check if at least one of the instantiation arguments is a universal canonical type, and if so, we // won't create a dynamic invoker instantiation. The arguments will be interpreted at runtime by the // calling convention converter during the dynamic invocation foreach (TypeDesc type in instantiation) { if (type.IsCanonicalSubtype(CanonicalFormKind.Universal)) return null; } // If the thunk ends up being shared code, return the canonical method body. // The concrete dictionary for the thunk will be built at runtime and is not interesting for the compiler. Instantiation canonInstantiation = context.ConvertInstantiationToCanonForm(new Instantiation(instantiation), CanonicalFormKind.Specific); MethodDesc instantiatedDynamicInvokeMethod = thunk.Context.GetInstantiatedMethod(thunk, canonInstantiation); return instantiatedDynamicInvokeMethod; } protected void EnsureMetadataGenerated(NodeFactory factory) { if (_metadataBlob != null) return; ComputeMetadata(factory, out _metadataBlob, out _typeMappings, out _methodMappings, out _fieldMappings, out _stackTraceMappings); } void ICompilationRootProvider.AddCompilationRoots(IRootingServiceProvider rootProvider) { // MetadataManagers can override this to provide metadata compilation roots that need to be added to the graph ahead of time. // (E.g. reflection roots computed by IL analyzers, or non-compilation-based roots) } protected abstract void ComputeMetadata(NodeFactory factory, out byte[] metadataBlob, out List<MetadataMapping<MetadataType>> typeMappings, out List<MetadataMapping<MethodDesc>> methodMappings, out List<MetadataMapping<FieldDesc>> fieldMappings, out List<MetadataMapping<MethodDesc>> stackTraceMapping); protected MetadataRecord CreateStackTraceRecord(Metadata.MetadataTransform transform, MethodDesc method) { // In the metadata, we only represent the generic definition MethodDesc methodToGenerateMetadataFor = method.GetTypicalMethodDefinition(); MetadataRecord record = transform.HandleQualifiedMethod(methodToGenerateMetadataFor); // If we're generating a MemberReference to a method on a generic type, the owning type // should appear as if instantiated over its formals TypeDesc owningTypeToGenerateMetadataFor = methodToGenerateMetadataFor.OwningType; if (owningTypeToGenerateMetadataFor.HasInstantiation && record is MemberReference memberRefRecord && memberRefRecord.Parent is TypeReference) { List<MetadataRecord> genericArgs = new List<MetadataRecord>(); foreach (Internal.TypeSystem.Ecma.EcmaGenericParameter genericParam in owningTypeToGenerateMetadataFor.Instantiation) { genericArgs.Add(new TypeReference { TypeName = (ConstantStringValue)genericParam.Name, }); } memberRefRecord.Parent = new TypeSpecification { Signature = new TypeInstantiationSignature { GenericType = memberRefRecord.Parent, GenericTypeArguments = genericArgs, } }; } // As a twist, instantiated generic methods appear as if instantiated over their formals. if (methodToGenerateMetadataFor.HasInstantiation) { var methodInst = new MethodInstantiation { Method = record, }; methodInst.GenericTypeArguments.Capacity = methodToGenerateMetadataFor.Instantiation.Length; foreach (Internal.TypeSystem.Ecma.EcmaGenericParameter typeArgument in methodToGenerateMetadataFor.Instantiation) { var genericParam = new TypeReference { TypeName = (ConstantStringValue)typeArgument.Name, }; methodInst.GenericTypeArguments.Add(genericParam); } record = methodInst; } return record; } /// <summary> /// Returns a set of modules that will get some metadata emitted into the output module /// </summary> public abstract IEnumerable<ModuleDesc> GetCompilationModulesWithMetadata(); public byte[] GetMetadataBlob(NodeFactory factory) { EnsureMetadataGenerated(factory); return _metadataBlob; } public IEnumerable<MetadataMapping<MetadataType>> GetTypeDefinitionMapping(NodeFactory factory) { EnsureMetadataGenerated(factory); return _typeMappings; } public IEnumerable<MetadataMapping<MethodDesc>> GetMethodMapping(NodeFactory factory) { EnsureMetadataGenerated(factory); return _methodMappings; } public IEnumerable<MetadataMapping<FieldDesc>> GetFieldMapping(NodeFactory factory) { EnsureMetadataGenerated(factory); return _fieldMappings; } public IEnumerable<MetadataMapping<MethodDesc>> GetStackTraceMapping(NodeFactory factory) { EnsureMetadataGenerated(factory); return _stackTraceMappings; } internal IEnumerable<NonGCStaticsNode> GetCctorContextMapping() { return _cctorContextsGenerated; } internal IEnumerable<TypeGVMEntriesNode> GetTypeGVMEntries() { return _typeGVMEntries; } internal IReadOnlyCollection<GenericDictionaryNode> GetCompiledGenericDictionaries() { return _genericDictionariesGenerated; } internal IEnumerable<DefType> GetTypesWithStructMarshalling() { return _typesWithStructMarshalling; } internal IEnumerable<DefType> GetTypesWithDelegateMarshalling() { return _typesWithDelegateMarshalling; } public IEnumerable<MethodDesc> GetCompiledMethods() { return _methodsGenerated; } public IEnumerable<MethodDesc> GetReflectableMethods() { return _reflectableMethods; } internal IEnumerable<IMethodBodyNode> GetCompiledMethodBodies() { return _methodBodiesGenerated; } internal bool TypeGeneratesEEType(TypeDesc type) { return _typesWithEETypesGenerated.Contains(type); } internal IEnumerable<TypeDesc> GetTypesWithEETypes() { return _typesWithEETypesGenerated; } internal IEnumerable<TypeDesc> GetTypesWithConstructedEETypes() { return _typesWithConstructedEETypesGenerated; } internal IEnumerable<MethodDesc> GetDynamicInvokeTemplateMethods() { return _dynamicInvokeTemplates; } internal IEnumerable<NativeLayoutTemplateMethodSignatureVertexNode> GetTemplateMethodEntries() { return _templateMethodEntries; } public bool IsReflectionBlocked(TypeDesc type) { switch (type.Category) { case TypeFlags.SzArray: case TypeFlags.Array: case TypeFlags.Pointer: case TypeFlags.ByRef: return IsReflectionBlocked(((ParameterizedType)type).ParameterType); case TypeFlags.FunctionPointer: MethodSignature pointerSignature = ((FunctionPointerType)type).Signature; for (int i = 0; i < pointerSignature.Length; i++) if (IsReflectionBlocked(pointerSignature[i])) return true; return IsReflectionBlocked(pointerSignature.ReturnType); default: Debug.Assert(type.IsDefType); TypeDesc typeDefinition = type.GetTypeDefinition(); if (type != typeDefinition) { if (_blockingPolicy.IsBlocked((MetadataType)typeDefinition)) return true; if (IsReflectionBlocked(type.Instantiation)) return true; return false; } return _blockingPolicy.IsBlocked((MetadataType)type); } } protected bool IsReflectionBlocked(Instantiation instantiation) { foreach (TypeDesc type in instantiation) { if (IsReflectionBlocked(type) && !type.IsCanonicalDefinitionType(CanonicalFormKind.Any)) return true; } return false; } public bool IsReflectionBlocked(FieldDesc field) { FieldDesc typicalFieldDefinition = field.GetTypicalFieldDefinition(); if (typicalFieldDefinition != field && IsReflectionBlocked(field.OwningType.Instantiation)) { return true; } return _blockingPolicy.IsBlocked(typicalFieldDefinition); } public bool IsReflectionBlocked(MethodDesc method) { MethodDesc methodDefinition = method.GetMethodDefinition(); if (method != methodDefinition && IsReflectionBlocked(method.Instantiation)) { return true; } MethodDesc typicalMethodDefinition = methodDefinition.GetTypicalMethodDefinition(); if (typicalMethodDefinition != methodDefinition && IsReflectionBlocked(method.OwningType.Instantiation)) { return true; } return _blockingPolicy.IsBlocked(typicalMethodDefinition); } public bool IsManifestResourceBlocked(ModuleDesc module, string resourceName) { return _resourceBlockingPolicy.IsManifestResourceBlocked(module, resourceName); } public bool CanGenerateMetadata(MetadataType type) { return (GetMetadataCategory(type) & MetadataCategory.Description) != 0; } public bool CanGenerateMetadata(MethodDesc method) { Debug.Assert(method.IsTypicalMethodDefinition); return (GetMetadataCategory(method) & MetadataCategory.Description) != 0; } public bool CanGenerateMetadata(FieldDesc field) { Debug.Assert(field.IsTypicalFieldDefinition); return (GetMetadataCategory(field) & MetadataCategory.Description) != 0; } /// <summary> /// Gets the metadata category for a compiled method body in the current compilation. /// The method will only get called with '<paramref name="method"/>' that has a compiled method body /// in this compilation. /// Note that if this method doesn't return <see cref="MetadataCategory.Description"/>, it doesn't mean /// that the method never has metadata. The metadata might just be generated in a different compilation. /// </summary> protected abstract MetadataCategory GetMetadataCategory(MethodDesc method); /// <summary> /// Gets the metadata category for a generated type in the current compilation. /// The method can assume it will only get called with '<paramref name="type"/>' that has an MethodTable generated /// in the current compilation. /// Note that if this method doesn't return <see cref="MetadataCategory.Description"/>, it doesn't mean /// that the method never has metadata. The metadata might just be generated in a different compilation. /// </summary> protected abstract MetadataCategory GetMetadataCategory(TypeDesc type); protected abstract MetadataCategory GetMetadataCategory(FieldDesc field); public virtual void GetDependenciesDueToAccess(ref DependencyList dependencies, NodeFactory factory, MethodIL methodIL, MethodDesc calledMethod) { } public virtual void GetDependenciesDueToAccess(ref DependencyList dependencies, NodeFactory factory, MethodIL methodIL, FieldDesc writtenField) { } public virtual DependencyList GetDependenciesForCustomAttribute(NodeFactory factory, MethodDesc attributeCtor, CustomAttributeValue decodedValue) { return null; } public virtual void GetDependenciesForGenericDictionary(ref DependencyList dependencies, NodeFactory factory, MethodDesc method) { } public virtual void GetDependenciesForGenericDictionary(ref DependencyList dependencies, NodeFactory factory, TypeDesc type) { } public virtual void NoteOverridingMethod(MethodDesc baseMethod, MethodDesc overridingMethod) { } } public struct MetadataMapping<TEntity> { public readonly TEntity Entity; public readonly int MetadataHandle; public MetadataMapping(TEntity entity, int metadataHandle) { Entity = entity; MetadataHandle = metadataHandle; } } [Flags] public enum MetadataCategory { None = 0x00, Description = 0x01, RuntimeMapping = 0x02, } }
1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/coreclr/tools/aot/ILCompiler/Program.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using Internal.IL; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; using Internal.CommandLine; using Debug = System.Diagnostics.Debug; using InstructionSet = Internal.JitInterface.InstructionSet; namespace ILCompiler { internal class Program { private const string DefaultSystemModule = "System.Private.CoreLib"; private Dictionary<string, string> _inputFilePaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private Dictionary<string, string> _referenceFilePaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private string _outputFilePath; private bool _isVerbose; private string _dgmlLogFileName; private bool _generateFullDgmlLog; private string _scanDgmlLogFileName; private bool _generateFullScanDgmlLog; private TargetArchitecture _targetArchitecture; private string _targetArchitectureStr; private TargetOS _targetOS; private string _targetOSStr; private OptimizationMode _optimizationMode; private bool _enableDebugInfo; private string _ilDump; private string _systemModuleName = DefaultSystemModule; private bool _multiFile; private bool _nativeLib; private string _exportsFile; private bool _useScanner; private bool _noScanner; private bool _preinitStatics; private bool _noPreinitStatics; private bool _emitStackTraceData; private string _mapFileName; private string _metadataLogFileName; private bool _noMetadataBlocking; private bool _disableReflection; private bool _completeTypesMetadata; private bool _reflectedOnly; private bool _scanReflection; private bool _methodBodyFolding; private int _parallelism = Environment.ProcessorCount; private string _instructionSet; private string _guard; private int _maxGenericCycle = CompilerTypeSystemContext.DefaultGenericCycleCutoffPoint; private bool _useDwarf5; private string _jitPath; private string _singleMethodTypeName; private string _singleMethodName; private IReadOnlyList<string> _singleMethodGenericArgs; private IReadOnlyList<string> _codegenOptions = Array.Empty<string>(); private IReadOnlyList<string> _rdXmlFilePaths = Array.Empty<string>(); private IReadOnlyList<string> _initAssemblies = Array.Empty<string>(); private IReadOnlyList<string> _appContextSwitches = Array.Empty<string>(); private IReadOnlyList<string> _runtimeOptions = Array.Empty<string>(); private IReadOnlyList<string> _featureSwitches = Array.Empty<string>(); private IReadOnlyList<string> _suppressedWarnings = Array.Empty<string>(); private IReadOnlyList<string> _directPInvokes = Array.Empty<string>(); private IReadOnlyList<string> _directPInvokeLists = Array.Empty<string>(); private bool _resilient; private IReadOnlyList<string> _rootedAssemblies = Array.Empty<string>(); private IReadOnlyList<string> _conditionallyRootedAssemblies = Array.Empty<string>(); private IReadOnlyList<string> _trimmedAssemblies = Array.Empty<string>(); private bool _rootDefaultAssemblies; public IReadOnlyList<string> _mibcFilePaths = Array.Empty<string>(); private IReadOnlyList<string> _singleWarnEnabledAssemblies = Array.Empty<string>(); private IReadOnlyList<string> _singleWarnDisabledAssemblies = Array.Empty<string>(); private bool _singleWarn; private string _makeReproPath; private bool _help; private Program() { } private void Help(string helpText) { Console.WriteLine(); Console.Write("Microsoft (R) .NET Native IL Compiler"); Console.Write(" "); Console.Write(typeof(Program).GetTypeInfo().Assembly.GetName().Version); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(helpText); } private void InitializeDefaultOptions() { // We could offer this as a command line option, but then we also need to // load a different RyuJIT, so this is a future nice to have... if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) _targetOS = TargetOS.Windows; else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) _targetOS = TargetOS.Linux; else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) _targetOS = TargetOS.OSX; else throw new NotImplementedException(); switch (RuntimeInformation.ProcessArchitecture) { case Architecture.X86: _targetArchitecture = TargetArchitecture.X86; break; case Architecture.X64: _targetArchitecture = TargetArchitecture.X64; break; case Architecture.Arm: _targetArchitecture = TargetArchitecture.ARM; break; case Architecture.Arm64: _targetArchitecture = TargetArchitecture.ARM64; break; default: throw new NotImplementedException(); } // Workaround for https://github.com/dotnet/corefx/issues/25267 // If pointer size is 8, we're obviously not an X86 process... if (_targetArchitecture == TargetArchitecture.X86 && IntPtr.Size == 8) _targetArchitecture = TargetArchitecture.X64; } private ArgumentSyntax ParseCommandLine(string[] args) { IReadOnlyList<string> inputFiles = Array.Empty<string>(); IReadOnlyList<string> referenceFiles = Array.Empty<string>(); bool optimize = false; bool optimizeSpace = false; bool optimizeTime = false; bool waitForDebugger = false; AssemblyName name = typeof(Program).GetTypeInfo().Assembly.GetName(); ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax => { syntax.ApplicationName = name.Name.ToString(); // HandleHelp writes to error, fails fast with crash dialog and lacks custom formatting. syntax.HandleHelp = false; syntax.HandleErrors = true; syntax.DefineOption("h|help", ref _help, "Help message for ILC"); syntax.DefineOptionList("r|reference", ref referenceFiles, "Reference file(s) for compilation"); syntax.DefineOption("o|out", ref _outputFilePath, "Output file path"); syntax.DefineOption("O", ref optimize, "Enable optimizations"); syntax.DefineOption("Os", ref optimizeSpace, "Enable optimizations, favor code space"); syntax.DefineOption("Ot", ref optimizeTime, "Enable optimizations, favor code speed"); syntax.DefineOptionList("m|mibc", ref _mibcFilePaths, "Mibc file(s) for profile guided optimization"); ; syntax.DefineOption("g", ref _enableDebugInfo, "Emit debugging information"); syntax.DefineOption("gdwarf-5", ref _useDwarf5, "Generate source-level debug information with dwarf version 5"); syntax.DefineOption("nativelib", ref _nativeLib, "Compile as static or shared library"); syntax.DefineOption("exportsfile", ref _exportsFile, "File to write exported method definitions"); syntax.DefineOption("dgmllog", ref _dgmlLogFileName, "Save result of dependency analysis as DGML"); syntax.DefineOption("fulllog", ref _generateFullDgmlLog, "Save detailed log of dependency analysis"); syntax.DefineOption("scandgmllog", ref _scanDgmlLogFileName, "Save result of scanner dependency analysis as DGML"); syntax.DefineOption("scanfulllog", ref _generateFullScanDgmlLog, "Save detailed log of scanner dependency analysis"); syntax.DefineOption("verbose", ref _isVerbose, "Enable verbose logging"); syntax.DefineOption("systemmodule", ref _systemModuleName, "System module name (default: System.Private.CoreLib)"); syntax.DefineOption("multifile", ref _multiFile, "Compile only input files (do not compile referenced assemblies)"); syntax.DefineOption("waitfordebugger", ref waitForDebugger, "Pause to give opportunity to attach debugger"); syntax.DefineOption("resilient", ref _resilient, "Ignore unresolved types, methods, and assemblies. Defaults to false"); syntax.DefineOptionList("codegenopt", ref _codegenOptions, "Define a codegen option"); syntax.DefineOptionList("rdxml", ref _rdXmlFilePaths, "RD.XML file(s) for compilation"); syntax.DefineOption("map", ref _mapFileName, "Generate a map file"); syntax.DefineOption("metadatalog", ref _metadataLogFileName, "Generate a metadata log file"); syntax.DefineOption("nometadatablocking", ref _noMetadataBlocking, "Ignore metadata blocking for internal implementation details"); syntax.DefineOption("disablereflection", ref _disableReflection, "Disable generation of reflection metadata"); syntax.DefineOption("completetypemetadata", ref _completeTypesMetadata, "Generate complete metadata for types"); syntax.DefineOption("reflectedonly", ref _reflectedOnly, "Generate metadata only for reflected members"); syntax.DefineOption("scanreflection", ref _scanReflection, "Scan IL for reflection patterns"); syntax.DefineOption("scan", ref _useScanner, "Use IL scanner to generate optimized code (implied by -O)"); syntax.DefineOption("noscan", ref _noScanner, "Do not use IL scanner to generate optimized code"); syntax.DefineOption("ildump", ref _ilDump, "Dump IL assembly listing for compiler-generated IL"); syntax.DefineOption("stacktracedata", ref _emitStackTraceData, "Emit data to support generating stack trace strings at runtime"); syntax.DefineOption("methodbodyfolding", ref _methodBodyFolding, "Fold identical method bodies"); syntax.DefineOptionList("initassembly", ref _initAssemblies, "Assembly(ies) with a library initializer"); syntax.DefineOptionList("appcontextswitch", ref _appContextSwitches, "System.AppContext switches to set (format: 'Key=Value')"); syntax.DefineOptionList("feature", ref _featureSwitches, "Feature switches to apply (format: 'Namespace.Name=[true|false]'"); syntax.DefineOptionList("runtimeopt", ref _runtimeOptions, "Runtime options to set"); syntax.DefineOption("parallelism", ref _parallelism, "Maximum number of threads to use during compilation"); syntax.DefineOption("instructionset", ref _instructionSet, "Instruction set to allow or disallow"); syntax.DefineOption("guard", ref _guard, "Enable mitigations. Options: 'cf': CFG (Control Flow Guard, Windows only)"); syntax.DefineOption("preinitstatics", ref _preinitStatics, "Interpret static constructors at compile time if possible (implied by -O)"); syntax.DefineOption("nopreinitstatics", ref _noPreinitStatics, "Do not interpret static constructors at compile time"); syntax.DefineOptionList("nowarn", ref _suppressedWarnings, "Disable specific warning messages"); syntax.DefineOption("singlewarn", ref _singleWarn, "Generate single AOT/trimming warning per assembly"); syntax.DefineOptionList("singlewarnassembly", ref _singleWarnEnabledAssemblies, "Generate single AOT/trimming warning for given assembly"); syntax.DefineOptionList("nosinglewarnassembly", ref _singleWarnDisabledAssemblies, "Expand AOT/trimming warnings for given assembly"); syntax.DefineOptionList("directpinvoke", ref _directPInvokes, "PInvoke to call directly"); syntax.DefineOptionList("directpinvokelist", ref _directPInvokeLists, "File with list of PInvokes to call directly"); syntax.DefineOption("maxgenericcycle", ref _maxGenericCycle, "Max depth of generic cycle"); syntax.DefineOptionList("root", ref _rootedAssemblies, "Fully generate given assembly"); syntax.DefineOptionList("conditionalroot", ref _conditionallyRootedAssemblies, "Fully generate given assembly if it's used"); syntax.DefineOptionList("trim", ref _trimmedAssemblies, "Trim the specified assembly"); syntax.DefineOption("defaultrooting", ref _rootDefaultAssemblies, "Root assemblies that are not marked [IsTrimmable]"); syntax.DefineOption("targetarch", ref _targetArchitectureStr, "Target architecture for cross compilation"); syntax.DefineOption("targetos", ref _targetOSStr, "Target OS for cross compilation"); syntax.DefineOption("jitpath", ref _jitPath, "Path to JIT compiler library"); syntax.DefineOption("singlemethodtypename", ref _singleMethodTypeName, "Single method compilation: assembly-qualified name of the owning type"); syntax.DefineOption("singlemethodname", ref _singleMethodName, "Single method compilation: name of the method"); syntax.DefineOptionList("singlemethodgenericarg", ref _singleMethodGenericArgs, "Single method compilation: generic arguments to the method"); syntax.DefineOption("make-repro-path", ref _makeReproPath, "Path where to place a repro package"); syntax.DefineParameterList("in", ref inputFiles, "Input file(s) to compile"); }); if (waitForDebugger) { Console.WriteLine("Waiting for debugger to attach. Press ENTER to continue"); Console.ReadLine(); } _optimizationMode = OptimizationMode.None; if (optimizeSpace) { if (optimizeTime) Console.WriteLine("Warning: overriding -Ot with -Os"); _optimizationMode = OptimizationMode.PreferSize; } else if (optimizeTime) _optimizationMode = OptimizationMode.PreferSpeed; else if (optimize) _optimizationMode = OptimizationMode.Blended; foreach (var input in inputFiles) Helpers.AppendExpandedPaths(_inputFilePaths, input, true); foreach (var reference in referenceFiles) Helpers.AppendExpandedPaths(_referenceFilePaths, reference, false); if (_makeReproPath != null) { // Create a repro package in the specified path // This package will have the set of input files needed for compilation // + the original command line arguments // + a rsp file that should work to directly run out of the zip file Helpers.MakeReproPackage(_makeReproPath, _outputFilePath, args, argSyntax, new[] { "-r", "-m", "--rdxml", "--directpinvokelist" }); } return argSyntax; } private IReadOnlyCollection<MethodDesc> CreateInitializerList(CompilerTypeSystemContext context) { List<ModuleDesc> assembliesWithInitalizers = new List<ModuleDesc>(); // Build a list of assemblies that have an initializer that needs to run before // any user code runs. foreach (string initAssemblyName in _initAssemblies) { ModuleDesc assembly = context.ResolveAssembly(new AssemblyName(initAssemblyName), throwIfNotFound: true); assembliesWithInitalizers.Add(assembly); } var libraryInitializers = new LibraryInitializers(context, assembliesWithInitalizers); List<MethodDesc> initializerList = new List<MethodDesc>(libraryInitializers.LibraryInitializerMethods); // If there are any AppContext switches the user wishes to enable, generate code that sets them. if (_appContextSwitches.Count > 0) { MethodDesc appContextInitMethod = new Internal.IL.Stubs.StartupCode.AppContextInitializerMethod( context.GeneratedAssembly.GetGlobalModuleType(), _appContextSwitches); initializerList.Add(appContextInitMethod); } return initializerList; } private int Run(string[] args) { InitializeDefaultOptions(); ArgumentSyntax syntax = ParseCommandLine(args); if (_help) { Help(syntax.GetHelpText()); return 1; } if (_outputFilePath == null) throw new CommandLineException("Output filename must be specified (/out <file>)"); // // Set target Architecture and OS // if (_targetArchitectureStr != null) { if (_targetArchitectureStr.Equals("x86", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.X86; else if (_targetArchitectureStr.Equals("x64", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.X64; else if (_targetArchitectureStr.Equals("arm", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.ARM; else if (_targetArchitectureStr.Equals("armel", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.ARM; else if (_targetArchitectureStr.Equals("arm64", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.ARM64; else throw new CommandLineException("Target architecture is not supported"); } if (_targetOSStr != null) { if (_targetOSStr.Equals("windows", StringComparison.OrdinalIgnoreCase)) _targetOS = TargetOS.Windows; else if (_targetOSStr.Equals("linux", StringComparison.OrdinalIgnoreCase)) _targetOS = TargetOS.Linux; else if (_targetOSStr.Equals("osx", StringComparison.OrdinalIgnoreCase)) _targetOS = TargetOS.OSX; else throw new CommandLineException("Target OS is not supported"); } InstructionSetSupportBuilder instructionSetSupportBuilder = new InstructionSetSupportBuilder(_targetArchitecture); // The runtime expects certain baselines that the codegen can assume as well. if ((_targetArchitecture == TargetArchitecture.X86) || (_targetArchitecture == TargetArchitecture.X64)) { instructionSetSupportBuilder.AddSupportedInstructionSet("sse"); instructionSetSupportBuilder.AddSupportedInstructionSet("sse2"); } else if (_targetArchitecture == TargetArchitecture.ARM64) { instructionSetSupportBuilder.AddSupportedInstructionSet("base"); instructionSetSupportBuilder.AddSupportedInstructionSet("neon"); } if (_instructionSet != null) { List<string> instructionSetParams = new List<string>(); // Normalize instruction set format to include implied +. string[] instructionSetParamsInput = _instructionSet.Split(','); for (int i = 0; i < instructionSetParamsInput.Length; i++) { string instructionSet = instructionSetParamsInput[i]; if (String.IsNullOrEmpty(instructionSet)) throw new CommandLineException("Instruction set must not be empty"); char firstChar = instructionSet[0]; if ((firstChar != '+') && (firstChar != '-')) { instructionSet = "+" + instructionSet; } instructionSetParams.Add(instructionSet); } Dictionary<string, bool> instructionSetSpecification = new Dictionary<string, bool>(); foreach (string instructionSetSpecifier in instructionSetParams) { string instructionSet = instructionSetSpecifier.Substring(1, instructionSetSpecifier.Length - 1); bool enabled = instructionSetSpecifier[0] == '+' ? true : false; if (enabled) { if (!instructionSetSupportBuilder.AddSupportedInstructionSet(instructionSet)) throw new CommandLineException($"Unrecognized instruction set '{instructionSet}'"); } else { if (!instructionSetSupportBuilder.RemoveInstructionSetSupport(instructionSet)) throw new CommandLineException($"Unrecognized instruction set '{instructionSet}'"); } } } instructionSetSupportBuilder.ComputeInstructionSetFlags(out var supportedInstructionSet, out var unsupportedInstructionSet, (string specifiedInstructionSet, string impliedInstructionSet) => throw new CommandLineException(String.Format("Unsupported combination of instruction sets: {0}/{1}", specifiedInstructionSet, impliedInstructionSet))); InstructionSetSupportBuilder optimisticInstructionSetSupportBuilder = new InstructionSetSupportBuilder(_targetArchitecture); // Optimistically assume some instruction sets are present. if ((_targetArchitecture == TargetArchitecture.X86) || (_targetArchitecture == TargetArchitecture.X64)) { // We set these hardware features as enabled always, as most // of hardware in the wild supports them. Note that we do not indicate support for AVX, or any other // instruction set which uses the VEX encodings as the presence of those makes otherwise acceptable // code be unusable on hardware which does not support VEX encodings, as well as emulators that do not // support AVX instructions. // // The compiler is able to generate runtime IsSupported checks for the following instruction sets. optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("sse4.1"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("sse4.2"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("ssse3"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("aes"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("pclmul"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("popcnt"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("lzcnt"); // If AVX was enabled, we can opportunistically enable FMA/BMI/VNNI Debug.Assert(InstructionSet.X64_AVX == InstructionSet.X86_AVX); if (supportedInstructionSet.HasInstructionSet(InstructionSet.X64_AVX)) { optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("fma"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("bmi"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("bmi2"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("avxvnni"); } } else if (_targetArchitecture == TargetArchitecture.ARM64) { optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("aes"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("crc"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("sha1"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("sha2"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("lse"); } optimisticInstructionSetSupportBuilder.ComputeInstructionSetFlags(out var optimisticInstructionSet, out _, (string specifiedInstructionSet, string impliedInstructionSet) => throw new NotSupportedException()); optimisticInstructionSet.Remove(unsupportedInstructionSet); optimisticInstructionSet.Add(supportedInstructionSet); var instructionSetSupport = new InstructionSetSupport(supportedInstructionSet, unsupportedInstructionSet, optimisticInstructionSet, InstructionSetSupportBuilder.GetNonSpecifiableInstructionSetsForArch(_targetArchitecture), _targetArchitecture); bool supportsReflection = !_disableReflection && _systemModuleName == DefaultSystemModule; // // Initialize type system context // SharedGenericsMode genericsMode = SharedGenericsMode.CanonicalReferenceTypes; var simdVectorLength = instructionSetSupport.GetVectorTSimdVector(); var targetAbi = TargetAbi.CoreRT; var targetDetails = new TargetDetails(_targetArchitecture, _targetOS, targetAbi, simdVectorLength); CompilerTypeSystemContext typeSystemContext = new CompilerTypeSystemContext(targetDetails, genericsMode, supportsReflection ? DelegateFeature.All : 0, _maxGenericCycle); // // TODO: To support our pre-compiled test tree, allow input files that aren't managed assemblies since // some tests contain a mixture of both managed and native binaries. // // See: https://github.com/dotnet/corert/issues/2785 // // When we undo this this hack, replace this foreach with // typeSystemContext.InputFilePaths = _inputFilePaths; // Dictionary<string, string> inputFilePaths = new Dictionary<string, string>(); foreach (var inputFile in _inputFilePaths) { try { var module = typeSystemContext.GetModuleFromPath(inputFile.Value); inputFilePaths.Add(inputFile.Key, inputFile.Value); } catch (TypeSystemException.BadImageFormatException) { // Keep calm and carry on. } } typeSystemContext.InputFilePaths = inputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; if (!typeSystemContext.InputFilePaths.ContainsKey(_systemModuleName) && !typeSystemContext.ReferenceFilePaths.ContainsKey(_systemModuleName)) throw new CommandLineException($"System module {_systemModuleName} does not exists. Make sure that you specify --systemmodule"); typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(_systemModuleName)); if (typeSystemContext.InputFilePaths.Count == 0) throw new CommandLineException("No input files specified"); SecurityMitigationOptions securityMitigationOptions = 0; if (StringComparer.OrdinalIgnoreCase.Equals(_guard, "cf")) { if (_targetOS != TargetOS.Windows) { throw new CommandLineException($"Control flow guard only available on Windows"); } securityMitigationOptions = SecurityMitigationOptions.ControlFlowGuardAnnotations; } else if (!String.IsNullOrEmpty(_guard)) { throw new CommandLineException($"Unrecognized mitigation option '{_guard}'"); } // // Initialize compilation group and compilation roots // // Single method mode? MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext); CompilationModuleGroup compilationGroup; List<ICompilationRootProvider> compilationRoots = new List<ICompilationRootProvider>(); if (singleMethod != null) { // Compiling just a single method compilationGroup = new SingleMethodCompilationModuleGroup(singleMethod); compilationRoots.Add(new SingleMethodRootProvider(singleMethod)); } else { // Either single file, or multifile library, or multifile consumption. EcmaModule entrypointModule = null; bool systemModuleIsInputModule = false; foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (module.PEReader.PEHeaders.IsExe) { if (entrypointModule != null) throw new Exception("Multiple EXE modules"); entrypointModule = module; } if (module == typeSystemContext.SystemModule) systemModuleIsInputModule = true; compilationRoots.Add(new ExportedMethodsRootProvider(module)); } if (entrypointModule != null) { compilationRoots.Add(new MainMethodRootProvider(entrypointModule, CreateInitializerList(typeSystemContext))); compilationRoots.Add(new RuntimeConfigurationRootProvider(_runtimeOptions)); compilationRoots.Add(new ExpectedIsaFeaturesRootProvider(instructionSetSupport)); } if (_multiFile) { List<EcmaModule> inputModules = new List<EcmaModule>(); foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (entrypointModule == null) { // This is a multifile production build - we need to root all methods compilationRoots.Add(new LibraryRootProvider(module)); } inputModules.Add(module); } compilationGroup = new MultiFileSharedCompilationModuleGroup(typeSystemContext, inputModules); } else { if (entrypointModule == null && !_nativeLib) throw new Exception("No entrypoint module"); if (!systemModuleIsInputModule) compilationRoots.Add(new ExportedMethodsRootProvider((EcmaModule)typeSystemContext.SystemModule)); compilationGroup = new SingleFileCompilationModuleGroup(); } if (_nativeLib) { // Set owning module of generated native library startup method to compiler generated module, // to ensure the startup method is included in the object file during multimodule mode build compilationRoots.Add(new NativeLibraryInitializerRootProvider(typeSystemContext.GeneratedAssembly, CreateInitializerList(typeSystemContext))); compilationRoots.Add(new RuntimeConfigurationRootProvider(_runtimeOptions)); compilationRoots.Add(new ExpectedIsaFeaturesRootProvider(instructionSetSupport)); } foreach (var rdXmlFilePath in _rdXmlFilePaths) { compilationRoots.Add(new RdXmlRootProvider(typeSystemContext, rdXmlFilePath)); } } _rootedAssemblies = new List<string>(_rootedAssemblies.Select(a => ILLinkify(a))); _conditionallyRootedAssemblies = new List<string>(_conditionallyRootedAssemblies.Select(a => ILLinkify(a))); _trimmedAssemblies = new List<string>(_trimmedAssemblies.Select(a => ILLinkify(a))); static string ILLinkify(string rootedAssembly) { // For compatibility with IL Linker, the parameter could be a file name or an assembly name. // This is the logic IL Linker uses to decide how to interpret the string. Really. string simpleName; if (File.Exists(rootedAssembly)) simpleName = Path.GetFileNameWithoutExtension(rootedAssembly); else simpleName = rootedAssembly; return simpleName; } // Root whatever assemblies were specified on the command line foreach (var rootedAssembly in _rootedAssemblies) { // We only root the module type. The rest will fall out because we treat _rootedAssemblies // same as conditionally rooted ones and here we're fulfilling the condition ("something is used"). compilationRoots.Add( new GenericRootProvider<ModuleDesc>(typeSystemContext.GetModuleForSimpleName(rootedAssembly), (ModuleDesc module, IRootingServiceProvider rooter) => rooter.AddCompilationRoot(module.GetGlobalModuleType(), "Command line root"))); } // // Compile // CompilationBuilder builder = new RyuJitCompilationBuilder(typeSystemContext, compilationGroup); string compilationUnitPrefix = _multiFile ? System.IO.Path.GetFileNameWithoutExtension(_outputFilePath) : ""; builder.UseCompilationUnitPrefix(compilationUnitPrefix); if (_mibcFilePaths.Count > 0) ((RyuJitCompilationBuilder)builder).UseProfileData(_mibcFilePaths); if (!String.IsNullOrEmpty(_jitPath)) ((RyuJitCompilationBuilder)builder).UseJitPath(_jitPath); PInvokeILEmitterConfiguration pinvokePolicy = new ConfigurablePInvokePolicy(typeSystemContext.Target, _directPInvokes, _directPInvokeLists); ILProvider ilProvider = new CoreRTILProvider(); List<KeyValuePair<string, bool>> featureSwitches = new List<KeyValuePair<string, bool>>(); foreach (var switchPair in _featureSwitches) { string[] switchAndValue = switchPair.Split('='); if (switchAndValue.Length != 2 || !bool.TryParse(switchAndValue[1], out bool switchValue)) throw new CommandLineException($"Unexpected feature switch pair '{switchPair}'"); featureSwitches.Add(new KeyValuePair<string, bool>(switchAndValue[0], switchValue)); } ilProvider = new FeatureSwitchManager(ilProvider, featureSwitches); var logger = new Logger(Console.Out, _isVerbose, ProcessWarningCodes(_suppressedWarnings), _singleWarn, _singleWarnEnabledAssemblies, _singleWarnDisabledAssemblies); var stackTracePolicy = _emitStackTraceData ? (StackTraceEmissionPolicy)new EcmaMethodStackTraceEmissionPolicy() : new NoStackTraceEmissionPolicy(); MetadataBlockingPolicy mdBlockingPolicy; ManifestResourceBlockingPolicy resBlockingPolicy; UsageBasedMetadataGenerationOptions metadataGenerationOptions = default; if (supportsReflection) { mdBlockingPolicy = _noMetadataBlocking ? (MetadataBlockingPolicy)new NoMetadataBlockingPolicy() : new BlockedInternalsBlockingPolicy(typeSystemContext); resBlockingPolicy = new ManifestResourceBlockingPolicy(featureSwitches); metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.AnonymousTypeHeuristic; if (_completeTypesMetadata) metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.CompleteTypesOnly; if (_scanReflection) metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.ReflectionILScanning; if (_reflectedOnly) metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.ReflectedMembersOnly; if (_rootDefaultAssemblies) metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.RootDefaultAssemblies; } else { mdBlockingPolicy = new FullyBlockedMetadataBlockingPolicy(); resBlockingPolicy = new FullyBlockedManifestResourceBlockingPolicy(); } DynamicInvokeThunkGenerationPolicy invokeThunkGenerationPolicy = new DefaultDynamicInvokeThunkGenerationPolicy(); var flowAnnotations = new Dataflow.FlowAnnotations(logger, ilProvider); MetadataManager metadataManager = new UsageBasedMetadataManager( compilationGroup, typeSystemContext, mdBlockingPolicy, resBlockingPolicy, _metadataLogFileName, stackTracePolicy, invokeThunkGenerationPolicy, flowAnnotations, metadataGenerationOptions, logger, featureSwitches, _conditionallyRootedAssemblies.Concat(_rootedAssemblies), _trimmedAssemblies); InteropStateManager interopStateManager = new InteropStateManager(typeSystemContext.GeneratedAssembly); InteropStubManager interopStubManager = new UsageBasedInteropStubManager(interopStateManager, pinvokePolicy, logger); // Unless explicitly opted in at the command line, we enable scanner for retail builds by default. // We also don't do this for multifile because scanner doesn't simulate inlining (this would be // fixable by using a CompilationGroup for the scanner that has a bigger worldview, but // let's cross that bridge when we get there). bool useScanner = _useScanner || (_optimizationMode != OptimizationMode.None && !_multiFile); useScanner &= !_noScanner; // Enable static data preinitialization in optimized builds. bool preinitStatics = _preinitStatics || (_optimizationMode != OptimizationMode.None && !_multiFile); preinitStatics &= !_noPreinitStatics; var preinitManager = new PreinitializationManager(typeSystemContext, compilationGroup, ilProvider, preinitStatics); builder .UseILProvider(ilProvider) .UsePreinitializationManager(preinitManager); ILScanResults scanResults = null; if (useScanner) { ILScannerBuilder scannerBuilder = builder.GetILScannerBuilder() .UseCompilationRoots(compilationRoots) .UseMetadataManager(metadataManager) .UseParallelism(_parallelism) .UseInteropStubManager(interopStubManager); if (_scanDgmlLogFileName != null) scannerBuilder.UseDependencyTracking(_generateFullScanDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); IILScanner scanner = scannerBuilder.ToILScanner(); scanResults = scanner.Scan(); metadataManager = ((UsageBasedMetadataManager)metadataManager).ToAnalysisBasedMetadataManager(); interopStubManager = scanResults.GetInteropStubManager(interopStateManager, pinvokePolicy); } DebugInformationProvider debugInfoProvider = _enableDebugInfo ? (_ilDump == null ? new DebugInformationProvider() : new ILAssemblyGeneratingMethodDebugInfoProvider(_ilDump, new EcmaOnlyDebugInformationProvider())) : new NullDebugInformationProvider(); DependencyTrackingLevel trackingLevel = _dgmlLogFileName == null ? DependencyTrackingLevel.None : (_generateFullDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); compilationRoots.Add(metadataManager); compilationRoots.Add(interopStubManager); builder .UseInstructionSetSupport(instructionSetSupport) .UseBackendOptions(_codegenOptions) .UseMethodBodyFolding(enable: _methodBodyFolding) .UseParallelism(_parallelism) .UseMetadataManager(metadataManager) .UseInteropStubManager(interopStubManager) .UseLogger(logger) .UseDependencyTracking(trackingLevel) .UseCompilationRoots(compilationRoots) .UseOptimizationMode(_optimizationMode) .UseSecurityMitigationOptions(securityMitigationOptions) .UseDebugInfoProvider(debugInfoProvider) .UseDwarf5(_useDwarf5); if (scanResults != null) { // If we have a scanner, feed the vtable analysis results to the compilation. // This could be a command line switch if we really wanted to. builder.UseVTableSliceProvider(scanResults.GetVTableLayoutInfo()); // If we have a scanner, feed the generic dictionary results to the compilation. // This could be a command line switch if we really wanted to. builder.UseGenericDictionaryLayoutProvider(scanResults.GetDictionaryLayoutInfo()); // If we have a scanner, we can drive devirtualization using the information // we collected at scanning time (effectively sealing unsealed types if possible). // This could be a command line switch if we really wanted to. builder.UseDevirtualizationManager(scanResults.GetDevirtualizationManager()); // If we use the scanner's result, we need to consult it to drive inlining. // This prevents e.g. devirtualizing and inlining methods on types that were // never actually allocated. builder.UseInliningPolicy(scanResults.GetInliningPolicy()); // Use an error provider that prevents us from re-importing methods that failed // to import with an exception during scanning phase. We would see the same failure during // compilation, but before RyuJIT gets there, it might ask questions that we don't // have answers for because we didn't scan the entire method. builder.UseMethodImportationErrorProvider(scanResults.GetMethodImportationErrorProvider()); } builder.UseResilience(_resilient); ICompilation compilation = builder.ToCompilation(); ObjectDumper dumper = _mapFileName != null ? new ObjectDumper(_mapFileName) : null; CompilationResults compilationResults = compilation.Compile(_outputFilePath, dumper); if (_exportsFile != null) { ExportsFileWriter defFileWriter = new ExportsFileWriter(typeSystemContext, _exportsFile); foreach (var compilationRoot in compilationRoots) { if (compilationRoot is ExportedMethodsRootProvider provider) defFileWriter.AddExportedMethods(provider.ExportedMethods); } defFileWriter.EmitExportedMethods(); } typeSystemContext.LogWarnings(logger); if (_dgmlLogFileName != null) compilationResults.WriteDependencyLog(_dgmlLogFileName); if (scanResults != null) { if (_scanDgmlLogFileName != null) scanResults.WriteDependencyLog(_scanDgmlLogFileName); // If the scanner and compiler don't agree on what to compile, the outputs of the scanner might not actually be usable. // We are going to check this two ways: // 1. The methods and types generated during compilation are a subset of method and types scanned // 2. The methods and types scanned are a subset of methods and types compiled (this has a chance to hold for unoptimized builds only). // Check that methods and types generated during compilation are a subset of method and types scanned bool scanningFail = false; DiffCompilationResults(ref scanningFail, compilationResults.CompiledMethodBodies, scanResults.CompiledMethodBodies, "Methods", "compiled", "scanned", method => !(method.GetTypicalMethodDefinition() is EcmaMethod) || method.Name == "ThrowPlatformNotSupportedException" || method.Name == "ThrowArgumentOutOfRangeException"); DiffCompilationResults(ref scanningFail, compilationResults.ConstructedEETypes, scanResults.ConstructedEETypes, "EETypes", "compiled", "scanned", type => !(type.GetTypeDefinition() is EcmaType)); // If optimizations are enabled, the results will for sure not match in the other direction due to inlining, etc. // But there's at least some value in checking the scanner doesn't expand the universe too much in debug. if (_optimizationMode == OptimizationMode.None) { // Check that methods and types scanned are a subset of methods and types compiled // If we find diffs here, they're not critical, but still might be causing a Size on Disk regression. bool dummy = false; // We additionally skip methods in SIMD module because there's just too many intrisics to handle and IL scanner // doesn't expand them. They would show up as noisy diffs. DiffCompilationResults(ref dummy, scanResults.CompiledMethodBodies, compilationResults.CompiledMethodBodies, "Methods", "scanned", "compiled", method => !(method.GetTypicalMethodDefinition() is EcmaMethod) || method.OwningType.IsIntrinsic); DiffCompilationResults(ref dummy, scanResults.ConstructedEETypes, compilationResults.ConstructedEETypes, "EETypes", "scanned", "compiled", type => !(type.GetTypeDefinition() is EcmaType)); } if (scanningFail) throw new Exception("Scanning failure"); } if (debugInfoProvider is IDisposable) ((IDisposable)debugInfoProvider).Dispose(); preinitManager.LogStatistics(logger); return 0; } [System.Diagnostics.Conditional("DEBUG")] private void DiffCompilationResults<T>(ref bool result, IEnumerable<T> set1, IEnumerable<T> set2, string prefix, string set1name, string set2name, Predicate<T> filter) { HashSet<T> diff = new HashSet<T>(set1); diff.ExceptWith(set2); // TODO: move ownership of compiler-generated entities to CompilerTypeSystemContext. // https://github.com/dotnet/corert/issues/3873 diff.RemoveWhere(filter); if (diff.Count > 0) { result = true; Console.WriteLine($"*** {prefix} {set1name} but not {set2name}:"); foreach (var d in diff) { Console.WriteLine(d.ToString()); } } } private TypeDesc FindType(CompilerTypeSystemContext context, string typeName) { ModuleDesc systemModule = context.SystemModule; TypeDesc foundType = systemModule.GetTypeByCustomAttributeTypeName(typeName, false, (typeDefName, module, throwIfNotFound) => { return (MetadataType)context.GetCanonType(typeDefName) ?? CustomAttributeTypeNameParser.ResolveCustomAttributeTypeDefinitionName(typeDefName, module, throwIfNotFound); }); if (foundType == null) throw new CommandLineException($"Type '{typeName}' not found"); return foundType; } private MethodDesc CheckAndParseSingleMethodModeArguments(CompilerTypeSystemContext context) { if (_singleMethodName == null && _singleMethodTypeName == null && _singleMethodGenericArgs == null) return null; if (_singleMethodName == null || _singleMethodTypeName == null) throw new CommandLineException("Both method name and type name are required parameters for single method mode"); TypeDesc owningType = FindType(context, _singleMethodTypeName); // TODO: allow specifying signature to distinguish overloads MethodDesc method = owningType.GetMethod(_singleMethodName, null); if (method == null) throw new CommandLineException($"Method '{_singleMethodName}' not found in '{_singleMethodTypeName}'"); if (method.HasInstantiation != (_singleMethodGenericArgs != null) || (method.HasInstantiation && (method.Instantiation.Length != _singleMethodGenericArgs.Count))) { throw new CommandLineException( $"Expected {method.Instantiation.Length} generic arguments for method '{_singleMethodName}' on type '{_singleMethodTypeName}'"); } if (method.HasInstantiation) { List<TypeDesc> genericArguments = new List<TypeDesc>(); foreach (var argString in _singleMethodGenericArgs) genericArguments.Add(FindType(context, argString)); method = method.MakeInstantiatedMethod(genericArguments.ToArray()); } return method; } private static bool DumpReproArguments(CodeGenerationFailedException ex) { Console.WriteLine("To repro, add following arguments to the command line:"); MethodDesc failingMethod = ex.Method; var formatter = new CustomAttributeTypeNameFormatter((IAssemblyDesc)failingMethod.Context.SystemModule); Console.Write($"--singlemethodtypename \"{formatter.FormatName(failingMethod.OwningType, true)}\""); Console.Write($" --singlemethodname {failingMethod.Name}"); for (int i = 0; i < failingMethod.Instantiation.Length; i++) Console.Write($" --singlemethodgenericarg \"{formatter.FormatName(failingMethod.Instantiation[i], true)}\""); return false; } private static IEnumerable<int> ProcessWarningCodes(IEnumerable<string> warningCodes) { foreach (string value in warningCodes) { string[] values = value.Split(new char[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string id in values) { if (!id.StartsWith("IL", StringComparison.Ordinal) || !ushort.TryParse(id.Substring(2), out ushort code)) continue; yield return code; } } } private static int Main(string[] args) { #if DEBUG try { return new Program().Run(args); } catch (CodeGenerationFailedException ex) when (DumpReproArguments(ex)) { throw new NotSupportedException(); // Unreachable } #else try { return new Program().Run(args); } catch (Exception e) { Console.Error.WriteLine("Error: " + e.Message); Console.Error.WriteLine(e.ToString()); return 1; } #endif } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using Internal.IL; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; using Internal.CommandLine; using Debug = System.Diagnostics.Debug; using InstructionSet = Internal.JitInterface.InstructionSet; namespace ILCompiler { internal class Program { private const string DefaultSystemModule = "System.Private.CoreLib"; private Dictionary<string, string> _inputFilePaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private Dictionary<string, string> _referenceFilePaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private string _outputFilePath; private bool _isVerbose; private string _dgmlLogFileName; private bool _generateFullDgmlLog; private string _scanDgmlLogFileName; private bool _generateFullScanDgmlLog; private TargetArchitecture _targetArchitecture; private string _targetArchitectureStr; private TargetOS _targetOS; private string _targetOSStr; private OptimizationMode _optimizationMode; private bool _enableDebugInfo; private string _ilDump; private string _systemModuleName = DefaultSystemModule; private bool _multiFile; private bool _nativeLib; private string _exportsFile; private bool _useScanner; private bool _noScanner; private bool _preinitStatics; private bool _noPreinitStatics; private bool _emitStackTraceData; private string _mapFileName; private string _metadataLogFileName; private bool _noMetadataBlocking; private bool _disableReflection; private bool _completeTypesMetadata; private bool _reflectedOnly; private bool _scanReflection; private bool _methodBodyFolding; private int _parallelism = Environment.ProcessorCount; private string _instructionSet; private string _guard; private int _maxGenericCycle = CompilerTypeSystemContext.DefaultGenericCycleCutoffPoint; private bool _useDwarf5; private string _jitPath; private string _singleMethodTypeName; private string _singleMethodName; private IReadOnlyList<string> _singleMethodGenericArgs; private IReadOnlyList<string> _codegenOptions = Array.Empty<string>(); private IReadOnlyList<string> _rdXmlFilePaths = Array.Empty<string>(); private IReadOnlyList<string> _initAssemblies = Array.Empty<string>(); private IReadOnlyList<string> _appContextSwitches = Array.Empty<string>(); private IReadOnlyList<string> _runtimeOptions = Array.Empty<string>(); private IReadOnlyList<string> _featureSwitches = Array.Empty<string>(); private IReadOnlyList<string> _suppressedWarnings = Array.Empty<string>(); private IReadOnlyList<string> _directPInvokes = Array.Empty<string>(); private IReadOnlyList<string> _directPInvokeLists = Array.Empty<string>(); private bool _resilient; private IReadOnlyList<string> _rootedAssemblies = Array.Empty<string>(); private IReadOnlyList<string> _conditionallyRootedAssemblies = Array.Empty<string>(); private IReadOnlyList<string> _trimmedAssemblies = Array.Empty<string>(); private bool _rootDefaultAssemblies; public IReadOnlyList<string> _mibcFilePaths = Array.Empty<string>(); private IReadOnlyList<string> _singleWarnEnabledAssemblies = Array.Empty<string>(); private IReadOnlyList<string> _singleWarnDisabledAssemblies = Array.Empty<string>(); private bool _singleWarn; private string _makeReproPath; private bool _help; private Program() { } private void Help(string helpText) { Console.WriteLine(); Console.Write("Microsoft (R) .NET Native IL Compiler"); Console.Write(" "); Console.Write(typeof(Program).GetTypeInfo().Assembly.GetName().Version); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(helpText); } private void InitializeDefaultOptions() { // We could offer this as a command line option, but then we also need to // load a different RyuJIT, so this is a future nice to have... if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) _targetOS = TargetOS.Windows; else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) _targetOS = TargetOS.Linux; else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) _targetOS = TargetOS.OSX; else throw new NotImplementedException(); switch (RuntimeInformation.ProcessArchitecture) { case Architecture.X86: _targetArchitecture = TargetArchitecture.X86; break; case Architecture.X64: _targetArchitecture = TargetArchitecture.X64; break; case Architecture.Arm: _targetArchitecture = TargetArchitecture.ARM; break; case Architecture.Arm64: _targetArchitecture = TargetArchitecture.ARM64; break; default: throw new NotImplementedException(); } // Workaround for https://github.com/dotnet/corefx/issues/25267 // If pointer size is 8, we're obviously not an X86 process... if (_targetArchitecture == TargetArchitecture.X86 && IntPtr.Size == 8) _targetArchitecture = TargetArchitecture.X64; } private ArgumentSyntax ParseCommandLine(string[] args) { IReadOnlyList<string> inputFiles = Array.Empty<string>(); IReadOnlyList<string> referenceFiles = Array.Empty<string>(); bool optimize = false; bool optimizeSpace = false; bool optimizeTime = false; bool waitForDebugger = false; AssemblyName name = typeof(Program).GetTypeInfo().Assembly.GetName(); ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax => { syntax.ApplicationName = name.Name.ToString(); // HandleHelp writes to error, fails fast with crash dialog and lacks custom formatting. syntax.HandleHelp = false; syntax.HandleErrors = true; syntax.DefineOption("h|help", ref _help, "Help message for ILC"); syntax.DefineOptionList("r|reference", ref referenceFiles, "Reference file(s) for compilation"); syntax.DefineOption("o|out", ref _outputFilePath, "Output file path"); syntax.DefineOption("O", ref optimize, "Enable optimizations"); syntax.DefineOption("Os", ref optimizeSpace, "Enable optimizations, favor code space"); syntax.DefineOption("Ot", ref optimizeTime, "Enable optimizations, favor code speed"); syntax.DefineOptionList("m|mibc", ref _mibcFilePaths, "Mibc file(s) for profile guided optimization"); ; syntax.DefineOption("g", ref _enableDebugInfo, "Emit debugging information"); syntax.DefineOption("gdwarf-5", ref _useDwarf5, "Generate source-level debug information with dwarf version 5"); syntax.DefineOption("nativelib", ref _nativeLib, "Compile as static or shared library"); syntax.DefineOption("exportsfile", ref _exportsFile, "File to write exported method definitions"); syntax.DefineOption("dgmllog", ref _dgmlLogFileName, "Save result of dependency analysis as DGML"); syntax.DefineOption("fulllog", ref _generateFullDgmlLog, "Save detailed log of dependency analysis"); syntax.DefineOption("scandgmllog", ref _scanDgmlLogFileName, "Save result of scanner dependency analysis as DGML"); syntax.DefineOption("scanfulllog", ref _generateFullScanDgmlLog, "Save detailed log of scanner dependency analysis"); syntax.DefineOption("verbose", ref _isVerbose, "Enable verbose logging"); syntax.DefineOption("systemmodule", ref _systemModuleName, "System module name (default: System.Private.CoreLib)"); syntax.DefineOption("multifile", ref _multiFile, "Compile only input files (do not compile referenced assemblies)"); syntax.DefineOption("waitfordebugger", ref waitForDebugger, "Pause to give opportunity to attach debugger"); syntax.DefineOption("resilient", ref _resilient, "Ignore unresolved types, methods, and assemblies. Defaults to false"); syntax.DefineOptionList("codegenopt", ref _codegenOptions, "Define a codegen option"); syntax.DefineOptionList("rdxml", ref _rdXmlFilePaths, "RD.XML file(s) for compilation"); syntax.DefineOption("map", ref _mapFileName, "Generate a map file"); syntax.DefineOption("metadatalog", ref _metadataLogFileName, "Generate a metadata log file"); syntax.DefineOption("nometadatablocking", ref _noMetadataBlocking, "Ignore metadata blocking for internal implementation details"); syntax.DefineOption("disablereflection", ref _disableReflection, "Disable generation of reflection metadata"); syntax.DefineOption("completetypemetadata", ref _completeTypesMetadata, "Generate complete metadata for types"); syntax.DefineOption("reflectedonly", ref _reflectedOnly, "Generate metadata only for reflected members"); syntax.DefineOption("scanreflection", ref _scanReflection, "Scan IL for reflection patterns"); syntax.DefineOption("scan", ref _useScanner, "Use IL scanner to generate optimized code (implied by -O)"); syntax.DefineOption("noscan", ref _noScanner, "Do not use IL scanner to generate optimized code"); syntax.DefineOption("ildump", ref _ilDump, "Dump IL assembly listing for compiler-generated IL"); syntax.DefineOption("stacktracedata", ref _emitStackTraceData, "Emit data to support generating stack trace strings at runtime"); syntax.DefineOption("methodbodyfolding", ref _methodBodyFolding, "Fold identical method bodies"); syntax.DefineOptionList("initassembly", ref _initAssemblies, "Assembly(ies) with a library initializer"); syntax.DefineOptionList("appcontextswitch", ref _appContextSwitches, "System.AppContext switches to set (format: 'Key=Value')"); syntax.DefineOptionList("feature", ref _featureSwitches, "Feature switches to apply (format: 'Namespace.Name=[true|false]'"); syntax.DefineOptionList("runtimeopt", ref _runtimeOptions, "Runtime options to set"); syntax.DefineOption("parallelism", ref _parallelism, "Maximum number of threads to use during compilation"); syntax.DefineOption("instructionset", ref _instructionSet, "Instruction set to allow or disallow"); syntax.DefineOption("guard", ref _guard, "Enable mitigations. Options: 'cf': CFG (Control Flow Guard, Windows only)"); syntax.DefineOption("preinitstatics", ref _preinitStatics, "Interpret static constructors at compile time if possible (implied by -O)"); syntax.DefineOption("nopreinitstatics", ref _noPreinitStatics, "Do not interpret static constructors at compile time"); syntax.DefineOptionList("nowarn", ref _suppressedWarnings, "Disable specific warning messages"); syntax.DefineOption("singlewarn", ref _singleWarn, "Generate single AOT/trimming warning per assembly"); syntax.DefineOptionList("singlewarnassembly", ref _singleWarnEnabledAssemblies, "Generate single AOT/trimming warning for given assembly"); syntax.DefineOptionList("nosinglewarnassembly", ref _singleWarnDisabledAssemblies, "Expand AOT/trimming warnings for given assembly"); syntax.DefineOptionList("directpinvoke", ref _directPInvokes, "PInvoke to call directly"); syntax.DefineOptionList("directpinvokelist", ref _directPInvokeLists, "File with list of PInvokes to call directly"); syntax.DefineOption("maxgenericcycle", ref _maxGenericCycle, "Max depth of generic cycle"); syntax.DefineOptionList("root", ref _rootedAssemblies, "Fully generate given assembly"); syntax.DefineOptionList("conditionalroot", ref _conditionallyRootedAssemblies, "Fully generate given assembly if it's used"); syntax.DefineOptionList("trim", ref _trimmedAssemblies, "Trim the specified assembly"); syntax.DefineOption("defaultrooting", ref _rootDefaultAssemblies, "Root assemblies that are not marked [IsTrimmable]"); syntax.DefineOption("targetarch", ref _targetArchitectureStr, "Target architecture for cross compilation"); syntax.DefineOption("targetos", ref _targetOSStr, "Target OS for cross compilation"); syntax.DefineOption("jitpath", ref _jitPath, "Path to JIT compiler library"); syntax.DefineOption("singlemethodtypename", ref _singleMethodTypeName, "Single method compilation: assembly-qualified name of the owning type"); syntax.DefineOption("singlemethodname", ref _singleMethodName, "Single method compilation: name of the method"); syntax.DefineOptionList("singlemethodgenericarg", ref _singleMethodGenericArgs, "Single method compilation: generic arguments to the method"); syntax.DefineOption("make-repro-path", ref _makeReproPath, "Path where to place a repro package"); syntax.DefineParameterList("in", ref inputFiles, "Input file(s) to compile"); }); if (waitForDebugger) { Console.WriteLine("Waiting for debugger to attach. Press ENTER to continue"); Console.ReadLine(); } _optimizationMode = OptimizationMode.None; if (optimizeSpace) { if (optimizeTime) Console.WriteLine("Warning: overriding -Ot with -Os"); _optimizationMode = OptimizationMode.PreferSize; } else if (optimizeTime) _optimizationMode = OptimizationMode.PreferSpeed; else if (optimize) _optimizationMode = OptimizationMode.Blended; foreach (var input in inputFiles) Helpers.AppendExpandedPaths(_inputFilePaths, input, true); foreach (var reference in referenceFiles) Helpers.AppendExpandedPaths(_referenceFilePaths, reference, false); if (_makeReproPath != null) { // Create a repro package in the specified path // This package will have the set of input files needed for compilation // + the original command line arguments // + a rsp file that should work to directly run out of the zip file Helpers.MakeReproPackage(_makeReproPath, _outputFilePath, args, argSyntax, new[] { "-r", "-m", "--rdxml", "--directpinvokelist" }); } return argSyntax; } private IReadOnlyCollection<MethodDesc> CreateInitializerList(CompilerTypeSystemContext context) { List<ModuleDesc> assembliesWithInitalizers = new List<ModuleDesc>(); // Build a list of assemblies that have an initializer that needs to run before // any user code runs. foreach (string initAssemblyName in _initAssemblies) { ModuleDesc assembly = context.ResolveAssembly(new AssemblyName(initAssemblyName), throwIfNotFound: true); assembliesWithInitalizers.Add(assembly); } var libraryInitializers = new LibraryInitializers(context, assembliesWithInitalizers); List<MethodDesc> initializerList = new List<MethodDesc>(libraryInitializers.LibraryInitializerMethods); // If there are any AppContext switches the user wishes to enable, generate code that sets them. if (_appContextSwitches.Count > 0) { MethodDesc appContextInitMethod = new Internal.IL.Stubs.StartupCode.AppContextInitializerMethod( context.GeneratedAssembly.GetGlobalModuleType(), _appContextSwitches); initializerList.Add(appContextInitMethod); } return initializerList; } private int Run(string[] args) { InitializeDefaultOptions(); ArgumentSyntax syntax = ParseCommandLine(args); if (_help) { Help(syntax.GetHelpText()); return 1; } if (_outputFilePath == null) throw new CommandLineException("Output filename must be specified (/out <file>)"); // // Set target Architecture and OS // if (_targetArchitectureStr != null) { if (_targetArchitectureStr.Equals("x86", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.X86; else if (_targetArchitectureStr.Equals("x64", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.X64; else if (_targetArchitectureStr.Equals("arm", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.ARM; else if (_targetArchitectureStr.Equals("armel", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.ARM; else if (_targetArchitectureStr.Equals("arm64", StringComparison.OrdinalIgnoreCase)) _targetArchitecture = TargetArchitecture.ARM64; else throw new CommandLineException("Target architecture is not supported"); } if (_targetOSStr != null) { if (_targetOSStr.Equals("windows", StringComparison.OrdinalIgnoreCase)) _targetOS = TargetOS.Windows; else if (_targetOSStr.Equals("linux", StringComparison.OrdinalIgnoreCase)) _targetOS = TargetOS.Linux; else if (_targetOSStr.Equals("osx", StringComparison.OrdinalIgnoreCase)) _targetOS = TargetOS.OSX; else throw new CommandLineException("Target OS is not supported"); } InstructionSetSupportBuilder instructionSetSupportBuilder = new InstructionSetSupportBuilder(_targetArchitecture); // The runtime expects certain baselines that the codegen can assume as well. if ((_targetArchitecture == TargetArchitecture.X86) || (_targetArchitecture == TargetArchitecture.X64)) { instructionSetSupportBuilder.AddSupportedInstructionSet("sse"); instructionSetSupportBuilder.AddSupportedInstructionSet("sse2"); } else if (_targetArchitecture == TargetArchitecture.ARM64) { instructionSetSupportBuilder.AddSupportedInstructionSet("base"); instructionSetSupportBuilder.AddSupportedInstructionSet("neon"); } if (_instructionSet != null) { List<string> instructionSetParams = new List<string>(); // Normalize instruction set format to include implied +. string[] instructionSetParamsInput = _instructionSet.Split(','); for (int i = 0; i < instructionSetParamsInput.Length; i++) { string instructionSet = instructionSetParamsInput[i]; if (String.IsNullOrEmpty(instructionSet)) throw new CommandLineException("Instruction set must not be empty"); char firstChar = instructionSet[0]; if ((firstChar != '+') && (firstChar != '-')) { instructionSet = "+" + instructionSet; } instructionSetParams.Add(instructionSet); } Dictionary<string, bool> instructionSetSpecification = new Dictionary<string, bool>(); foreach (string instructionSetSpecifier in instructionSetParams) { string instructionSet = instructionSetSpecifier.Substring(1, instructionSetSpecifier.Length - 1); bool enabled = instructionSetSpecifier[0] == '+' ? true : false; if (enabled) { if (!instructionSetSupportBuilder.AddSupportedInstructionSet(instructionSet)) throw new CommandLineException($"Unrecognized instruction set '{instructionSet}'"); } else { if (!instructionSetSupportBuilder.RemoveInstructionSetSupport(instructionSet)) throw new CommandLineException($"Unrecognized instruction set '{instructionSet}'"); } } } instructionSetSupportBuilder.ComputeInstructionSetFlags(out var supportedInstructionSet, out var unsupportedInstructionSet, (string specifiedInstructionSet, string impliedInstructionSet) => throw new CommandLineException(String.Format("Unsupported combination of instruction sets: {0}/{1}", specifiedInstructionSet, impliedInstructionSet))); InstructionSetSupportBuilder optimisticInstructionSetSupportBuilder = new InstructionSetSupportBuilder(_targetArchitecture); // Optimistically assume some instruction sets are present. if ((_targetArchitecture == TargetArchitecture.X86) || (_targetArchitecture == TargetArchitecture.X64)) { // We set these hardware features as enabled always, as most // of hardware in the wild supports them. Note that we do not indicate support for AVX, or any other // instruction set which uses the VEX encodings as the presence of those makes otherwise acceptable // code be unusable on hardware which does not support VEX encodings, as well as emulators that do not // support AVX instructions. // // The compiler is able to generate runtime IsSupported checks for the following instruction sets. optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("sse4.1"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("sse4.2"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("ssse3"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("aes"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("pclmul"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("popcnt"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("lzcnt"); // If AVX was enabled, we can opportunistically enable FMA/BMI/VNNI Debug.Assert(InstructionSet.X64_AVX == InstructionSet.X86_AVX); if (supportedInstructionSet.HasInstructionSet(InstructionSet.X64_AVX)) { optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("fma"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("bmi"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("bmi2"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("avxvnni"); } } else if (_targetArchitecture == TargetArchitecture.ARM64) { optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("aes"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("crc"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("sha1"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("sha2"); optimisticInstructionSetSupportBuilder.AddSupportedInstructionSet("lse"); } optimisticInstructionSetSupportBuilder.ComputeInstructionSetFlags(out var optimisticInstructionSet, out _, (string specifiedInstructionSet, string impliedInstructionSet) => throw new NotSupportedException()); optimisticInstructionSet.Remove(unsupportedInstructionSet); optimisticInstructionSet.Add(supportedInstructionSet); var instructionSetSupport = new InstructionSetSupport(supportedInstructionSet, unsupportedInstructionSet, optimisticInstructionSet, InstructionSetSupportBuilder.GetNonSpecifiableInstructionSetsForArch(_targetArchitecture), _targetArchitecture); bool supportsReflection = !_disableReflection && _systemModuleName == DefaultSystemModule; // // Initialize type system context // SharedGenericsMode genericsMode = SharedGenericsMode.CanonicalReferenceTypes; var simdVectorLength = instructionSetSupport.GetVectorTSimdVector(); var targetAbi = TargetAbi.CoreRT; var targetDetails = new TargetDetails(_targetArchitecture, _targetOS, targetAbi, simdVectorLength); CompilerTypeSystemContext typeSystemContext = new CompilerTypeSystemContext(targetDetails, genericsMode, supportsReflection ? DelegateFeature.All : 0, _maxGenericCycle); // // TODO: To support our pre-compiled test tree, allow input files that aren't managed assemblies since // some tests contain a mixture of both managed and native binaries. // // See: https://github.com/dotnet/corert/issues/2785 // // When we undo this this hack, replace this foreach with // typeSystemContext.InputFilePaths = _inputFilePaths; // Dictionary<string, string> inputFilePaths = new Dictionary<string, string>(); foreach (var inputFile in _inputFilePaths) { try { var module = typeSystemContext.GetModuleFromPath(inputFile.Value); inputFilePaths.Add(inputFile.Key, inputFile.Value); } catch (TypeSystemException.BadImageFormatException) { // Keep calm and carry on. } } typeSystemContext.InputFilePaths = inputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; if (!typeSystemContext.InputFilePaths.ContainsKey(_systemModuleName) && !typeSystemContext.ReferenceFilePaths.ContainsKey(_systemModuleName)) throw new CommandLineException($"System module {_systemModuleName} does not exists. Make sure that you specify --systemmodule"); typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(_systemModuleName)); if (typeSystemContext.InputFilePaths.Count == 0) throw new CommandLineException("No input files specified"); SecurityMitigationOptions securityMitigationOptions = 0; if (StringComparer.OrdinalIgnoreCase.Equals(_guard, "cf")) { if (_targetOS != TargetOS.Windows) { throw new CommandLineException($"Control flow guard only available on Windows"); } securityMitigationOptions = SecurityMitigationOptions.ControlFlowGuardAnnotations; } else if (!String.IsNullOrEmpty(_guard)) { throw new CommandLineException($"Unrecognized mitigation option '{_guard}'"); } // // Initialize compilation group and compilation roots // // Single method mode? MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext); CompilationModuleGroup compilationGroup; List<ICompilationRootProvider> compilationRoots = new List<ICompilationRootProvider>(); if (singleMethod != null) { // Compiling just a single method compilationGroup = new SingleMethodCompilationModuleGroup(singleMethod); compilationRoots.Add(new SingleMethodRootProvider(singleMethod)); } else { // Either single file, or multifile library, or multifile consumption. EcmaModule entrypointModule = null; bool systemModuleIsInputModule = false; foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (module.PEReader.PEHeaders.IsExe) { if (entrypointModule != null) throw new Exception("Multiple EXE modules"); entrypointModule = module; } if (module == typeSystemContext.SystemModule) systemModuleIsInputModule = true; compilationRoots.Add(new ExportedMethodsRootProvider(module)); } if (entrypointModule != null) { compilationRoots.Add(new MainMethodRootProvider(entrypointModule, CreateInitializerList(typeSystemContext))); compilationRoots.Add(new RuntimeConfigurationRootProvider(_runtimeOptions)); compilationRoots.Add(new ExpectedIsaFeaturesRootProvider(instructionSetSupport)); } if (_multiFile) { List<EcmaModule> inputModules = new List<EcmaModule>(); foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (entrypointModule == null) { // This is a multifile production build - we need to root all methods compilationRoots.Add(new LibraryRootProvider(module)); } inputModules.Add(module); } compilationGroup = new MultiFileSharedCompilationModuleGroup(typeSystemContext, inputModules); } else { if (entrypointModule == null && !_nativeLib) throw new Exception("No entrypoint module"); if (!systemModuleIsInputModule) compilationRoots.Add(new ExportedMethodsRootProvider((EcmaModule)typeSystemContext.SystemModule)); compilationGroup = new SingleFileCompilationModuleGroup(); } if (_nativeLib) { // Set owning module of generated native library startup method to compiler generated module, // to ensure the startup method is included in the object file during multimodule mode build compilationRoots.Add(new NativeLibraryInitializerRootProvider(typeSystemContext.GeneratedAssembly, CreateInitializerList(typeSystemContext))); compilationRoots.Add(new RuntimeConfigurationRootProvider(_runtimeOptions)); compilationRoots.Add(new ExpectedIsaFeaturesRootProvider(instructionSetSupport)); } foreach (var rdXmlFilePath in _rdXmlFilePaths) { compilationRoots.Add(new RdXmlRootProvider(typeSystemContext, rdXmlFilePath)); } } _rootedAssemblies = new List<string>(_rootedAssemblies.Select(a => ILLinkify(a))); _conditionallyRootedAssemblies = new List<string>(_conditionallyRootedAssemblies.Select(a => ILLinkify(a))); _trimmedAssemblies = new List<string>(_trimmedAssemblies.Select(a => ILLinkify(a))); static string ILLinkify(string rootedAssembly) { // For compatibility with IL Linker, the parameter could be a file name or an assembly name. // This is the logic IL Linker uses to decide how to interpret the string. Really. string simpleName; if (File.Exists(rootedAssembly)) simpleName = Path.GetFileNameWithoutExtension(rootedAssembly); else simpleName = rootedAssembly; return simpleName; } // Root whatever assemblies were specified on the command line foreach (var rootedAssembly in _rootedAssemblies) { // We only root the module type. The rest will fall out because we treat _rootedAssemblies // same as conditionally rooted ones and here we're fulfilling the condition ("something is used"). compilationRoots.Add( new GenericRootProvider<ModuleDesc>(typeSystemContext.GetModuleForSimpleName(rootedAssembly), (ModuleDesc module, IRootingServiceProvider rooter) => rooter.AddCompilationRoot(module.GetGlobalModuleType(), "Command line root"))); } // // Compile // CompilationBuilder builder = new RyuJitCompilationBuilder(typeSystemContext, compilationGroup); string compilationUnitPrefix = _multiFile ? System.IO.Path.GetFileNameWithoutExtension(_outputFilePath) : ""; builder.UseCompilationUnitPrefix(compilationUnitPrefix); if (_mibcFilePaths.Count > 0) ((RyuJitCompilationBuilder)builder).UseProfileData(_mibcFilePaths); if (!String.IsNullOrEmpty(_jitPath)) ((RyuJitCompilationBuilder)builder).UseJitPath(_jitPath); PInvokeILEmitterConfiguration pinvokePolicy = new ConfigurablePInvokePolicy(typeSystemContext.Target, _directPInvokes, _directPInvokeLists); ILProvider ilProvider = new CoreRTILProvider(); List<KeyValuePair<string, bool>> featureSwitches = new List<KeyValuePair<string, bool>>(); foreach (var switchPair in _featureSwitches) { string[] switchAndValue = switchPair.Split('='); if (switchAndValue.Length != 2 || !bool.TryParse(switchAndValue[1], out bool switchValue)) throw new CommandLineException($"Unexpected feature switch pair '{switchPair}'"); featureSwitches.Add(new KeyValuePair<string, bool>(switchAndValue[0], switchValue)); } ilProvider = new FeatureSwitchManager(ilProvider, featureSwitches); var logger = new Logger(Console.Out, _isVerbose, ProcessWarningCodes(_suppressedWarnings), _singleWarn, _singleWarnEnabledAssemblies, _singleWarnDisabledAssemblies); var stackTracePolicy = _emitStackTraceData ? (StackTraceEmissionPolicy)new EcmaMethodStackTraceEmissionPolicy() : new NoStackTraceEmissionPolicy(); MetadataBlockingPolicy mdBlockingPolicy; ManifestResourceBlockingPolicy resBlockingPolicy; UsageBasedMetadataGenerationOptions metadataGenerationOptions = default; if (supportsReflection) { mdBlockingPolicy = _noMetadataBlocking ? (MetadataBlockingPolicy)new NoMetadataBlockingPolicy() : new BlockedInternalsBlockingPolicy(typeSystemContext); resBlockingPolicy = new ManifestResourceBlockingPolicy(featureSwitches); metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.AnonymousTypeHeuristic; if (_completeTypesMetadata) metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.CompleteTypesOnly; if (_scanReflection) metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.ReflectionILScanning; if (_reflectedOnly) metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.ReflectedMembersOnly; if (_rootDefaultAssemblies) metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.RootDefaultAssemblies; } else { mdBlockingPolicy = new FullyBlockedMetadataBlockingPolicy(); resBlockingPolicy = new FullyBlockedManifestResourceBlockingPolicy(); } DynamicInvokeThunkGenerationPolicy invokeThunkGenerationPolicy = new DefaultDynamicInvokeThunkGenerationPolicy(); var flowAnnotations = new Dataflow.FlowAnnotations(logger, ilProvider); MetadataManager metadataManager = new UsageBasedMetadataManager( compilationGroup, typeSystemContext, mdBlockingPolicy, resBlockingPolicy, _metadataLogFileName, stackTracePolicy, invokeThunkGenerationPolicy, flowAnnotations, metadataGenerationOptions, logger, featureSwitches, _conditionallyRootedAssemblies.Concat(_rootedAssemblies), _trimmedAssemblies); InteropStateManager interopStateManager = new InteropStateManager(typeSystemContext.GeneratedAssembly); InteropStubManager interopStubManager = new UsageBasedInteropStubManager(interopStateManager, pinvokePolicy, logger); // Unless explicitly opted in at the command line, we enable scanner for retail builds by default. // We also don't do this for multifile because scanner doesn't simulate inlining (this would be // fixable by using a CompilationGroup for the scanner that has a bigger worldview, but // let's cross that bridge when we get there). bool useScanner = _useScanner || (_optimizationMode != OptimizationMode.None && !_multiFile); useScanner &= !_noScanner; // Enable static data preinitialization in optimized builds. bool preinitStatics = _preinitStatics || (_optimizationMode != OptimizationMode.None && !_multiFile); preinitStatics &= !_noPreinitStatics; var preinitManager = new PreinitializationManager(typeSystemContext, compilationGroup, ilProvider, preinitStatics); builder .UseILProvider(ilProvider) .UsePreinitializationManager(preinitManager); ILScanResults scanResults = null; if (useScanner) { ILScannerBuilder scannerBuilder = builder.GetILScannerBuilder() .UseCompilationRoots(compilationRoots) .UseMetadataManager(metadataManager) .UseParallelism(_parallelism) .UseInteropStubManager(interopStubManager); if (_scanDgmlLogFileName != null) scannerBuilder.UseDependencyTracking(_generateFullScanDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); IILScanner scanner = scannerBuilder.ToILScanner(); scanResults = scanner.Scan(); metadataManager = ((UsageBasedMetadataManager)metadataManager).ToAnalysisBasedMetadataManager(); interopStubManager = scanResults.GetInteropStubManager(interopStateManager, pinvokePolicy); } DebugInformationProvider debugInfoProvider = _enableDebugInfo ? (_ilDump == null ? new DebugInformationProvider() : new ILAssemblyGeneratingMethodDebugInfoProvider(_ilDump, new EcmaOnlyDebugInformationProvider())) : new NullDebugInformationProvider(); DependencyTrackingLevel trackingLevel = _dgmlLogFileName == null ? DependencyTrackingLevel.None : (_generateFullDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); compilationRoots.Add(metadataManager); compilationRoots.Add(interopStubManager); builder .UseInstructionSetSupport(instructionSetSupport) .UseBackendOptions(_codegenOptions) .UseMethodBodyFolding(enable: _methodBodyFolding) .UseParallelism(_parallelism) .UseMetadataManager(metadataManager) .UseInteropStubManager(interopStubManager) .UseLogger(logger) .UseDependencyTracking(trackingLevel) .UseCompilationRoots(compilationRoots) .UseOptimizationMode(_optimizationMode) .UseSecurityMitigationOptions(securityMitigationOptions) .UseDebugInfoProvider(debugInfoProvider) .UseDwarf5(_useDwarf5); if (scanResults != null) { // If we have a scanner, feed the vtable analysis results to the compilation. // This could be a command line switch if we really wanted to. builder.UseVTableSliceProvider(scanResults.GetVTableLayoutInfo()); // If we have a scanner, feed the generic dictionary results to the compilation. // This could be a command line switch if we really wanted to. builder.UseGenericDictionaryLayoutProvider(scanResults.GetDictionaryLayoutInfo()); // If we have a scanner, we can drive devirtualization using the information // we collected at scanning time (effectively sealing unsealed types if possible). // This could be a command line switch if we really wanted to. builder.UseDevirtualizationManager(scanResults.GetDevirtualizationManager()); // If we use the scanner's result, we need to consult it to drive inlining. // This prevents e.g. devirtualizing and inlining methods on types that were // never actually allocated. builder.UseInliningPolicy(scanResults.GetInliningPolicy()); // Use an error provider that prevents us from re-importing methods that failed // to import with an exception during scanning phase. We would see the same failure during // compilation, but before RyuJIT gets there, it might ask questions that we don't // have answers for because we didn't scan the entire method. builder.UseMethodImportationErrorProvider(scanResults.GetMethodImportationErrorProvider()); } builder.UseResilience(_resilient); ICompilation compilation = builder.ToCompilation(); ObjectDumper dumper = _mapFileName != null ? new ObjectDumper(_mapFileName) : null; CompilationResults compilationResults = compilation.Compile(_outputFilePath, dumper); if (_exportsFile != null) { ExportsFileWriter defFileWriter = new ExportsFileWriter(typeSystemContext, _exportsFile); foreach (var compilationRoot in compilationRoots) { if (compilationRoot is ExportedMethodsRootProvider provider) defFileWriter.AddExportedMethods(provider.ExportedMethods); } defFileWriter.EmitExportedMethods(); } typeSystemContext.LogWarnings(logger); if (_dgmlLogFileName != null) compilationResults.WriteDependencyLog(_dgmlLogFileName); if (scanResults != null) { if (_scanDgmlLogFileName != null) scanResults.WriteDependencyLog(_scanDgmlLogFileName); // If the scanner and compiler don't agree on what to compile, the outputs of the scanner might not actually be usable. // We are going to check this two ways: // 1. The methods and types generated during compilation are a subset of method and types scanned // 2. The methods and types scanned are a subset of methods and types compiled (this has a chance to hold for unoptimized builds only). // Check that methods and types generated during compilation are a subset of method and types scanned bool scanningFail = false; DiffCompilationResults(ref scanningFail, compilationResults.CompiledMethodBodies, scanResults.CompiledMethodBodies, "Methods", "compiled", "scanned", method => !(method.GetTypicalMethodDefinition() is EcmaMethod) || method.Name == "ThrowPlatformNotSupportedException" || method.Name == "ThrowArgumentOutOfRangeException" || method.Name == "ThrowArgumentException"); DiffCompilationResults(ref scanningFail, compilationResults.ConstructedEETypes, scanResults.ConstructedEETypes, "EETypes", "compiled", "scanned", type => !(type.GetTypeDefinition() is EcmaType)); // If optimizations are enabled, the results will for sure not match in the other direction due to inlining, etc. // But there's at least some value in checking the scanner doesn't expand the universe too much in debug. if (_optimizationMode == OptimizationMode.None) { // Check that methods and types scanned are a subset of methods and types compiled // If we find diffs here, they're not critical, but still might be causing a Size on Disk regression. bool dummy = false; // We additionally skip methods in SIMD module because there's just too many intrisics to handle and IL scanner // doesn't expand them. They would show up as noisy diffs. DiffCompilationResults(ref dummy, scanResults.CompiledMethodBodies, compilationResults.CompiledMethodBodies, "Methods", "scanned", "compiled", method => !(method.GetTypicalMethodDefinition() is EcmaMethod) || method.OwningType.IsIntrinsic); DiffCompilationResults(ref dummy, scanResults.ConstructedEETypes, compilationResults.ConstructedEETypes, "EETypes", "scanned", "compiled", type => !(type.GetTypeDefinition() is EcmaType)); } if (scanningFail) throw new Exception("Scanning failure"); } if (debugInfoProvider is IDisposable) ((IDisposable)debugInfoProvider).Dispose(); preinitManager.LogStatistics(logger); return 0; } [System.Diagnostics.Conditional("DEBUG")] private void DiffCompilationResults<T>(ref bool result, IEnumerable<T> set1, IEnumerable<T> set2, string prefix, string set1name, string set2name, Predicate<T> filter) { HashSet<T> diff = new HashSet<T>(set1); diff.ExceptWith(set2); // TODO: move ownership of compiler-generated entities to CompilerTypeSystemContext. // https://github.com/dotnet/corert/issues/3873 diff.RemoveWhere(filter); if (diff.Count > 0) { result = true; Console.WriteLine($"*** {prefix} {set1name} but not {set2name}:"); foreach (var d in diff) { Console.WriteLine(d.ToString()); } } } private TypeDesc FindType(CompilerTypeSystemContext context, string typeName) { ModuleDesc systemModule = context.SystemModule; TypeDesc foundType = systemModule.GetTypeByCustomAttributeTypeName(typeName, false, (typeDefName, module, throwIfNotFound) => { return (MetadataType)context.GetCanonType(typeDefName) ?? CustomAttributeTypeNameParser.ResolveCustomAttributeTypeDefinitionName(typeDefName, module, throwIfNotFound); }); if (foundType == null) throw new CommandLineException($"Type '{typeName}' not found"); return foundType; } private MethodDesc CheckAndParseSingleMethodModeArguments(CompilerTypeSystemContext context) { if (_singleMethodName == null && _singleMethodTypeName == null && _singleMethodGenericArgs == null) return null; if (_singleMethodName == null || _singleMethodTypeName == null) throw new CommandLineException("Both method name and type name are required parameters for single method mode"); TypeDesc owningType = FindType(context, _singleMethodTypeName); // TODO: allow specifying signature to distinguish overloads MethodDesc method = owningType.GetMethod(_singleMethodName, null); if (method == null) throw new CommandLineException($"Method '{_singleMethodName}' not found in '{_singleMethodTypeName}'"); if (method.HasInstantiation != (_singleMethodGenericArgs != null) || (method.HasInstantiation && (method.Instantiation.Length != _singleMethodGenericArgs.Count))) { throw new CommandLineException( $"Expected {method.Instantiation.Length} generic arguments for method '{_singleMethodName}' on type '{_singleMethodTypeName}'"); } if (method.HasInstantiation) { List<TypeDesc> genericArguments = new List<TypeDesc>(); foreach (var argString in _singleMethodGenericArgs) genericArguments.Add(FindType(context, argString)); method = method.MakeInstantiatedMethod(genericArguments.ToArray()); } return method; } private static bool DumpReproArguments(CodeGenerationFailedException ex) { Console.WriteLine("To repro, add following arguments to the command line:"); MethodDesc failingMethod = ex.Method; var formatter = new CustomAttributeTypeNameFormatter((IAssemblyDesc)failingMethod.Context.SystemModule); Console.Write($"--singlemethodtypename \"{formatter.FormatName(failingMethod.OwningType, true)}\""); Console.Write($" --singlemethodname {failingMethod.Name}"); for (int i = 0; i < failingMethod.Instantiation.Length; i++) Console.Write($" --singlemethodgenericarg \"{formatter.FormatName(failingMethod.Instantiation[i], true)}\""); return false; } private static IEnumerable<int> ProcessWarningCodes(IEnumerable<string> warningCodes) { foreach (string value in warningCodes) { string[] values = value.Split(new char[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string id in values) { if (!id.StartsWith("IL", StringComparison.Ordinal) || !ushort.TryParse(id.Substring(2), out ushort code)) continue; yield return code; } } } private static int Main(string[] args) { #if DEBUG try { return new Program().Run(args); } catch (CodeGenerationFailedException ex) when (DumpReproArguments(ex)) { throw new NotSupportedException(); // Unreachable } #else try { return new Program().Run(args); } catch (Exception e) { Console.Error.WriteLine("Error: " + e.Message); Console.Error.WriteLine(e.ToString()); return 1; } #endif } } }
1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/GetEndComSlotTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices.Tests.Common; using Xunit; namespace System.Runtime.InteropServices.Tests { public partial class GetEndComSlotTests { [Fact] [PlatformSpecific(TestPlatforms.AnyUnix)] public void GetEndComSlot_Unix_ThrowsPlatformNotSupportedException() { Assert.Throws<PlatformNotSupportedException>(() => Marshal.GetEndComSlot(null)); } [Fact] [PlatformSpecific(TestPlatforms.Windows)] public void GetEndComSlot_NullType_ThrowsArgumentNullException() { AssertExtensions.Throws<ArgumentNullException>(null, () => Marshal.GetEndComSlot(null)); } [Fact] [PlatformSpecific(TestPlatforms.Windows)] public void GetEndComSlot_NotRuntimeType_ThrowsArgumentException() { AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.Run); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module"); TypeBuilder typeBuilder = moduleBuilder.DefineType("Type"); AssertExtensions.Throws<ArgumentException>("t", () => Marshal.GetEndComSlot(typeBuilder)); } public static IEnumerable<object[]> GetStartComSlot_InvalidGenericType_TestData() { yield return new object[] { typeof(int).MakeByRefType() }; yield return new object[] { typeof(GenericClass<>).GetTypeInfo().GenericTypeParameters[0] }; } [Theory] [MemberData(nameof(GetStartComSlot_InvalidGenericType_TestData))] [PlatformSpecific(TestPlatforms.Windows)] public void GetEndComSlot_InvalidGenericType_ThrowsArgumentNullException(Type type) { AssertExtensions.Throws<ArgumentNullException>(null, () => Marshal.GetEndComSlot(type)); } public static IEnumerable<object[]> GetStartComSlot_NotComVisibleType_TestData() { yield return new object[] { typeof(GenericClass<>) }; yield return new object[] { typeof(GenericClass<string>) }; yield return new object[] { typeof(GenericStruct<>) }; yield return new object[] { typeof(GenericStruct<string>) }; yield return new object[] { typeof(IGenericInterface<>) }; yield return new object[] { typeof(IGenericInterface<string>) }; yield return new object[] { typeof(NonComVisibleClass) }; yield return new object[] { typeof(NonComVisibleStruct) }; yield return new object[] { typeof(INonComVisibleInterface) }; yield return new object[] { typeof(int[]) }; yield return new object[] { typeof(int[][]) }; yield return new object[] { typeof(int[,]) }; AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module"); TypeBuilder typeBuilder = moduleBuilder.DefineType("Type"); Type collectibleType = typeBuilder.CreateType(); yield return new object[] { collectibleType }; } [Theory] [MemberData(nameof(GetStartComSlot_NotComVisibleType_TestData))] [PlatformSpecific(TestPlatforms.Windows)] public void GetEndComSlot_NotComVisibleType_ThrowsArgumentException(Type type) { AssertExtensions.Throws<ArgumentException>("t", () => Marshal.GetEndComSlot(type)); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices.Tests.Common; using Xunit; namespace System.Runtime.InteropServices.Tests { public partial class GetEndComSlotTests { [Fact] [PlatformSpecific(TestPlatforms.AnyUnix)] public void GetEndComSlot_Unix_ThrowsPlatformNotSupportedException() { Assert.Throws<PlatformNotSupportedException>(() => Marshal.GetEndComSlot(null)); } [Fact] [PlatformSpecific(TestPlatforms.Windows)] public void GetEndComSlot_NullType_ThrowsArgumentNullException() { AssertExtensions.Throws<ArgumentNullException>(null, () => Marshal.GetEndComSlot(null)); } [Fact] [PlatformSpecific(TestPlatforms.Windows)] public void GetEndComSlot_NotRuntimeType_ThrowsArgumentException() { AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.Run); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module"); TypeBuilder typeBuilder = moduleBuilder.DefineType("Type"); AssertExtensions.Throws<ArgumentException>("t", () => Marshal.GetEndComSlot(typeBuilder)); } public static IEnumerable<object[]> GetStartComSlot_InvalidGenericType_TestData() { yield return new object[] { typeof(int).MakeByRefType() }; yield return new object[] { typeof(GenericClass<>).GetTypeInfo().GenericTypeParameters[0] }; } [Theory] [MemberData(nameof(GetStartComSlot_InvalidGenericType_TestData))] [PlatformSpecific(TestPlatforms.Windows)] public void GetEndComSlot_InvalidGenericType_ThrowsArgumentNullException(Type type) { AssertExtensions.Throws<ArgumentNullException>(null, () => Marshal.GetEndComSlot(type)); } public static IEnumerable<object[]> GetStartComSlot_NotComVisibleType_TestData() { yield return new object[] { typeof(GenericClass<>) }; yield return new object[] { typeof(GenericClass<string>) }; yield return new object[] { typeof(GenericStruct<>) }; yield return new object[] { typeof(GenericStruct<string>) }; yield return new object[] { typeof(IGenericInterface<>) }; yield return new object[] { typeof(IGenericInterface<string>) }; yield return new object[] { typeof(NonComVisibleClass) }; yield return new object[] { typeof(NonComVisibleStruct) }; yield return new object[] { typeof(INonComVisibleInterface) }; yield return new object[] { typeof(int[]) }; yield return new object[] { typeof(int[][]) }; yield return new object[] { typeof(int[,]) }; AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Assembly"), AssemblyBuilderAccess.RunAndCollect); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Module"); TypeBuilder typeBuilder = moduleBuilder.DefineType("Type"); Type collectibleType = typeBuilder.CreateType(); yield return new object[] { collectibleType }; } [Theory] [MemberData(nameof(GetStartComSlot_NotComVisibleType_TestData))] [PlatformSpecific(TestPlatforms.Windows)] public void GetEndComSlot_NotComVisibleType_ThrowsArgumentException(Type type) { AssertExtensions.Throws<ArgumentException>("t", () => Marshal.GetEndComSlot(type)); } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionEmitCachingMemberAccessor.Cache.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #if NETFRAMEWORK || NETCOREAPP using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Threading; namespace System.Text.Json.Serialization.Metadata { internal sealed partial class ReflectionEmitCachingMemberAccessor { private sealed class Cache<TKey> where TKey : notnull { private int _evictLock; private long _lastEvictedTicks; // timestamp of latest eviction operation. private readonly long _evictionIntervalTicks; // min timespan needed to trigger a new evict operation. private readonly long _slidingExpirationTicks; // max timespan allowed for cache entries to remain inactive. private readonly ConcurrentDictionary<TKey, CacheEntry> _cache = new(); public Cache(TimeSpan slidingExpiration, TimeSpan evictionInterval) { _slidingExpirationTicks = slidingExpiration.Ticks; _evictionIntervalTicks = evictionInterval.Ticks; _lastEvictedTicks = DateTime.UtcNow.Ticks; } public TValue GetOrAdd<TValue>(TKey key, Func<TKey, TValue> valueFactory) where TValue : class? { CacheEntry entry = _cache.GetOrAdd( key, #if NETCOREAPP static (TKey key, Func<TKey, TValue> valueFactory) => new(valueFactory(key)), valueFactory); #else key => new(valueFactory(key))); #endif long utcNowTicks = DateTime.UtcNow.Ticks; Volatile.Write(ref entry.LastUsedTicks, utcNowTicks); if (utcNowTicks - Volatile.Read(ref _lastEvictedTicks) >= _evictionIntervalTicks) { if (Interlocked.CompareExchange(ref _evictLock, 1, 0) == 0) { if (utcNowTicks - _lastEvictedTicks >= _evictionIntervalTicks) { EvictStaleCacheEntries(utcNowTicks); Volatile.Write(ref _lastEvictedTicks, utcNowTicks); } Volatile.Write(ref _evictLock, 0); } } return (TValue)entry.Value!; } public void Clear() { _cache.Clear(); _lastEvictedTicks = DateTime.UtcNow.Ticks; } private void EvictStaleCacheEntries(long utcNowTicks) { foreach (KeyValuePair<TKey, CacheEntry> kvp in _cache) { if (utcNowTicks - Volatile.Read(ref kvp.Value.LastUsedTicks) >= _slidingExpirationTicks) { _cache.TryRemove(kvp.Key, out _); } } } private class CacheEntry { public readonly object? Value; public long LastUsedTicks; public CacheEntry(object? value) { Value = value; } } } } } #endif
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #if NETFRAMEWORK || NETCOREAPP using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Threading; namespace System.Text.Json.Serialization.Metadata { internal sealed partial class ReflectionEmitCachingMemberAccessor { private sealed class Cache<TKey> where TKey : notnull { private int _evictLock; private long _lastEvictedTicks; // timestamp of latest eviction operation. private readonly long _evictionIntervalTicks; // min timespan needed to trigger a new evict operation. private readonly long _slidingExpirationTicks; // max timespan allowed for cache entries to remain inactive. private readonly ConcurrentDictionary<TKey, CacheEntry> _cache = new(); public Cache(TimeSpan slidingExpiration, TimeSpan evictionInterval) { _slidingExpirationTicks = slidingExpiration.Ticks; _evictionIntervalTicks = evictionInterval.Ticks; _lastEvictedTicks = DateTime.UtcNow.Ticks; } public TValue GetOrAdd<TValue>(TKey key, Func<TKey, TValue> valueFactory) where TValue : class? { CacheEntry entry = _cache.GetOrAdd( key, #if NETCOREAPP static (TKey key, Func<TKey, TValue> valueFactory) => new(valueFactory(key)), valueFactory); #else key => new(valueFactory(key))); #endif long utcNowTicks = DateTime.UtcNow.Ticks; Volatile.Write(ref entry.LastUsedTicks, utcNowTicks); if (utcNowTicks - Volatile.Read(ref _lastEvictedTicks) >= _evictionIntervalTicks) { if (Interlocked.CompareExchange(ref _evictLock, 1, 0) == 0) { if (utcNowTicks - _lastEvictedTicks >= _evictionIntervalTicks) { EvictStaleCacheEntries(utcNowTicks); Volatile.Write(ref _lastEvictedTicks, utcNowTicks); } Volatile.Write(ref _evictLock, 0); } } return (TValue)entry.Value!; } public void Clear() { _cache.Clear(); _lastEvictedTicks = DateTime.UtcNow.Ticks; } private void EvictStaleCacheEntries(long utcNowTicks) { foreach (KeyValuePair<TKey, CacheEntry> kvp in _cache) { if (utcNowTicks - Volatile.Read(ref kvp.Value.LastUsedTicks) >= _slidingExpirationTicks) { _cache.TryRemove(kvp.Key, out _); } } } private class CacheEntry { public readonly object? Value; public long LastUsedTicks; public CacheEntry(object? value) { Value = value; } } } } } #endif
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/mono/mono/tests/pinvoke3.cs
// // pinvoke3.cs: // // Tests for native->managed marshalling // using System; using System.Text; using System.Runtime.InteropServices; using System.Threading; public class Tests { [StructLayout (LayoutKind.Sequential)] public struct SimpleStruct { public bool a; public bool b; public bool c; public string d; [MarshalAs(UnmanagedType.LPWStr)] public string d2; } [StructLayout (LayoutKind.Sequential)] public class SimpleClass { public bool a; public bool b; public bool c; public string d; } public static SimpleStruct delegate_test_struct (SimpleStruct ss) { SimpleStruct res; res.a = !ss.a; res.b = !ss.b; res.c = !ss.c; res.d = ss.d + "-RES"; res.d2 = ss.d2 + "-RES"; return res; } public static int delegate_test_struct_byref (int a, ref SimpleStruct ss, int b) { if (a == 1 && b == 2 && ss.a && !ss.b && ss.c && ss.d == "TEST2") { ss.a = true; ss.b = true; ss.c = true; ss.d = "TEST3"; return 0; } return 1; } public static int delegate_test_struct_out (int a, out SimpleStruct ss, int b) { ss.a = true; ss.b = true; ss.c = true; ss.d = "TEST3"; ss.d2 = "TEST4"; return 0; } public static int delegate_test_struct_in (int a, [In] ref SimpleStruct ss, int b) { if (a == 1 && b == 2 && ss.a && !ss.b && ss.c && ss.d == "TEST2") { ss.a = true; ss.b = true; ss.c = true; ss.d = "TEST3"; return 0; } return 1; } public static SimpleClass delegate_test_class (SimpleClass ss) { if (ss == null) return null; if (! (!ss.a && ss.b && !ss.c && ss.d == "TEST")) return null; SimpleClass res = ss; return res; } public static int delegate_test_class_byref (ref SimpleClass ss) { if (ss == null) return -1; if (!ss.a && ss.b && !ss.c && ss.d == "TEST") { ss.a = true; ss.b = false; ss.c = true; ss.d = "RES"; return 0; } return 1; } public static int delegate_test_class_out (out SimpleClass ss) { ss = new SimpleClass (); ss.a = true; ss.b = false; ss.c = true; ss.d = "RES"; return 0; } public static int delegate_test_primitive_byref (ref int i) { if (i != 1) return 1; i = 2; return 0; } public static int delegate_test_string_marshalling (string s) { return s == "ABC" ? 0 : 1; } public static int delegate_test_string_builder_marshalling (StringBuilder s) { if (s == null) return 2; else return s.ToString () == "ABC" ? 0 : 1; } [DllImport ("libtest", EntryPoint="mono_test_ref_vtype")] public static extern int mono_test_ref_vtype (int a, ref SimpleStruct ss, int b, TestDelegate d); public delegate int OutStructDelegate (int a, out SimpleStruct ss, int b); public delegate int InStructDelegate (int a, [In] ref SimpleStruct ss, int b); [DllImport ("libtest", EntryPoint="mono_test_marshal_out_struct")] public static extern int mono_test_marshal_out_struct (int a, out SimpleStruct ss, int b, OutStructDelegate d); [DllImport ("libtest", EntryPoint="mono_test_marshal_in_struct")] public static extern int mono_test_marshal_in_struct (int a, ref SimpleStruct ss, int b, InStructDelegate d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate2")] public static extern int mono_test_marshal_delegate2 (SimpleDelegate2 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate4")] public static extern int mono_test_marshal_delegate4 (SimpleDelegate4 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate5")] public static extern int mono_test_marshal_delegate5 (SimpleDelegate5 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate6")] public static extern int mono_test_marshal_delegate6 (SimpleDelegate5 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate7")] public static extern int mono_test_marshal_delegate7 (SimpleDelegate7 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate8", CharSet=CharSet.Unicode)] public static extern int mono_test_marshal_delegate8 (SimpleDelegate8 d, string s); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate9")] public static extern int mono_test_marshal_delegate9 (SimpleDelegate9 d, return_int_delegate d2); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate10")] public static extern int mono_test_marshal_delegate10 (SimpleDelegate9 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate8")] public static extern int mono_test_marshal_delegate11 (SimpleDelegate11 d, string s); [DllImport ("libtest", EntryPoint="mono_test_marshal_primitive_byref_delegate")] public static extern int mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate d); [DllImport ("libtest", EntryPoint="mono_test_marshal_return_delegate_delegate")] public static extern int mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate_ref_delegate")] public static extern int mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del); [DllImport ("libtest", EntryPoint="mono_test_marshal_virtual_delegate")] public static extern int mono_test_marshal_virtual_delegate (VirtualDelegate del); [DllImport ("libtest", EntryPoint="mono_test_marshal_icall_delegate")] public static extern int mono_test_marshal_icall_delegate (IcallDelegate del); [DllImport ("libtest", EntryPoint="mono_test_marshal_nullable_ret_delegate")] public static extern int mono_test_marshal_nullable_ret_delegate (NullableReturnDelegate del); public delegate string IcallDelegate (IntPtr p); public delegate int TestDelegate (int a, ref SimpleStruct ss, int b); public delegate SimpleStruct SimpleDelegate2 (SimpleStruct ss); public delegate SimpleClass SimpleDelegate4 (SimpleClass ss); public delegate int SimpleDelegate5 (ref SimpleClass ss); public delegate int SimpleDelegate7 (out SimpleClass ss); public delegate int SimpleDelegate8 ([MarshalAs (UnmanagedType.LPWStr)] string s1); public delegate int return_int_delegate (int i); public delegate int SimpleDelegate9 (return_int_delegate del); public delegate int SimpleDelegate11 (StringBuilder s1); public delegate int PrimitiveByrefDelegate (ref int i); public delegate return_int_delegate ReturnDelegateDelegate (); public delegate int DelegateByrefDelegate (ref return_int_delegate del); public delegate int VirtualDelegate (int i); public delegate Nullable<int> NullableReturnDelegate (); public static int Main () { return TestDriver.RunTests (typeof (Tests)); } /* Test structures as arguments and return values of delegates */ public static int test_0_marshal_struct_delegate () { SimpleDelegate2 d = new SimpleDelegate2 (delegate_test_struct); return mono_test_marshal_delegate2 (d); } /* Test structures as byref arguments of delegates */ public static int test_0_marshal_byref_struct_delegate () { SimpleStruct ss = new SimpleStruct (); TestDelegate d = new TestDelegate (delegate_test_struct_byref); ss.b = true; ss.d = "TEST1"; if (mono_test_ref_vtype (1, ref ss, 2, d) != 0) return 1; if (! (ss.a && ss.b && ss.c && ss.d == "TEST3")) return 2; return 0; } /* Test structures as out arguments of delegates */ public static int test_0_marshal_out_struct_delegate () { SimpleStruct ss = new SimpleStruct (); OutStructDelegate d = new OutStructDelegate (delegate_test_struct_out); return mono_test_marshal_out_struct (1, out ss, 2, d); } /* Test structures as in arguments of delegates */ public static int test_0_marshal_in_struct_delegate () { SimpleStruct ss = new SimpleStruct () { a = true, b = false, c = true, d = "TEST2" }; InStructDelegate d = new InStructDelegate (delegate_test_struct_in); return mono_test_marshal_in_struct (1, ref ss, 2, d); } /* Test classes as arguments and return values of delegates */ public static int test_0_marshal_class_delegate () { SimpleDelegate4 d = new SimpleDelegate4 (delegate_test_class); return mono_test_marshal_delegate4 (d); } /* Test classes as byref arguments of delegates */ public static int test_0_marshal_byref_class_delegate () { SimpleDelegate5 d = new SimpleDelegate5 (delegate_test_class_byref); return mono_test_marshal_delegate5 (d); } /* Test classes as out arguments of delegates */ public static int test_0_marshal_out_class_delegate () { SimpleDelegate7 d = new SimpleDelegate7 (delegate_test_class_out); return mono_test_marshal_delegate7 (d); } /* Test string marshalling with delegates */ public static int test_0_marshal_string_delegate () { SimpleDelegate8 d = new SimpleDelegate8 (delegate_test_string_marshalling); return mono_test_marshal_delegate8 (d, "ABC"); } /* Test string builder marshalling with delegates */ public static int test_0_marshal_string_builder_delegate () { SimpleDelegate11 d = new SimpleDelegate11 (delegate_test_string_builder_marshalling); if (mono_test_marshal_delegate11 (d, null) != 2) return 2; return mono_test_marshal_delegate11 (d, "ABC"); } /* Test that the delegate wrapper correctly catches null byref arguments */ public static int test_0_marshal_byref_class_delegate_null () { SimpleDelegate5 d = new SimpleDelegate5 (delegate_test_class_byref); try { mono_test_marshal_delegate6 (d); return 1; } catch (ArgumentNullException ex) { return 0; } } static int return_self (int i) { return i; } static int call_int_delegate (return_int_delegate d) { return d (55); } public static int test_55_marshal_delegate_delegate () { SimpleDelegate9 d = new SimpleDelegate9 (call_int_delegate); return mono_test_marshal_delegate9 (d, new return_int_delegate (return_self)); } public static int test_0_marshal_primitive_byref_delegate () { PrimitiveByrefDelegate d = new PrimitiveByrefDelegate (delegate_test_primitive_byref); return mono_test_marshal_primitive_byref_delegate (d); } public static return_int_delegate return_delegate () { return new return_int_delegate (return_self); } public static int test_55_marshal_return_delegate_delegate () { return mono_test_marshal_return_delegate_delegate (new ReturnDelegateDelegate (return_delegate)); } public static int return_plus_1 (int i) { return i + 1; } public static int ref_delegate_delegate (ref return_int_delegate del) { del = return_plus_1; return 0; } public static int test_55_marshal_delegate_ref_delegate () { var del = new DelegateByrefDelegate (ref_delegate_delegate); return mono_test_marshal_delegate_ref_delegate (del); } /* Passing and returning strings */ public delegate String ReturnStringDelegate (String s); [DllImport ("libtest", EntryPoint="mono_test_return_string")] public static extern String mono_test_marshal_return_string_delegate (ReturnStringDelegate d); public static String managed_return_string (String s) { if (s != "TEST") return ""; else return "12345"; } public static int test_0_marshal_return_string_delegate () { ReturnStringDelegate d = new ReturnStringDelegate (managed_return_string); String s = mono_test_marshal_return_string_delegate (d); return (s == "12345") ? 0 : 1; } /* Passing and returning enums */ public enum FooEnum { Foo1, Foo2, Foo3 }; public delegate FooEnum ReturnEnumDelegate (FooEnum e); [DllImport ("libtest", EntryPoint="mono_test_marshal_return_enum_delegate")] public static extern int mono_test_marshal_return_enum_delegate (ReturnEnumDelegate d); public static FooEnum managed_return_enum (FooEnum e) { return (FooEnum)((int)e + 1); } public static int test_0_marshal_return_enum_delegate () { ReturnEnumDelegate d = new ReturnEnumDelegate (managed_return_enum); FooEnum e = (FooEnum)mono_test_marshal_return_enum_delegate (d); return e == FooEnum.Foo3 ? 0 : 1; } /* Passing and returning blittable structs */ [StructLayout (LayoutKind.Sequential)] public struct BlittableStruct { public int a, b, c; public long d; } public static BlittableStruct delegate_test_blittable_struct (BlittableStruct ss) { BlittableStruct res; res.a = -ss.a; res.b = -ss.b; res.c = -ss.c; res.d = -ss.d; return res; } public delegate BlittableStruct SimpleDelegate10 (BlittableStruct ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_blittable_struct_delegate")] public static extern int mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 d); public static int test_0_marshal_blittable_struct_delegate () { return mono_test_marshal_blittable_struct_delegate (new SimpleDelegate10 (delegate_test_blittable_struct)); } /* * Passing and returning small structs */ /* TEST 1: 4 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct1 { public int i; } public static SmallStruct1 delegate_test_struct (SmallStruct1 ss) { SmallStruct1 res; res.i = -ss.i; return res; } public delegate SmallStruct1 SmallStructDelegate1 (SmallStruct1 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate1")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate1 d); public static int test_0_marshal_small_struct_delegate1 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate1 (delegate_test_struct)); } /* TEST 2: 2+2 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct2 { public short i, j; } public static SmallStruct2 delegate_test_struct (SmallStruct2 ss) { SmallStruct2 res; res.i = (short)-ss.i; res.j = (short)-ss.j; return res; } public delegate SmallStruct2 SmallStructDelegate2 (SmallStruct2 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate2")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate2 d); public static int test_0_marshal_small_struct_delegate2 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate2 (delegate_test_struct)); } /* TEST 3: 2+1 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct3 { public short i; public byte j; } public static SmallStruct3 delegate_test_struct (SmallStruct3 ss) { SmallStruct3 res; res.i = (short)-ss.i; res.j = (byte)-ss.j; return res; } public delegate SmallStruct3 SmallStructDelegate3 (SmallStruct3 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate3")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate3 d); public static int test_0_marshal_small_struct_delegate3 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate3 (delegate_test_struct)); } /* TEST 4: 2 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct4 { public short i; } public static SmallStruct4 delegate_test_struct (SmallStruct4 ss) { SmallStruct4 res; res.i = (short)-ss.i; return res; } public delegate SmallStruct4 SmallStructDelegate4 (SmallStruct4 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate4")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate4 d); public static int test_0_marshal_small_struct_delegate4 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate4 (delegate_test_struct)); } /* TEST 5: 8 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct5 { public long l; } public static SmallStruct5 delegate_test_struct (SmallStruct5 ss) { SmallStruct5 res; res.l = -ss.l; return res; } public delegate SmallStruct5 SmallStructDelegate5 (SmallStruct5 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate5")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate5 d); public static int test_0_marshal_small_struct_delegate5 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate5 (delegate_test_struct)); } /* TEST 6: 4+4 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct6 { public int i, j; } public static SmallStruct6 delegate_test_struct (SmallStruct6 ss) { SmallStruct6 res; res.i = -ss.i; res.j = -ss.j; return res; } public delegate SmallStruct6 SmallStructDelegate6 (SmallStruct6 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate6")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate6 d); public static int test_0_marshal_small_struct_delegate6 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate6 (delegate_test_struct)); } /* TEST 7: 4+2 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct7 { public int i; public short j; } public static SmallStruct7 delegate_test_struct (SmallStruct7 ss) { SmallStruct7 res; res.i = -ss.i; res.j = (short)-ss.j; return res; } public delegate SmallStruct7 SmallStructDelegate7 (SmallStruct7 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate7")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate7 d); public static int test_0_marshal_small_struct_delegate7 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate7 (delegate_test_struct)); } /* TEST 8: 4 byte long FLOAT struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct8 { public float i; } public static SmallStruct8 delegate_test_struct (SmallStruct8 ss) { SmallStruct8 res; res.i = -ss.i; return res; } public delegate SmallStruct8 SmallStructDelegate8 (SmallStruct8 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate8")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate8 d); public static int test_0_marshal_small_struct_delegate8 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate8 (delegate_test_struct)); } /* TEST 9: 8 byte long FLOAT struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct9 { public double i; } public static SmallStruct9 delegate_test_struct (SmallStruct9 ss) { SmallStruct9 res; res.i = -ss.i; return res; } public delegate SmallStruct9 SmallStructDelegate9 (SmallStruct9 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate9")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate9 d); public static int test_0_marshal_small_struct_delegate9 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate9 (delegate_test_struct)); } /* TEST 10: 4+4 byte long FLOAT struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct10 { public float i; public float j; } public static SmallStruct10 delegate_test_struct (SmallStruct10 ss) { SmallStruct10 res; res.i = -ss.i; res.j = -ss.j; return res; } public delegate SmallStruct10 SmallStructDelegate10 (SmallStruct10 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate10")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate10 d); public static int test_0_marshal_small_struct_delegate10 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate10 (delegate_test_struct)); } /* TEST 11: 4+4 byte long MIXED struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct11 { public float i; public int j; } public static SmallStruct11 delegate_test_struct (SmallStruct11 ss) { SmallStruct11 res; res.i = -ss.i; res.j = -ss.j; return res; } public delegate SmallStruct11 SmallStructDelegate11 (SmallStruct11 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate11")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate11 d); public static int test_0_marshal_small_struct_delegate11 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate11 (delegate_test_struct)); } /* * Passing arrays */ public delegate int ArrayDelegate1 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=0)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate1 (string[] arr, int len, ArrayDelegate1 d); public static int array_delegate1 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_string () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate1 (arr, arr.Length, new ArrayDelegate1 (array_delegate1)); } public static int array_delegate2 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_null () { return mono_test_marshal_array_delegate1 (null, 0, new ArrayDelegate1 (array_delegate2)); } public delegate int ArrayDelegateBlittable (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=0)] int[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate1 (string[] arr, int len, ArrayDelegateBlittable d); public static int array_delegate_null_blittable (int i, string j, int[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_null_blittable () { return mono_test_marshal_array_delegate1 (null, 0, new ArrayDelegateBlittable (array_delegate_null_blittable)); } public delegate int ArrayDelegate3 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=3)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate3 (string[] arr, int len, ArrayDelegate3 d); public static int array_delegate3 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_bad_paramindex () { try { mono_test_marshal_array_delegate3 (null, 0, new ArrayDelegate3 (array_delegate3)); return 1; } catch (MarshalDirectiveException) { return 0; } } public delegate int ArrayDelegate4 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=1)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate4 (string[] arr, int len, ArrayDelegate4 d); public static int array_delegate4 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_bad_paramtype () { try { mono_test_marshal_array_delegate4 (null, 0, new ArrayDelegate4 (array_delegate4)); return 1; } catch (MarshalDirectiveException) { return 0; } } public delegate int ArrayDelegate4_2 (int i, string j, string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate4_2 (string[] arr, int len, ArrayDelegate4_2 d); public static int array_delegate4_2 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_no_marshal_directive () { try { mono_test_marshal_array_delegate4_2 (null, 0, new ArrayDelegate4_2 (array_delegate4_2)); return 1; } catch (MarshalDirectiveException) { return 0; } } public delegate int ArrayDelegate4_3 (int i, string j, string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate4_3 (string[] arr, int len, ArrayDelegate4_3 d); public int array_delegate4_3 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_no_marshal_directive_instance () { try { Tests t = new Tests (); mono_test_marshal_array_delegate4_3 (null, 0, new ArrayDelegate4_3 (t.array_delegate4_3)); return 1; } catch (MarshalDirectiveException) { return 0; } } public delegate int ArrayDelegate5 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPWStr, SizeParamIndex=0)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate", CharSet=CharSet.Unicode)] public static extern int mono_test_marshal_array_delegate5 (string[] arr, int len, ArrayDelegate5 d); public static int array_delegate5 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_unicode_string () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate5 (arr, arr.Length, new ArrayDelegate5 (array_delegate5)); } public delegate int ArrayDelegate6 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeConst=2)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate6 (string[] arr, int len, ArrayDelegate6 d); public static int array_delegate6 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_sizeconst () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate6 (arr, 1024, new ArrayDelegate6 (array_delegate6)); } public delegate int ArrayDelegate7 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeConst=1, SizeParamIndex=0)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate7 (string[] arr, int len, ArrayDelegate7 d); public static int array_delegate7 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_sizeconst_paramindex () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate7 (arr, 1, new ArrayDelegate7 (array_delegate7)); } public delegate int ArrayDelegate8 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] int[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate8 (int[] arr, int len, ArrayDelegate8 d); public static int array_delegate8 (int i, string j, int[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != 42) || (arr [1] != 43)) return 2; return 0; } public static int test_0_marshal_array_delegate_blittable () { int[] arr = new int [] { 42, 43 }; return mono_test_marshal_array_delegate8 (arr, 2, new ArrayDelegate8 (array_delegate8)); } /* Array with size param of type long */ public delegate int ArrayDelegate8_2 (long i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=0)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate_long")] public static extern int mono_test_marshal_array_delegate8_2 (string[] arr, long len, ArrayDelegate8_2 d); public static int array_delegate8_2 (long i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_long_param () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate8_2 (arr, arr.Length, new ArrayDelegate8_2 (array_delegate8_2)); } /* * [Out] blittable arrays */ public delegate int ArrayDelegate9 (int i, string j, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] int[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_out_array_delegate")] public static extern int mono_test_marshal_out_array_delegate (int[] arr, int len, ArrayDelegate9 d); public static int array_delegate9 (int i, string j, int[] arr) { if (arr.Length != 2) return 1; arr [0] = 1; arr [1] = 2; return 0; } public static int test_0_marshal_out_array_delegate () { int[] arr = new int [] { 42, 43 }; return mono_test_marshal_out_array_delegate (arr, 2, new ArrayDelegate9 (array_delegate9)); } /* * [Out] string arrays */ public delegate int ArrayDelegate10 (int i, string j, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeConst=2)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_out_string_array_delegate")] public static extern int mono_test_marshal_out_string_array_delegate (string[] arr, int len, ArrayDelegate10 d); public static int array_delegate10 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; arr [0] = "ABC"; arr [1] = "DEF"; return 0; } public static int test_0_marshal_out_string_array_delegate () { string[] arr = new string [] { "", "" }; return mono_test_marshal_out_string_array_delegate (arr, 2, new ArrayDelegate10 (array_delegate10)); } /* * [In, Out] classes */ public delegate int InOutByvalClassDelegate ([In, Out] SimpleClass ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_byval_class_delegate")] public static extern int mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate d); public static int delegate_test_byval_class_inout (SimpleClass ss) { if ((ss.a != false) || (ss.b != true) || (ss.c != false) || (ss.d != "FOO")) return 1; ss.a = true; ss.b = false; ss.c = true; ss.d = "RES"; return 0; } public static int test_0_marshal_inout_byval_class_delegate () { return mono_test_marshal_inout_byval_class_delegate (new InOutByvalClassDelegate (delegate_test_byval_class_inout)); } /* * Returning unicode strings */ [return: MarshalAs(UnmanagedType.LPWStr)] public delegate string ReturnUnicodeStringDelegate([MarshalAs(UnmanagedType.LPWStr)] string message); [DllImport ("libtest", EntryPoint="mono_test_marshal_return_unicode_string_delegate")] public static extern int mono_test_marshal_return_unicode_string_delegate (ReturnUnicodeStringDelegate d); public static String return_unicode_string_delegate (string message) { return message; } public static int test_0_marshal_return_unicode_string_delegate () { return mono_test_marshal_return_unicode_string_delegate (new ReturnUnicodeStringDelegate (return_unicode_string_delegate)); } /* * Returning string arrays */ public delegate string[] ReturnArrayDelegate (int i); [DllImport ("libtest", EntryPoint="mono_test_marshal_return_string_array_delegate")] public static extern int mono_test_marshal_return_string_array_delegate (ReturnArrayDelegate d); public static String[] return_array_delegate (int i) { String[] arr = new String [2]; arr [0] = "ABC"; arr [1] = "DEF"; return arr; } public static String[] return_array_delegate_null (int i) { return null; } public static int test_0_marshal_return_string_array_delegate () { return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate)); } public static int test_3_marshal_return_string_array_delegate_null () { return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate_null)); } /* * Byref string marshalling */ public delegate int ByrefStringDelegate (ref string s); [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_string_delegate")] public static extern int mono_test_marshal_byref_string_delegate (ByrefStringDelegate d); public static int byref_string_delegate (ref string s) { if (s != "ABC") return 1; s = "DEF"; return 0; } public static int test_0_marshal_byref_string_delegate () { return mono_test_marshal_byref_string_delegate (new ByrefStringDelegate (byref_string_delegate)); } /* * Thread attach */ public delegate int SimpleDelegate (int i); [DllImport ("libtest", EntryPoint="mono_test_marshal_thread_attach")] public static extern int mono_test_marshal_thread_attach (SimpleDelegate d); public static int test_43_thread_attach () { int res = mono_test_marshal_thread_attach (delegate (int i) { if (!Thread.CurrentThread.IsBackground) return 0; return i + 1; }); return res; } public struct LargeStruct { public Int16 s; public Int16 v; public UInt32 p; public UInt32 e; public Int32 l; public Int32 ll; public UInt16 h; public Int16 r; public Int16 pp; public Int32 hh; public Int32 bn; public Int32 dn; public Int32 dr; public Int32 sh; public Int32 ra; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public Int32[] angle; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public Int32[] width; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public Int32[] edge; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3 * 1024)] public byte[] echo; } public delegate int LargeStructDelegate (ref LargeStruct s); [DllImport ("libtest", EntryPoint="mono_test_marshal_thread_attach_large_vt")] public static extern int mono_test_marshal_thread_attach_large_vt (LargeStructDelegate d); public static int test_43_thread_attach_large_vt () { int res = mono_test_marshal_thread_attach_large_vt (delegate (ref LargeStruct s) { return 43; }); return res; } class Worker { volatile bool stop = false; public void Stop () { stop = true; } public void Work () { while (!stop) { for (int i = 0; i < 100; i++) { var a = new double[80000]; Thread.Sleep (1); } GC.Collect (); } } } public static int test_43_thread_attach_detach_contested () { // Test plan: we want to create a race between the GC // and native threads detaching. When a native thread // calls a managed delegate, it's attached to the // runtime by the wrapper. It is detached when the // thread is destroyed and the TLS key destructor for // MonoThreadInfo runs. That destructor wants to take // the GC lock. So we create a lot of native threads // while at the same time running a worker that // allocates garbage and invokes the collector. var w = new Worker (); Thread t = new Thread(new ThreadStart (w.Work)); t.Start (); for (int count = 0; count < 500; count++) { int res = mono_test_marshal_thread_attach (delegate (int i) { Thread.Sleep (0); return i + 1; }); } Thread.Sleep (1000); w.Stop (); t.Join (); return 43; } /* * Appdomain save/restore */ static Func<int> callback; [DllImport ("libtest", EntryPoint="mono_test_marshal_set_callback")] public static extern int mono_test_marshal_set_callback (Func<int> a); [DllImport ("libtest", EntryPoint="mono_test_marshal_call_callback")] public static extern int mono_test_marshal_call_callback (); public static int test_0_appdomain_switch () { // FIXME: The appdomain unload hangs //return 0; AppDomain ad = AppDomain.CreateDomain ("foo"); var c = (CallbackClass)ad.CreateInstanceAndUnwrap ( typeof (CallbackClass).Assembly.FullName, "Tests/CallbackClass"); c.SetCallback (); int domain_id = AppDomain.CurrentDomain.Id; int new_id = mono_test_marshal_call_callback (); int res = 0; if (new_id == domain_id) res = 1; if (AppDomain.CurrentDomain.Id != domain_id) res = 2; AppDomain.Unload (ad); return res; } static int domain_callback () { return AppDomain.CurrentDomain.Id; } class CallbackClass : MarshalByRefObject { public int SetCallback () { mono_test_marshal_set_callback (domain_callback); return 0; } } class Base { public VirtualDelegate get_del () { return delegate_test; } public virtual int delegate_test (int i) { return i; } } class Derived : Base { public override int delegate_test (int i) { return i + 1; } } public static int test_43_virtual () { Base b = new Derived (); return mono_test_marshal_virtual_delegate (b.get_del ()); } public static int test_0_icall_delegate () { var m = typeof (Marshal).GetMethod ("PtrToStringAnsi", new Type[] { typeof (IntPtr) }); return mono_test_marshal_icall_delegate ((IcallDelegate)Delegate.CreateDelegate (typeof (IcallDelegate), m)); } private static Nullable<int> nullable_ret_cb () { return 0; } public static int test_0_generic_return () { try { Marshal.GetFunctionPointerForDelegate<NullableReturnDelegate> (nullable_ret_cb); return 1; } catch (MarshalDirectiveException) { } try { mono_test_marshal_nullable_ret_delegate (nullable_ret_cb); return 2; } catch (MarshalDirectiveException) { } return 0; } }
// // pinvoke3.cs: // // Tests for native->managed marshalling // using System; using System.Text; using System.Runtime.InteropServices; using System.Threading; public class Tests { [StructLayout (LayoutKind.Sequential)] public struct SimpleStruct { public bool a; public bool b; public bool c; public string d; [MarshalAs(UnmanagedType.LPWStr)] public string d2; } [StructLayout (LayoutKind.Sequential)] public class SimpleClass { public bool a; public bool b; public bool c; public string d; } public static SimpleStruct delegate_test_struct (SimpleStruct ss) { SimpleStruct res; res.a = !ss.a; res.b = !ss.b; res.c = !ss.c; res.d = ss.d + "-RES"; res.d2 = ss.d2 + "-RES"; return res; } public static int delegate_test_struct_byref (int a, ref SimpleStruct ss, int b) { if (a == 1 && b == 2 && ss.a && !ss.b && ss.c && ss.d == "TEST2") { ss.a = true; ss.b = true; ss.c = true; ss.d = "TEST3"; return 0; } return 1; } public static int delegate_test_struct_out (int a, out SimpleStruct ss, int b) { ss.a = true; ss.b = true; ss.c = true; ss.d = "TEST3"; ss.d2 = "TEST4"; return 0; } public static int delegate_test_struct_in (int a, [In] ref SimpleStruct ss, int b) { if (a == 1 && b == 2 && ss.a && !ss.b && ss.c && ss.d == "TEST2") { ss.a = true; ss.b = true; ss.c = true; ss.d = "TEST3"; return 0; } return 1; } public static SimpleClass delegate_test_class (SimpleClass ss) { if (ss == null) return null; if (! (!ss.a && ss.b && !ss.c && ss.d == "TEST")) return null; SimpleClass res = ss; return res; } public static int delegate_test_class_byref (ref SimpleClass ss) { if (ss == null) return -1; if (!ss.a && ss.b && !ss.c && ss.d == "TEST") { ss.a = true; ss.b = false; ss.c = true; ss.d = "RES"; return 0; } return 1; } public static int delegate_test_class_out (out SimpleClass ss) { ss = new SimpleClass (); ss.a = true; ss.b = false; ss.c = true; ss.d = "RES"; return 0; } public static int delegate_test_primitive_byref (ref int i) { if (i != 1) return 1; i = 2; return 0; } public static int delegate_test_string_marshalling (string s) { return s == "ABC" ? 0 : 1; } public static int delegate_test_string_builder_marshalling (StringBuilder s) { if (s == null) return 2; else return s.ToString () == "ABC" ? 0 : 1; } [DllImport ("libtest", EntryPoint="mono_test_ref_vtype")] public static extern int mono_test_ref_vtype (int a, ref SimpleStruct ss, int b, TestDelegate d); public delegate int OutStructDelegate (int a, out SimpleStruct ss, int b); public delegate int InStructDelegate (int a, [In] ref SimpleStruct ss, int b); [DllImport ("libtest", EntryPoint="mono_test_marshal_out_struct")] public static extern int mono_test_marshal_out_struct (int a, out SimpleStruct ss, int b, OutStructDelegate d); [DllImport ("libtest", EntryPoint="mono_test_marshal_in_struct")] public static extern int mono_test_marshal_in_struct (int a, ref SimpleStruct ss, int b, InStructDelegate d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate2")] public static extern int mono_test_marshal_delegate2 (SimpleDelegate2 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate4")] public static extern int mono_test_marshal_delegate4 (SimpleDelegate4 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate5")] public static extern int mono_test_marshal_delegate5 (SimpleDelegate5 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate6")] public static extern int mono_test_marshal_delegate6 (SimpleDelegate5 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate7")] public static extern int mono_test_marshal_delegate7 (SimpleDelegate7 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate8", CharSet=CharSet.Unicode)] public static extern int mono_test_marshal_delegate8 (SimpleDelegate8 d, string s); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate9")] public static extern int mono_test_marshal_delegate9 (SimpleDelegate9 d, return_int_delegate d2); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate10")] public static extern int mono_test_marshal_delegate10 (SimpleDelegate9 d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate8")] public static extern int mono_test_marshal_delegate11 (SimpleDelegate11 d, string s); [DllImport ("libtest", EntryPoint="mono_test_marshal_primitive_byref_delegate")] public static extern int mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate d); [DllImport ("libtest", EntryPoint="mono_test_marshal_return_delegate_delegate")] public static extern int mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d); [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate_ref_delegate")] public static extern int mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del); [DllImport ("libtest", EntryPoint="mono_test_marshal_virtual_delegate")] public static extern int mono_test_marshal_virtual_delegate (VirtualDelegate del); [DllImport ("libtest", EntryPoint="mono_test_marshal_icall_delegate")] public static extern int mono_test_marshal_icall_delegate (IcallDelegate del); [DllImport ("libtest", EntryPoint="mono_test_marshal_nullable_ret_delegate")] public static extern int mono_test_marshal_nullable_ret_delegate (NullableReturnDelegate del); public delegate string IcallDelegate (IntPtr p); public delegate int TestDelegate (int a, ref SimpleStruct ss, int b); public delegate SimpleStruct SimpleDelegate2 (SimpleStruct ss); public delegate SimpleClass SimpleDelegate4 (SimpleClass ss); public delegate int SimpleDelegate5 (ref SimpleClass ss); public delegate int SimpleDelegate7 (out SimpleClass ss); public delegate int SimpleDelegate8 ([MarshalAs (UnmanagedType.LPWStr)] string s1); public delegate int return_int_delegate (int i); public delegate int SimpleDelegate9 (return_int_delegate del); public delegate int SimpleDelegate11 (StringBuilder s1); public delegate int PrimitiveByrefDelegate (ref int i); public delegate return_int_delegate ReturnDelegateDelegate (); public delegate int DelegateByrefDelegate (ref return_int_delegate del); public delegate int VirtualDelegate (int i); public delegate Nullable<int> NullableReturnDelegate (); public static int Main () { return TestDriver.RunTests (typeof (Tests)); } /* Test structures as arguments and return values of delegates */ public static int test_0_marshal_struct_delegate () { SimpleDelegate2 d = new SimpleDelegate2 (delegate_test_struct); return mono_test_marshal_delegate2 (d); } /* Test structures as byref arguments of delegates */ public static int test_0_marshal_byref_struct_delegate () { SimpleStruct ss = new SimpleStruct (); TestDelegate d = new TestDelegate (delegate_test_struct_byref); ss.b = true; ss.d = "TEST1"; if (mono_test_ref_vtype (1, ref ss, 2, d) != 0) return 1; if (! (ss.a && ss.b && ss.c && ss.d == "TEST3")) return 2; return 0; } /* Test structures as out arguments of delegates */ public static int test_0_marshal_out_struct_delegate () { SimpleStruct ss = new SimpleStruct (); OutStructDelegate d = new OutStructDelegate (delegate_test_struct_out); return mono_test_marshal_out_struct (1, out ss, 2, d); } /* Test structures as in arguments of delegates */ public static int test_0_marshal_in_struct_delegate () { SimpleStruct ss = new SimpleStruct () { a = true, b = false, c = true, d = "TEST2" }; InStructDelegate d = new InStructDelegate (delegate_test_struct_in); return mono_test_marshal_in_struct (1, ref ss, 2, d); } /* Test classes as arguments and return values of delegates */ public static int test_0_marshal_class_delegate () { SimpleDelegate4 d = new SimpleDelegate4 (delegate_test_class); return mono_test_marshal_delegate4 (d); } /* Test classes as byref arguments of delegates */ public static int test_0_marshal_byref_class_delegate () { SimpleDelegate5 d = new SimpleDelegate5 (delegate_test_class_byref); return mono_test_marshal_delegate5 (d); } /* Test classes as out arguments of delegates */ public static int test_0_marshal_out_class_delegate () { SimpleDelegate7 d = new SimpleDelegate7 (delegate_test_class_out); return mono_test_marshal_delegate7 (d); } /* Test string marshalling with delegates */ public static int test_0_marshal_string_delegate () { SimpleDelegate8 d = new SimpleDelegate8 (delegate_test_string_marshalling); return mono_test_marshal_delegate8 (d, "ABC"); } /* Test string builder marshalling with delegates */ public static int test_0_marshal_string_builder_delegate () { SimpleDelegate11 d = new SimpleDelegate11 (delegate_test_string_builder_marshalling); if (mono_test_marshal_delegate11 (d, null) != 2) return 2; return mono_test_marshal_delegate11 (d, "ABC"); } /* Test that the delegate wrapper correctly catches null byref arguments */ public static int test_0_marshal_byref_class_delegate_null () { SimpleDelegate5 d = new SimpleDelegate5 (delegate_test_class_byref); try { mono_test_marshal_delegate6 (d); return 1; } catch (ArgumentNullException ex) { return 0; } } static int return_self (int i) { return i; } static int call_int_delegate (return_int_delegate d) { return d (55); } public static int test_55_marshal_delegate_delegate () { SimpleDelegate9 d = new SimpleDelegate9 (call_int_delegate); return mono_test_marshal_delegate9 (d, new return_int_delegate (return_self)); } public static int test_0_marshal_primitive_byref_delegate () { PrimitiveByrefDelegate d = new PrimitiveByrefDelegate (delegate_test_primitive_byref); return mono_test_marshal_primitive_byref_delegate (d); } public static return_int_delegate return_delegate () { return new return_int_delegate (return_self); } public static int test_55_marshal_return_delegate_delegate () { return mono_test_marshal_return_delegate_delegate (new ReturnDelegateDelegate (return_delegate)); } public static int return_plus_1 (int i) { return i + 1; } public static int ref_delegate_delegate (ref return_int_delegate del) { del = return_plus_1; return 0; } public static int test_55_marshal_delegate_ref_delegate () { var del = new DelegateByrefDelegate (ref_delegate_delegate); return mono_test_marshal_delegate_ref_delegate (del); } /* Passing and returning strings */ public delegate String ReturnStringDelegate (String s); [DllImport ("libtest", EntryPoint="mono_test_return_string")] public static extern String mono_test_marshal_return_string_delegate (ReturnStringDelegate d); public static String managed_return_string (String s) { if (s != "TEST") return ""; else return "12345"; } public static int test_0_marshal_return_string_delegate () { ReturnStringDelegate d = new ReturnStringDelegate (managed_return_string); String s = mono_test_marshal_return_string_delegate (d); return (s == "12345") ? 0 : 1; } /* Passing and returning enums */ public enum FooEnum { Foo1, Foo2, Foo3 }; public delegate FooEnum ReturnEnumDelegate (FooEnum e); [DllImport ("libtest", EntryPoint="mono_test_marshal_return_enum_delegate")] public static extern int mono_test_marshal_return_enum_delegate (ReturnEnumDelegate d); public static FooEnum managed_return_enum (FooEnum e) { return (FooEnum)((int)e + 1); } public static int test_0_marshal_return_enum_delegate () { ReturnEnumDelegate d = new ReturnEnumDelegate (managed_return_enum); FooEnum e = (FooEnum)mono_test_marshal_return_enum_delegate (d); return e == FooEnum.Foo3 ? 0 : 1; } /* Passing and returning blittable structs */ [StructLayout (LayoutKind.Sequential)] public struct BlittableStruct { public int a, b, c; public long d; } public static BlittableStruct delegate_test_blittable_struct (BlittableStruct ss) { BlittableStruct res; res.a = -ss.a; res.b = -ss.b; res.c = -ss.c; res.d = -ss.d; return res; } public delegate BlittableStruct SimpleDelegate10 (BlittableStruct ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_blittable_struct_delegate")] public static extern int mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 d); public static int test_0_marshal_blittable_struct_delegate () { return mono_test_marshal_blittable_struct_delegate (new SimpleDelegate10 (delegate_test_blittable_struct)); } /* * Passing and returning small structs */ /* TEST 1: 4 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct1 { public int i; } public static SmallStruct1 delegate_test_struct (SmallStruct1 ss) { SmallStruct1 res; res.i = -ss.i; return res; } public delegate SmallStruct1 SmallStructDelegate1 (SmallStruct1 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate1")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate1 d); public static int test_0_marshal_small_struct_delegate1 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate1 (delegate_test_struct)); } /* TEST 2: 2+2 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct2 { public short i, j; } public static SmallStruct2 delegate_test_struct (SmallStruct2 ss) { SmallStruct2 res; res.i = (short)-ss.i; res.j = (short)-ss.j; return res; } public delegate SmallStruct2 SmallStructDelegate2 (SmallStruct2 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate2")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate2 d); public static int test_0_marshal_small_struct_delegate2 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate2 (delegate_test_struct)); } /* TEST 3: 2+1 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct3 { public short i; public byte j; } public static SmallStruct3 delegate_test_struct (SmallStruct3 ss) { SmallStruct3 res; res.i = (short)-ss.i; res.j = (byte)-ss.j; return res; } public delegate SmallStruct3 SmallStructDelegate3 (SmallStruct3 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate3")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate3 d); public static int test_0_marshal_small_struct_delegate3 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate3 (delegate_test_struct)); } /* TEST 4: 2 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct4 { public short i; } public static SmallStruct4 delegate_test_struct (SmallStruct4 ss) { SmallStruct4 res; res.i = (short)-ss.i; return res; } public delegate SmallStruct4 SmallStructDelegate4 (SmallStruct4 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate4")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate4 d); public static int test_0_marshal_small_struct_delegate4 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate4 (delegate_test_struct)); } /* TEST 5: 8 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct5 { public long l; } public static SmallStruct5 delegate_test_struct (SmallStruct5 ss) { SmallStruct5 res; res.l = -ss.l; return res; } public delegate SmallStruct5 SmallStructDelegate5 (SmallStruct5 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate5")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate5 d); public static int test_0_marshal_small_struct_delegate5 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate5 (delegate_test_struct)); } /* TEST 6: 4+4 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct6 { public int i, j; } public static SmallStruct6 delegate_test_struct (SmallStruct6 ss) { SmallStruct6 res; res.i = -ss.i; res.j = -ss.j; return res; } public delegate SmallStruct6 SmallStructDelegate6 (SmallStruct6 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate6")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate6 d); public static int test_0_marshal_small_struct_delegate6 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate6 (delegate_test_struct)); } /* TEST 7: 4+2 byte long INTEGER struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct7 { public int i; public short j; } public static SmallStruct7 delegate_test_struct (SmallStruct7 ss) { SmallStruct7 res; res.i = -ss.i; res.j = (short)-ss.j; return res; } public delegate SmallStruct7 SmallStructDelegate7 (SmallStruct7 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate7")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate7 d); public static int test_0_marshal_small_struct_delegate7 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate7 (delegate_test_struct)); } /* TEST 8: 4 byte long FLOAT struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct8 { public float i; } public static SmallStruct8 delegate_test_struct (SmallStruct8 ss) { SmallStruct8 res; res.i = -ss.i; return res; } public delegate SmallStruct8 SmallStructDelegate8 (SmallStruct8 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate8")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate8 d); public static int test_0_marshal_small_struct_delegate8 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate8 (delegate_test_struct)); } /* TEST 9: 8 byte long FLOAT struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct9 { public double i; } public static SmallStruct9 delegate_test_struct (SmallStruct9 ss) { SmallStruct9 res; res.i = -ss.i; return res; } public delegate SmallStruct9 SmallStructDelegate9 (SmallStruct9 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate9")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate9 d); public static int test_0_marshal_small_struct_delegate9 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate9 (delegate_test_struct)); } /* TEST 10: 4+4 byte long FLOAT struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct10 { public float i; public float j; } public static SmallStruct10 delegate_test_struct (SmallStruct10 ss) { SmallStruct10 res; res.i = -ss.i; res.j = -ss.j; return res; } public delegate SmallStruct10 SmallStructDelegate10 (SmallStruct10 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate10")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate10 d); public static int test_0_marshal_small_struct_delegate10 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate10 (delegate_test_struct)); } /* TEST 11: 4+4 byte long MIXED struct */ [StructLayout (LayoutKind.Sequential)] public struct SmallStruct11 { public float i; public int j; } public static SmallStruct11 delegate_test_struct (SmallStruct11 ss) { SmallStruct11 res; res.i = -ss.i; res.j = -ss.j; return res; } public delegate SmallStruct11 SmallStructDelegate11 (SmallStruct11 ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_small_struct_delegate11")] public static extern int mono_test_marshal_small_struct_delegate (SmallStructDelegate11 d); public static int test_0_marshal_small_struct_delegate11 () { return mono_test_marshal_small_struct_delegate (new SmallStructDelegate11 (delegate_test_struct)); } /* * Passing arrays */ public delegate int ArrayDelegate1 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=0)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate1 (string[] arr, int len, ArrayDelegate1 d); public static int array_delegate1 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_string () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate1 (arr, arr.Length, new ArrayDelegate1 (array_delegate1)); } public static int array_delegate2 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_null () { return mono_test_marshal_array_delegate1 (null, 0, new ArrayDelegate1 (array_delegate2)); } public delegate int ArrayDelegateBlittable (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=0)] int[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate1 (string[] arr, int len, ArrayDelegateBlittable d); public static int array_delegate_null_blittable (int i, string j, int[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_null_blittable () { return mono_test_marshal_array_delegate1 (null, 0, new ArrayDelegateBlittable (array_delegate_null_blittable)); } public delegate int ArrayDelegate3 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=3)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate3 (string[] arr, int len, ArrayDelegate3 d); public static int array_delegate3 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_bad_paramindex () { try { mono_test_marshal_array_delegate3 (null, 0, new ArrayDelegate3 (array_delegate3)); return 1; } catch (MarshalDirectiveException) { return 0; } } public delegate int ArrayDelegate4 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=1)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate4 (string[] arr, int len, ArrayDelegate4 d); public static int array_delegate4 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_bad_paramtype () { try { mono_test_marshal_array_delegate4 (null, 0, new ArrayDelegate4 (array_delegate4)); return 1; } catch (MarshalDirectiveException) { return 0; } } public delegate int ArrayDelegate4_2 (int i, string j, string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate4_2 (string[] arr, int len, ArrayDelegate4_2 d); public static int array_delegate4_2 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_no_marshal_directive () { try { mono_test_marshal_array_delegate4_2 (null, 0, new ArrayDelegate4_2 (array_delegate4_2)); return 1; } catch (MarshalDirectiveException) { return 0; } } public delegate int ArrayDelegate4_3 (int i, string j, string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate4_3 (string[] arr, int len, ArrayDelegate4_3 d); public int array_delegate4_3 (int i, string j, string[] arr) { return (arr == null) ? 0 : 1; } public static int test_0_marshal_array_delegate_no_marshal_directive_instance () { try { Tests t = new Tests (); mono_test_marshal_array_delegate4_3 (null, 0, new ArrayDelegate4_3 (t.array_delegate4_3)); return 1; } catch (MarshalDirectiveException) { return 0; } } public delegate int ArrayDelegate5 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPWStr, SizeParamIndex=0)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate", CharSet=CharSet.Unicode)] public static extern int mono_test_marshal_array_delegate5 (string[] arr, int len, ArrayDelegate5 d); public static int array_delegate5 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_unicode_string () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate5 (arr, arr.Length, new ArrayDelegate5 (array_delegate5)); } public delegate int ArrayDelegate6 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeConst=2)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate6 (string[] arr, int len, ArrayDelegate6 d); public static int array_delegate6 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_sizeconst () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate6 (arr, 1024, new ArrayDelegate6 (array_delegate6)); } public delegate int ArrayDelegate7 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeConst=1, SizeParamIndex=0)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate7 (string[] arr, int len, ArrayDelegate7 d); public static int array_delegate7 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_sizeconst_paramindex () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate7 (arr, 1, new ArrayDelegate7 (array_delegate7)); } public delegate int ArrayDelegate8 (int i, string j, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] int[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate")] public static extern int mono_test_marshal_array_delegate8 (int[] arr, int len, ArrayDelegate8 d); public static int array_delegate8 (int i, string j, int[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != 42) || (arr [1] != 43)) return 2; return 0; } public static int test_0_marshal_array_delegate_blittable () { int[] arr = new int [] { 42, 43 }; return mono_test_marshal_array_delegate8 (arr, 2, new ArrayDelegate8 (array_delegate8)); } /* Array with size param of type long */ public delegate int ArrayDelegate8_2 (long i, string j, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeParamIndex=0)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate_long")] public static extern int mono_test_marshal_array_delegate8_2 (string[] arr, long len, ArrayDelegate8_2 d); public static int array_delegate8_2 (long i, string j, string[] arr) { if (arr.Length != 2) return 1; if ((arr [0] != "ABC") || (arr [1] != "DEF")) return 2; return 0; } public static int test_0_marshal_array_delegate_long_param () { string[] arr = new string [] { "ABC", "DEF" }; return mono_test_marshal_array_delegate8_2 (arr, arr.Length, new ArrayDelegate8_2 (array_delegate8_2)); } /* * [Out] blittable arrays */ public delegate int ArrayDelegate9 (int i, string j, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] int[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_out_array_delegate")] public static extern int mono_test_marshal_out_array_delegate (int[] arr, int len, ArrayDelegate9 d); public static int array_delegate9 (int i, string j, int[] arr) { if (arr.Length != 2) return 1; arr [0] = 1; arr [1] = 2; return 0; } public static int test_0_marshal_out_array_delegate () { int[] arr = new int [] { 42, 43 }; return mono_test_marshal_out_array_delegate (arr, 2, new ArrayDelegate9 (array_delegate9)); } /* * [Out] string arrays */ public delegate int ArrayDelegate10 (int i, string j, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr, SizeConst=2)] string[] arr); [DllImport ("libtest", EntryPoint="mono_test_marshal_out_string_array_delegate")] public static extern int mono_test_marshal_out_string_array_delegate (string[] arr, int len, ArrayDelegate10 d); public static int array_delegate10 (int i, string j, string[] arr) { if (arr.Length != 2) return 1; arr [0] = "ABC"; arr [1] = "DEF"; return 0; } public static int test_0_marshal_out_string_array_delegate () { string[] arr = new string [] { "", "" }; return mono_test_marshal_out_string_array_delegate (arr, 2, new ArrayDelegate10 (array_delegate10)); } /* * [In, Out] classes */ public delegate int InOutByvalClassDelegate ([In, Out] SimpleClass ss); [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_byval_class_delegate")] public static extern int mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate d); public static int delegate_test_byval_class_inout (SimpleClass ss) { if ((ss.a != false) || (ss.b != true) || (ss.c != false) || (ss.d != "FOO")) return 1; ss.a = true; ss.b = false; ss.c = true; ss.d = "RES"; return 0; } public static int test_0_marshal_inout_byval_class_delegate () { return mono_test_marshal_inout_byval_class_delegate (new InOutByvalClassDelegate (delegate_test_byval_class_inout)); } /* * Returning unicode strings */ [return: MarshalAs(UnmanagedType.LPWStr)] public delegate string ReturnUnicodeStringDelegate([MarshalAs(UnmanagedType.LPWStr)] string message); [DllImport ("libtest", EntryPoint="mono_test_marshal_return_unicode_string_delegate")] public static extern int mono_test_marshal_return_unicode_string_delegate (ReturnUnicodeStringDelegate d); public static String return_unicode_string_delegate (string message) { return message; } public static int test_0_marshal_return_unicode_string_delegate () { return mono_test_marshal_return_unicode_string_delegate (new ReturnUnicodeStringDelegate (return_unicode_string_delegate)); } /* * Returning string arrays */ public delegate string[] ReturnArrayDelegate (int i); [DllImport ("libtest", EntryPoint="mono_test_marshal_return_string_array_delegate")] public static extern int mono_test_marshal_return_string_array_delegate (ReturnArrayDelegate d); public static String[] return_array_delegate (int i) { String[] arr = new String [2]; arr [0] = "ABC"; arr [1] = "DEF"; return arr; } public static String[] return_array_delegate_null (int i) { return null; } public static int test_0_marshal_return_string_array_delegate () { return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate)); } public static int test_3_marshal_return_string_array_delegate_null () { return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate_null)); } /* * Byref string marshalling */ public delegate int ByrefStringDelegate (ref string s); [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_string_delegate")] public static extern int mono_test_marshal_byref_string_delegate (ByrefStringDelegate d); public static int byref_string_delegate (ref string s) { if (s != "ABC") return 1; s = "DEF"; return 0; } public static int test_0_marshal_byref_string_delegate () { return mono_test_marshal_byref_string_delegate (new ByrefStringDelegate (byref_string_delegate)); } /* * Thread attach */ public delegate int SimpleDelegate (int i); [DllImport ("libtest", EntryPoint="mono_test_marshal_thread_attach")] public static extern int mono_test_marshal_thread_attach (SimpleDelegate d); public static int test_43_thread_attach () { int res = mono_test_marshal_thread_attach (delegate (int i) { if (!Thread.CurrentThread.IsBackground) return 0; return i + 1; }); return res; } public struct LargeStruct { public Int16 s; public Int16 v; public UInt32 p; public UInt32 e; public Int32 l; public Int32 ll; public UInt16 h; public Int16 r; public Int16 pp; public Int32 hh; public Int32 bn; public Int32 dn; public Int32 dr; public Int32 sh; public Int32 ra; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public Int32[] angle; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public Int32[] width; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public Int32[] edge; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3 * 1024)] public byte[] echo; } public delegate int LargeStructDelegate (ref LargeStruct s); [DllImport ("libtest", EntryPoint="mono_test_marshal_thread_attach_large_vt")] public static extern int mono_test_marshal_thread_attach_large_vt (LargeStructDelegate d); public static int test_43_thread_attach_large_vt () { int res = mono_test_marshal_thread_attach_large_vt (delegate (ref LargeStruct s) { return 43; }); return res; } class Worker { volatile bool stop = false; public void Stop () { stop = true; } public void Work () { while (!stop) { for (int i = 0; i < 100; i++) { var a = new double[80000]; Thread.Sleep (1); } GC.Collect (); } } } public static int test_43_thread_attach_detach_contested () { // Test plan: we want to create a race between the GC // and native threads detaching. When a native thread // calls a managed delegate, it's attached to the // runtime by the wrapper. It is detached when the // thread is destroyed and the TLS key destructor for // MonoThreadInfo runs. That destructor wants to take // the GC lock. So we create a lot of native threads // while at the same time running a worker that // allocates garbage and invokes the collector. var w = new Worker (); Thread t = new Thread(new ThreadStart (w.Work)); t.Start (); for (int count = 0; count < 500; count++) { int res = mono_test_marshal_thread_attach (delegate (int i) { Thread.Sleep (0); return i + 1; }); } Thread.Sleep (1000); w.Stop (); t.Join (); return 43; } /* * Appdomain save/restore */ static Func<int> callback; [DllImport ("libtest", EntryPoint="mono_test_marshal_set_callback")] public static extern int mono_test_marshal_set_callback (Func<int> a); [DllImport ("libtest", EntryPoint="mono_test_marshal_call_callback")] public static extern int mono_test_marshal_call_callback (); public static int test_0_appdomain_switch () { // FIXME: The appdomain unload hangs //return 0; AppDomain ad = AppDomain.CreateDomain ("foo"); var c = (CallbackClass)ad.CreateInstanceAndUnwrap ( typeof (CallbackClass).Assembly.FullName, "Tests/CallbackClass"); c.SetCallback (); int domain_id = AppDomain.CurrentDomain.Id; int new_id = mono_test_marshal_call_callback (); int res = 0; if (new_id == domain_id) res = 1; if (AppDomain.CurrentDomain.Id != domain_id) res = 2; AppDomain.Unload (ad); return res; } static int domain_callback () { return AppDomain.CurrentDomain.Id; } class CallbackClass : MarshalByRefObject { public int SetCallback () { mono_test_marshal_set_callback (domain_callback); return 0; } } class Base { public VirtualDelegate get_del () { return delegate_test; } public virtual int delegate_test (int i) { return i; } } class Derived : Base { public override int delegate_test (int i) { return i + 1; } } public static int test_43_virtual () { Base b = new Derived (); return mono_test_marshal_virtual_delegate (b.get_del ()); } public static int test_0_icall_delegate () { var m = typeof (Marshal).GetMethod ("PtrToStringAnsi", new Type[] { typeof (IntPtr) }); return mono_test_marshal_icall_delegate ((IcallDelegate)Delegate.CreateDelegate (typeof (IcallDelegate), m)); } private static Nullable<int> nullable_ret_cb () { return 0; } public static int test_0_generic_return () { try { Marshal.GetFunctionPointerForDelegate<NullableReturnDelegate> (nullable_ret_cb); return 1; } catch (MarshalDirectiveException) { } try { mono_test_marshal_nullable_ret_delegate (nullable_ret_cb); return 2; } catch (MarshalDirectiveException) { } return 0; } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.Private.CoreLib/src/System/IO/MatchCasing.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.IO { /// <summary>Specifies the type of character casing to match.</summary> public enum MatchCasing { /// <summary>Matches using the default casing for the given platform.</summary> PlatformDefault, /// <summary>Matches respecting character casing.</summary> CaseSensitive, /// <summary>Matches ignoring character casing.</summary> CaseInsensitive } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.IO { /// <summary>Specifies the type of character casing to match.</summary> public enum MatchCasing { /// <summary>Matches using the default casing for the given platform.</summary> PlatformDefault, /// <summary>Matches respecting character casing.</summary> CaseSensitive, /// <summary>Matches ignoring character casing.</summary> CaseInsensitive } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.ComponentModel.Annotations/tests/System/ComponentModel/DataAnnotations/Schema/InversePropertyAttributeTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.ComponentModel.DataAnnotations.Schema.Tests { public class InversePropertyAttributeTests { [Theory] [InlineData("Gammer Brevis")] public static void Ctor_String(string property) { InversePropertyAttribute attribute = new InversePropertyAttribute(property); Assert.Equal(property, attribute.Property); } [Theory] [InlineData(null)] [InlineData("")] [InlineData(" \t\r\n")] public static void Ctor_String_NullOrWhitespaceProperty_ThrowsArgumentException(string property) { AssertExtensions.Throws<ArgumentException>("property", null, () => new InversePropertyAttribute(property)); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Xunit; namespace System.ComponentModel.DataAnnotations.Schema.Tests { public class InversePropertyAttributeTests { [Theory] [InlineData("Gammer Brevis")] public static void Ctor_String(string property) { InversePropertyAttribute attribute = new InversePropertyAttribute(property); Assert.Equal(property, attribute.Property); } [Theory] [InlineData(null)] [InlineData("")] [InlineData(" \t\r\n")] public static void Ctor_String_NullOrWhitespaceProperty_ThrowsArgumentException(string property) { AssertExtensions.Throws<ArgumentException>("property", null, () => new InversePropertyAttribute(property)); } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/SpherePacket.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System.Runtime.Intrinsics.X86; using static System.Runtime.Intrinsics.X86.Avx; using System.Runtime.Intrinsics; using System.Runtime.CompilerServices; internal sealed class SpherePacket256 : ObjectPacket256 { public VectorPacket256 Centers; public Vector256<float> Radiuses; [MethodImpl(MethodImplOptions.AggressiveInlining)] public SpherePacket256(VectorPacket256 centers, Vector256<float> radiuses, Surface surface) : base(surface) { Centers = centers; Radiuses = radiuses; } public override VectorPacket256 Normals(VectorPacket256 pos) { return (pos - Centers).Normalize(); } public override Vector256<float> Intersect(RayPacket256 rayPacket256) { var eo = Centers - rayPacket256.Starts; var v = VectorPacket256.DotProduct(eo, rayPacket256.Dirs); var zero = Vector256<float>.Zero; var vLessZeroMask = Compare(v, zero, FloatComparisonMode.OrderedLessThanNonSignaling); var discs = Subtract(Multiply(Radiuses, Radiuses), Subtract(VectorPacket256.DotProduct(eo, eo), Multiply(v, v))); var discLessZeroMask = Compare(discs, zero, FloatComparisonMode.OrderedLessThanNonSignaling); var dists = BlendVariable(Subtract(v, Sqrt(discs)), zero, Or(vLessZeroMask, discLessZeroMask)); var isZero = Compare(dists, zero, FloatComparisonMode.OrderedEqualNonSignaling); return BlendVariable(dists, Intersections.NullDistance, isZero); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System.Runtime.Intrinsics.X86; using static System.Runtime.Intrinsics.X86.Avx; using System.Runtime.Intrinsics; using System.Runtime.CompilerServices; internal sealed class SpherePacket256 : ObjectPacket256 { public VectorPacket256 Centers; public Vector256<float> Radiuses; [MethodImpl(MethodImplOptions.AggressiveInlining)] public SpherePacket256(VectorPacket256 centers, Vector256<float> radiuses, Surface surface) : base(surface) { Centers = centers; Radiuses = radiuses; } public override VectorPacket256 Normals(VectorPacket256 pos) { return (pos - Centers).Normalize(); } public override Vector256<float> Intersect(RayPacket256 rayPacket256) { var eo = Centers - rayPacket256.Starts; var v = VectorPacket256.DotProduct(eo, rayPacket256.Dirs); var zero = Vector256<float>.Zero; var vLessZeroMask = Compare(v, zero, FloatComparisonMode.OrderedLessThanNonSignaling); var discs = Subtract(Multiply(Radiuses, Radiuses), Subtract(VectorPacket256.DotProduct(eo, eo), Multiply(v, v))); var discLessZeroMask = Compare(discs, zero, FloatComparisonMode.OrderedLessThanNonSignaling); var dists = BlendVariable(Subtract(v, Sqrt(discs)), zero, Or(vLessZeroMask, discLessZeroMask)); var isZero = Compare(dists, zero, FloatComparisonMode.OrderedEqualNonSignaling); return BlendVariable(dists, Intersections.NullDistance, isZero); } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd.Arm64/TransposeEven.Vector128.Byte.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void TransposeEven_Vector128_Byte() { var test = new SimpleBinaryOpTest__TransposeEven_Vector128_Byte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__TransposeEven_Vector128_Byte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, Byte[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Byte> _fld1; public Vector128<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__TransposeEven_Vector128_Byte testClass) { var result = AdvSimd.Arm64.TransposeEven(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__TransposeEven_Vector128_Byte testClass) { fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector128<Byte> _clsVar1; private static Vector128<Byte> _clsVar2; private Vector128<Byte> _fld1; private Vector128<Byte> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__TransposeEven_Vector128_Byte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); } public SimpleBinaryOpTest__TransposeEven_Vector128_Byte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, new Byte[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.Arm64.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.Arm64.TransposeEven( Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.TransposeEven), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.TransposeEven), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.Arm64.TransposeEven( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Byte>* pClsVar1 = &_clsVar1) fixed (Vector128<Byte>* pClsVar2 = &_clsVar2) { var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(pClsVar1)), AdvSimd.LoadVector128((Byte*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr); var result = AdvSimd.Arm64.TransposeEven(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); var result = AdvSimd.Arm64.TransposeEven(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__TransposeEven_Vector128_Byte(); var result = AdvSimd.Arm64.TransposeEven(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__TransposeEven_Vector128_Byte(); fixed (Vector128<Byte>* pFld1 = &test._fld1) fixed (Vector128<Byte>* pFld2 = &test._fld2) { var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.Arm64.TransposeEven(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.TransposeEven(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(&test._fld1)), AdvSimd.LoadVector128((Byte*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Byte> op1, Vector128<Byte> op2, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") { bool succeeded = true; int index = 0; int half = RetElementCount / 2; for (var i = 0; i < RetElementCount; i+=2, index++) { if (result[index] != left[i] || result[++index] != right[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.TransposeEven)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void TransposeEven_Vector128_Byte() { var test = new SimpleBinaryOpTest__TransposeEven_Vector128_Byte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__TransposeEven_Vector128_Byte { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Byte[] inArray1, Byte[] inArray2, Byte[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Byte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Byte>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Byte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Byte, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Byte> _fld1; public Vector128<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__TransposeEven_Vector128_Byte testClass) { var result = AdvSimd.Arm64.TransposeEven(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__TransposeEven_Vector128_Byte testClass) { fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector128<Byte> _clsVar1; private static Vector128<Byte> _clsVar2; private Vector128<Byte> _fld1; private Vector128<Byte> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__TransposeEven_Vector128_Byte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); } public SimpleBinaryOpTest__TransposeEven_Vector128_Byte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, new Byte[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.Arm64.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.Arm64.TransposeEven( Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.TransposeEven), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd.Arm64).GetMethod(nameof(AdvSimd.Arm64.TransposeEven), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.Arm64.TransposeEven( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Byte>* pClsVar1 = &_clsVar1) fixed (Vector128<Byte>* pClsVar2 = &_clsVar2) { var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(pClsVar1)), AdvSimd.LoadVector128((Byte*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr); var result = AdvSimd.Arm64.TransposeEven(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); var result = AdvSimd.Arm64.TransposeEven(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__TransposeEven_Vector128_Byte(); var result = AdvSimd.Arm64.TransposeEven(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__TransposeEven_Vector128_Byte(); fixed (Vector128<Byte>* pFld1 = &test._fld1) fixed (Vector128<Byte>* pFld2 = &test._fld2) { var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.Arm64.TransposeEven(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Byte>* pFld1 = &_fld1) fixed (Vector128<Byte>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(pFld1)), AdvSimd.LoadVector128((Byte*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.TransposeEven(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.Arm64.TransposeEven( AdvSimd.LoadVector128((Byte*)(&test._fld1)), AdvSimd.LoadVector128((Byte*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Byte> op1, Vector128<Byte> op2, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Byte[] inArray1 = new Byte[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; Byte[] outArray = new Byte[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") { bool succeeded = true; int index = 0; int half = RetElementCount / 2; for (var i = 0; i < RetElementCount; i+=2, index++) { if (result[index] != left[i] || result[++index] != right[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.TransposeEven)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/baseservices/exceptions/unittests/InnerFinallyAndCatch.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.IO; public class TestSet { static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) { if (100 == testReturnValue) { nSuccesses++; } else { nFailures++; } } public static int Main() { int nSuccesses = 0; int nFailures = 0; CountResults(new InnerFinallyAndCatchTest().Run(), ref nSuccesses, ref nFailures); if (0 == nFailures) { Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); return 100; } else { Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); return 999; } } } class InnerFinallyAndCatchTest { Trace _trace; public int Run() { _trace = new Trace("InnerFinallyAndCatchTest", "abcdefghijklm13"); int x = 7, y = 0, z; int count = 0; try { _trace.Write("a"); count++; try { _trace.Write("b"); count++; } finally // 1 { try { _trace.Write("c"); count++; } finally // 2 { try { try { _trace.Write("d"); count++; } finally // 3 { _trace.Write("e"); count++; try { _trace.Write("f"); count++; } finally // 4 { _trace.Write("g"); count++; z = x / y; } _trace.Write("@@"); count++; } } catch (Exception) // C2 { _trace.Write("h"); count++; } _trace.Write("i"); count++; } _trace.Write("j"); count++; } _trace.Write("k"); count++; } catch (Exception) // C1 { _trace.Write("!!"); count++; } finally // 0 { _trace.Write("l"); count++; } _trace.Write("m"); count++; _trace.Write(count.ToString()); return _trace.Match(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.IO; public class TestSet { static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) { if (100 == testReturnValue) { nSuccesses++; } else { nFailures++; } } public static int Main() { int nSuccesses = 0; int nFailures = 0; CountResults(new InnerFinallyAndCatchTest().Run(), ref nSuccesses, ref nFailures); if (0 == nFailures) { Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); return 100; } else { Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); return 999; } } } class InnerFinallyAndCatchTest { Trace _trace; public int Run() { _trace = new Trace("InnerFinallyAndCatchTest", "abcdefghijklm13"); int x = 7, y = 0, z; int count = 0; try { _trace.Write("a"); count++; try { _trace.Write("b"); count++; } finally // 1 { try { _trace.Write("c"); count++; } finally // 2 { try { try { _trace.Write("d"); count++; } finally // 3 { _trace.Write("e"); count++; try { _trace.Write("f"); count++; } finally // 4 { _trace.Write("g"); count++; z = x / y; } _trace.Write("@@"); count++; } } catch (Exception) // C2 { _trace.Write("h"); count++; } _trace.Write("i"); count++; } _trace.Write("j"); count++; } _trace.Write("k"); count++; } catch (Exception) // C1 { _trace.Write("!!"); count++; } finally // 0 { _trace.Write("l"); count++; } _trace.Write("m"); count++; _trace.Write(count.ToString()); return _trace.Match(); } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/JIT/HardwareIntrinsics/X86/Sse1/MultiplyScalar.Single.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void MultiplyScalarSingle() { var test = new SimpleBinaryOpTest__MultiplyScalarSingle(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); if (Sse.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (Sse.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (Sse.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (Sse.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (Sse.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__MultiplyScalarSingle { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Single[] inArray1, Single[] inArray2, Single[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Single>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Single>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Single>(); if ((alignment != 32 && alignment != 16) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Single, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Single, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Single> _fld1; public Vector128<Single> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref testStruct._fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref testStruct._fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyScalarSingle testClass) { var result = Sse.MultiplyScalar(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__MultiplyScalarSingle testClass) { fixed (Vector128<Single>* pFld1 = &_fld1) fixed (Vector128<Single>* pFld2 = &_fld2) { var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(pFld1)), Sse.LoadVector128((Single*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); private static Single[] _data1 = new Single[Op1ElementCount]; private static Single[] _data2 = new Single[Op2ElementCount]; private static Vector128<Single> _clsVar1; private static Vector128<Single> _clsVar2; private Vector128<Single> _fld1; private Vector128<Single> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__MultiplyScalarSingle() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); } public SimpleBinaryOpTest__MultiplyScalarSingle() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Sse.MultiplyScalar( Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), Sse.LoadVector128((Single*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Sse.MultiplyScalar( Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), Sse.LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Sse).GetMethod(nameof(Sse.MultiplyScalar), new Type[] { typeof(Vector128<Single>), typeof(Vector128<Single>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Sse).GetMethod(nameof(Sse.MultiplyScalar), new Type[] { typeof(Vector128<Single>), typeof(Vector128<Single>) }) .Invoke(null, new object[] { Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), Sse.LoadVector128((Single*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Sse).GetMethod(nameof(Sse.MultiplyScalar), new Type[] { typeof(Vector128<Single>), typeof(Vector128<Single>) }) .Invoke(null, new object[] { Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), Sse.LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Sse.MultiplyScalar( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Single>* pClsVar1 = &_clsVar1) fixed (Vector128<Single>* pClsVar2 = &_clsVar2) { var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(pClsVar1)), Sse.LoadVector128((Single*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr); var result = Sse.MultiplyScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); var op2 = Sse.LoadVector128((Single*)(_dataTable.inArray2Ptr)); var result = Sse.MultiplyScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var op1 = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); var op2 = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); var result = Sse.MultiplyScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__MultiplyScalarSingle(); var result = Sse.MultiplyScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__MultiplyScalarSingle(); fixed (Vector128<Single>* pFld1 = &test._fld1) fixed (Vector128<Single>* pFld2 = &test._fld2) { var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(pFld1)), Sse.LoadVector128((Single*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Sse.MultiplyScalar(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Single>* pFld1 = &_fld1) fixed (Vector128<Single>* pFld2 = &_fld2) { var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(pFld1)), Sse.LoadVector128((Single*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Sse.MultiplyScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(&test._fld1)), Sse.LoadVector128((Single*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Single> op1, Vector128<Single> op2, void* result, [CallerMemberName] string method = "") { Single[] inArray1 = new Single[Op1ElementCount]; Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Single[] inArray1 = new Single[Op1ElementCount]; Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Single>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Single>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Sse)}.{nameof(Sse.MultiplyScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void MultiplyScalarSingle() { var test = new SimpleBinaryOpTest__MultiplyScalarSingle(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); if (Sse.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (Sse.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (Sse.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (Sse.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (Sse.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleBinaryOpTest__MultiplyScalarSingle { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(Single[] inArray1, Single[] inArray2, Single[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Single>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Single>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Single>(); if ((alignment != 32 && alignment != 16) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<Single, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Single, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector128<Single> _fld1; public Vector128<Single> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref testStruct._fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref testStruct._fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyScalarSingle testClass) { var result = Sse.MultiplyScalar(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__MultiplyScalarSingle testClass) { fixed (Vector128<Single>* pFld1 = &_fld1) fixed (Vector128<Single>* pFld2 = &_fld2) { var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(pFld1)), Sse.LoadVector128((Single*)(pFld2)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); private static Single[] _data1 = new Single[Op1ElementCount]; private static Single[] _data2 = new Single[Op2ElementCount]; private static Vector128<Single> _clsVar1; private static Vector128<Single> _clsVar2; private Vector128<Single> _fld1; private Vector128<Single> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__MultiplyScalarSingle() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); } public SimpleBinaryOpTest__MultiplyScalarSingle() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Single>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Sse.MultiplyScalar( Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), Sse.LoadVector128((Single*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Sse.MultiplyScalar( Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), Sse.LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Sse).GetMethod(nameof(Sse.MultiplyScalar), new Type[] { typeof(Vector128<Single>), typeof(Vector128<Single>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Sse).GetMethod(nameof(Sse.MultiplyScalar), new Type[] { typeof(Vector128<Single>), typeof(Vector128<Single>) }) .Invoke(null, new object[] { Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), Sse.LoadVector128((Single*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Sse).GetMethod(nameof(Sse.MultiplyScalar), new Type[] { typeof(Vector128<Single>), typeof(Vector128<Single>) }) .Invoke(null, new object[] { Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), Sse.LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Single>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Sse.MultiplyScalar( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Single>* pClsVar1 = &_clsVar1) fixed (Vector128<Single>* pClsVar2 = &_clsVar2) { var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(pClsVar1)), Sse.LoadVector128((Single*)(pClsVar2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector128<Single>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Single>>(_dataTable.inArray2Ptr); var result = Sse.MultiplyScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); var op2 = Sse.LoadVector128((Single*)(_dataTable.inArray2Ptr)); var result = Sse.MultiplyScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var op1 = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); var op2 = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); var result = Sse.MultiplyScalar(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__MultiplyScalarSingle(); var result = Sse.MultiplyScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleBinaryOpTest__MultiplyScalarSingle(); fixed (Vector128<Single>* pFld1 = &test._fld1) fixed (Vector128<Single>* pFld2 = &test._fld2) { var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(pFld1)), Sse.LoadVector128((Single*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Sse.MultiplyScalar(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Single>* pFld1 = &_fld1) fixed (Vector128<Single>* pFld2 = &_fld2) { var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(pFld1)), Sse.LoadVector128((Single*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Sse.MultiplyScalar(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = Sse.MultiplyScalar( Sse.LoadVector128((Single*)(&test._fld1)), Sse.LoadVector128((Single*)(&test._fld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector128<Single> op1, Vector128<Single> op2, void* result, [CallerMemberName] string method = "") { Single[] inArray1 = new Single[Op1ElementCount]; Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Single[] inArray1 = new Single[Op1ElementCount]; Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<Single>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Single>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Single>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Sse)}.{nameof(Sse.MultiplyScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/JIT/HardwareIntrinsics/General/Vector256/Max.UInt32.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void MaxUInt32() { var test = new VectorBinaryOpTest__MaxUInt32(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__MaxUInt32 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(UInt32[] inArray1, UInt32[] inArray2, UInt32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt32>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt32>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt32>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt32, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt32, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<UInt32> _fld1; public Vector256<UInt32> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__MaxUInt32 testClass) { var result = Vector256.Max(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<UInt32>>() / sizeof(UInt32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<UInt32>>() / sizeof(UInt32); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<UInt32>>() / sizeof(UInt32); private static UInt32[] _data1 = new UInt32[Op1ElementCount]; private static UInt32[] _data2 = new UInt32[Op2ElementCount]; private static Vector256<UInt32> _clsVar1; private static Vector256<UInt32> _clsVar2; private Vector256<UInt32> _fld1; private Vector256<UInt32> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__MaxUInt32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); } public VectorBinaryOpTest__MaxUInt32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } _dataTable = new DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector256.Max( Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector256).GetMethod(nameof(Vector256.Max), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) }); if (method is null) { method = typeof(Vector256).GetMethod(nameof(Vector256.Max), 1, new Type[] { typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(UInt32)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector256.Max( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr); var result = Vector256.Max(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__MaxUInt32(); var result = Vector256.Max(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector256.Max(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector256.Max(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<UInt32> op1, Vector256<UInt32> op2, void* result, [CallerMemberName] string method = "") { UInt32[] inArray1 = new UInt32[Op1ElementCount]; UInt32[] inArray2 = new UInt32[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt32[] inArray1 = new UInt32[Op1ElementCount]; UInt32[] inArray2 = new UInt32[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != ((left[0] > right[0]) ? left[0] : right[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != ((left[i] > right[i]) ? left[i] : right[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.Max)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; namespace JIT.HardwareIntrinsics.General { public static partial class Program { private static void MaxUInt32() { var test = new VectorBinaryOpTest__MaxUInt32(); // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorBinaryOpTest__MaxUInt32 { private struct DataTable { private byte[] inArray1; private byte[] inArray2; private byte[] outArray; private GCHandle inHandle1; private GCHandle inHandle2; private GCHandle outHandle; private ulong alignment; public DataTable(UInt32[] inArray1, UInt32[] inArray2, UInt32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt32>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt32>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt32>(); if ((alignment != 32 && alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfinArray2 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.inArray2 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.inHandle2 = GCHandle.Alloc(this.inArray2, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<UInt32, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt32, byte>(ref inArray2[0]), (uint)sizeOfinArray2); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* inArray2Ptr => Align((byte*)(inHandle2.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector256<UInt32> _fld1; public Vector256<UInt32> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__MaxUInt32 testClass) { var result = Vector256.Max(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector256<UInt32>>() / sizeof(UInt32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector256<UInt32>>() / sizeof(UInt32); private static readonly int RetElementCount = Unsafe.SizeOf<Vector256<UInt32>>() / sizeof(UInt32); private static UInt32[] _data1 = new UInt32[Op1ElementCount]; private static UInt32[] _data2 = new UInt32[Op2ElementCount]; private static Vector256<UInt32> _clsVar1; private static Vector256<UInt32> _clsVar2; private Vector256<UInt32> _fld1; private Vector256<UInt32> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__MaxUInt32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); } public VectorBinaryOpTest__MaxUInt32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } _dataTable = new DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); } public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector256.Max( Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var method = typeof(Vector256).GetMethod(nameof(Vector256.Max), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) }); if (method is null) { method = typeof(Vector256).GetMethod(nameof(Vector256.Max), 1, new Type[] { typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector256<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(UInt32)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector256<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector256.Max( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr); var result = Vector256.Max(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__MaxUInt32(); var result = Vector256.Max(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Vector256.Max(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Vector256.Max(test._fld1, test._fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } private void ValidateResult(Vector256<UInt32> op1, Vector256<UInt32> op2, void* result, [CallerMemberName] string method = "") { UInt32[] inArray1 = new UInt32[Op1ElementCount]; UInt32[] inArray2 = new UInt32[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt32[] inArray1 = new UInt32[Op1ElementCount]; UInt32[] inArray2 = new UInt32[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector256<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != ((left[0] > right[0]) ? left[0] : right[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != ((left[i] > right[i]) ? left[i] : right[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector256)}.{nameof(Vector256.Max)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/SignatureTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; using Internal.IL; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; using Xunit; using Xunit.Abstractions; namespace TypeSystemTests { public class SignatureTests { private readonly ITestOutputHelper _output; private TestTypeSystemContext _context; private ModuleDesc _testModule; public SignatureTests(ITestOutputHelper output) { _output = output; _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = _context.GetModuleForSimpleName("ILTestAssembly"); } private static string GetModOptMethodSignatureInfo(MethodSignature signature) { if (!signature.HasEmbeddedSignatureData) return string.Empty; StringBuilder sb = new StringBuilder(); foreach (EmbeddedSignatureData data in signature.GetEmbeddedSignatureData()) { sb.Append(data.kind.ToString()); sb.Append(data.index); if (data.type != null) sb.Append(((MetadataType)data.type).Name); else sb.Append("<null>"); } return sb.ToString(); } [Fact] public void TestSignatureMatches2ModOptsAtStartOfSig() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWith2ModOptsAtStartOfSig = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method")).Signature; // All modopts that are at the very beginning of the signature are given index 0.1.1.1 // Both the index and the order in the modopt array are significant for signature comparison Assert.Equal(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWith2ModOptsAtStartOfSig.GetEmbeddedSignatureData()[0].index); Assert.Equal(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWith2ModOptsAtStartOfSig.GetEmbeddedSignatureData()[1].index); Assert.NotEqual(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWith2ModOptsAtStartOfSig.GetEmbeddedSignatureData()[2].index); Assert.Equal("OptionalCustomModifier0.1.1.1CharOptionalCustomModifier0.1.1.1VoidOptionalCustomModifier0.1.2.1FooModifier", GetModOptMethodSignatureInfo(methodWith2ModOptsAtStartOfSig)); } [Fact] public void TestSignatureMatchesModOptAtStartOfSigAndAfterByRef() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWithModOptAtStartOfSigAndAfterByRef = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method2")).Signature; // A modopts after an E_T_BYREF will look like 0.1.1.2.1.1 Assert.Equal(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWithModOptAtStartOfSigAndAfterByRef.GetEmbeddedSignatureData()[0].index); Assert.NotEqual(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWithModOptAtStartOfSigAndAfterByRef.GetEmbeddedSignatureData()[1].index); Assert.NotEqual(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWithModOptAtStartOfSigAndAfterByRef.GetEmbeddedSignatureData()[2].index); Assert.Equal("OptionalCustomModifier0.1.1.1CharOptionalCustomModifier0.1.1.2.1.1VoidOptionalCustomModifier0.1.2.1FooModifier", GetModOptMethodSignatureInfo(methodWithModOptAtStartOfSigAndAfterByRef)); } [Fact] public void TestSignatureMatchesModoptOnPointerOrRefModifiedType() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method3")).Signature; Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(0), methodWithModOpt.GetEmbeddedSignatureData()[0].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(1), methodWithModOpt.GetEmbeddedSignatureData()[1].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(2), methodWithModOpt.GetEmbeddedSignatureData()[2].index); } [Fact] public void TestSignatureMatchesForArrayShapeDetails() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method4")).Signature; _output.WriteLine($"Found ModOptData '{GetModOptMethodSignatureInfo(methodWithModOpt)}'"); Assert.Equal(7, methodWithModOpt.GetEmbeddedSignatureData().Length); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(0), methodWithModOpt.GetEmbeddedSignatureData()[0].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(1), methodWithModOpt.GetEmbeddedSignatureData()[2].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(2), methodWithModOpt.GetEmbeddedSignatureData()[4].index); Assert.Equal("OptionalCustomModifier0.1.1.2.1.1VoidArrayShape1.2.1.1|3,4|0,1<null>OptionalCustomModifier0.1.1.2.2.1FooModifierArrayShape1.2.2.1|0,9|2,0<null>OptionalCustomModifier0.1.1.2.3.1FooModifierArrayShape1.2.3.1||0<null>ArrayShape1.2.4.1||<null>", GetModOptMethodSignatureInfo(methodWithModOpt)); } [Fact] public void TestSignatureMatchesForArrayShapeDetails_HandlingOfCasesWhichDoNotNeedEmbeddeSignatureData() { // Test that ensure the typical case (where the loBounds is 0, and the hibounds is unspecified) doesn't produce an // EmbeddedSignatureData, but that other cases do. This isn't a complete test as ilasm won't actually properly generate the metadata for many of these cases MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method5")).Signature; _output.WriteLine($"Found ModOptData '{GetModOptMethodSignatureInfo(methodWithModOpt)}'"); Assert.Equal(2, methodWithModOpt.GetEmbeddedSignatureData().Length); Assert.EndsWith(methodWithModOpt.GetEmbeddedSignatureData()[0].index.Split('|')[0], MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(1)); Assert.EndsWith(methodWithModOpt.GetEmbeddedSignatureData()[1].index.Split('|')[0], MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(2)); Assert.Equal("ArrayShape1.2.2.1||0<null>ArrayShape1.2.3.1||<null>", GetModOptMethodSignatureInfo(methodWithModOpt)); } [Fact] public void TestSignatureMatches() { MetadataType atomType = _testModule.GetType("", "Atom"); MetadataType aType = _testModule.GetType("", "A`1"); MetadataType aOfAtomType = aType.MakeInstantiatedType(new Instantiation(atomType)); MetadataType baseClassType = _testModule.GetType("", "BaseClass`2"); MethodDesc baseClassMethod = baseClassType.GetMethods().Single(m => string.Equals(m.Name, "Method")); MethodSignature baseClassMethodSignature = baseClassMethod.Signature; MethodSignatureBuilder matchingSignatureBuilder = new MethodSignatureBuilder(baseClassMethodSignature); matchingSignatureBuilder[0] = aOfAtomType; matchingSignatureBuilder[1] = atomType; MethodSignature matchingSignature = matchingSignatureBuilder.ToSignature(); MetadataType derivedClassType = _testModule.GetType("", "DerivedClass"); IEnumerable<MethodDesc> derivedClassMethods = derivedClassType.GetMethods().Where(m => string.Equals(m.Name, "Method")); IEnumerable<bool> matches = derivedClassMethods.Select(m => matchingSignature.Equals(m.Signature)); int matchCount = matches.Select(b => b ? 1 : 0).Sum(); Assert.Equal(1, matchCount); } [Fact] public void TestSerializedSignatureWithArrayShapes() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodDesc methodWithInterestingShapes = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method4")); // Create assembly with reference to interesting method TypeSystemMetadataEmitter metadataEmitter = new TypeSystemMetadataEmitter(new System.Reflection.AssemblyName("Lookup"), _context); var token = metadataEmitter.GetMethodRef(methodWithInterestingShapes); Stream peStream = new MemoryStream(); metadataEmitter.SerializeToStream(peStream); peStream.Seek(0, SeekOrigin.Begin); // Create new TypeSystemContext with just created assembly inside var lookupContext = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = lookupContext.CreateModuleForSimpleName("CoreTestAssembly"); lookupContext.SetSystemModule(systemModule); lookupContext.CreateModuleForSimpleName("Lookup", peStream); // Use generated assembly to trigger a load through the token created above and verify that it loads correctly var ilLookupModule = (EcmaModule)lookupContext.GetModuleForSimpleName("Lookup"); MethodDesc method4 = ilLookupModule.GetMethod(token); Assert.Equal("Method4", method4.Name); } [Fact] public void TestSerializedSignatureWithReferenceToMDIntArray() { var typeInInitialContext = _context.GetWellKnownType(WellKnownType.Int32).MakeArrayType(3); // Create assembly with reference to interesting type TypeSystemMetadataEmitter metadataEmitter = new TypeSystemMetadataEmitter(new System.Reflection.AssemblyName("Lookup"), _context); var token = metadataEmitter.GetTypeRef(typeInInitialContext); Stream peStream = new MemoryStream(); metadataEmitter.SerializeToStream(peStream); peStream.Seek(0, SeekOrigin.Begin); // Create new TypeSystemContext with just created assembly inside var lookupContext = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = lookupContext.CreateModuleForSimpleName("CoreTestAssembly"); lookupContext.SetSystemModule(systemModule); lookupContext.CreateModuleForSimpleName("Lookup", peStream); // Use generated assembly to trigger a load through the token created above and verify that it loads correctly var ilLookupModule = (EcmaModule)lookupContext.GetModuleForSimpleName("Lookup"); TypeDesc int32ArrayFromLookup = ilLookupModule.GetType(token); var typeInLookupContext = lookupContext.GetWellKnownType(WellKnownType.Int32).MakeArrayType(3); Assert.Equal(typeInLookupContext, int32ArrayFromLookup); } [Fact] public void TestMDArrayFunctionReading() { MetadataType mdArrayFunctionResolutionType = _testModule.GetType("", "MDArrayFunctionResolution"); MethodDesc methodWithMDArrayUsage = mdArrayFunctionResolutionType.GetMethods().Single(m => string.Equals(m.Name, "MethodWithUseOfMDArrayFunctions")); MethodIL methodIL = EcmaMethodIL.Create((EcmaMethod)methodWithMDArrayUsage); ILReader ilReader = new ILReader(methodIL.GetILBytes()); int failures = 0; int successes = 0; while (ilReader.HasNext) { ILOpcode opcode = ilReader.ReadILOpcode(); switch(opcode) { case ILOpcode.call: case ILOpcode.newobj: int token = ilReader.ReadILToken(); object tokenReferenceResult = methodIL.GetObject(token, NotFoundBehavior.ReturnNull); if (tokenReferenceResult == null) { failures++; tokenReferenceResult = "null"; } else { successes++; } _output.WriteLine($"call {tokenReferenceResult.ToString()}"); break; } } Assert.Equal(0, failures); Assert.Equal(4, successes); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; using Internal.IL; using Internal.TypeSystem; using Internal.TypeSystem.Ecma; using Xunit; using Xunit.Abstractions; namespace TypeSystemTests { public class SignatureTests { private readonly ITestOutputHelper _output; private TestTypeSystemContext _context; private ModuleDesc _testModule; public SignatureTests(ITestOutputHelper output) { _output = output; _context = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly"); _context.SetSystemModule(systemModule); _testModule = _context.GetModuleForSimpleName("ILTestAssembly"); } private static string GetModOptMethodSignatureInfo(MethodSignature signature) { if (!signature.HasEmbeddedSignatureData) return string.Empty; StringBuilder sb = new StringBuilder(); foreach (EmbeddedSignatureData data in signature.GetEmbeddedSignatureData()) { sb.Append(data.kind.ToString()); sb.Append(data.index); if (data.type != null) sb.Append(((MetadataType)data.type).Name); else sb.Append("<null>"); } return sb.ToString(); } [Fact] public void TestSignatureMatches2ModOptsAtStartOfSig() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWith2ModOptsAtStartOfSig = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method")).Signature; // All modopts that are at the very beginning of the signature are given index 0.1.1.1 // Both the index and the order in the modopt array are significant for signature comparison Assert.Equal(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWith2ModOptsAtStartOfSig.GetEmbeddedSignatureData()[0].index); Assert.Equal(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWith2ModOptsAtStartOfSig.GetEmbeddedSignatureData()[1].index); Assert.NotEqual(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWith2ModOptsAtStartOfSig.GetEmbeddedSignatureData()[2].index); Assert.Equal("OptionalCustomModifier0.1.1.1CharOptionalCustomModifier0.1.1.1VoidOptionalCustomModifier0.1.2.1FooModifier", GetModOptMethodSignatureInfo(methodWith2ModOptsAtStartOfSig)); } [Fact] public void TestSignatureMatchesModOptAtStartOfSigAndAfterByRef() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWithModOptAtStartOfSigAndAfterByRef = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method2")).Signature; // A modopts after an E_T_BYREF will look like 0.1.1.2.1.1 Assert.Equal(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWithModOptAtStartOfSigAndAfterByRef.GetEmbeddedSignatureData()[0].index); Assert.NotEqual(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWithModOptAtStartOfSigAndAfterByRef.GetEmbeddedSignatureData()[1].index); Assert.NotEqual(MethodSignature.IndexOfCustomModifiersOnReturnType, methodWithModOptAtStartOfSigAndAfterByRef.GetEmbeddedSignatureData()[2].index); Assert.Equal("OptionalCustomModifier0.1.1.1CharOptionalCustomModifier0.1.1.2.1.1VoidOptionalCustomModifier0.1.2.1FooModifier", GetModOptMethodSignatureInfo(methodWithModOptAtStartOfSigAndAfterByRef)); } [Fact] public void TestSignatureMatchesModoptOnPointerOrRefModifiedType() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method3")).Signature; Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(0), methodWithModOpt.GetEmbeddedSignatureData()[0].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(1), methodWithModOpt.GetEmbeddedSignatureData()[1].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(2), methodWithModOpt.GetEmbeddedSignatureData()[2].index); } [Fact] public void TestSignatureMatchesForArrayShapeDetails() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method4")).Signature; _output.WriteLine($"Found ModOptData '{GetModOptMethodSignatureInfo(methodWithModOpt)}'"); Assert.Equal(7, methodWithModOpt.GetEmbeddedSignatureData().Length); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(0), methodWithModOpt.GetEmbeddedSignatureData()[0].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(1), methodWithModOpt.GetEmbeddedSignatureData()[2].index); Assert.Equal(MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(2), methodWithModOpt.GetEmbeddedSignatureData()[4].index); Assert.Equal("OptionalCustomModifier0.1.1.2.1.1VoidArrayShape1.2.1.1|3,4|0,1<null>OptionalCustomModifier0.1.1.2.2.1FooModifierArrayShape1.2.2.1|0,9|2,0<null>OptionalCustomModifier0.1.1.2.3.1FooModifierArrayShape1.2.3.1||0<null>ArrayShape1.2.4.1||<null>", GetModOptMethodSignatureInfo(methodWithModOpt)); } [Fact] public void TestSignatureMatchesForArrayShapeDetails_HandlingOfCasesWhichDoNotNeedEmbeddeSignatureData() { // Test that ensure the typical case (where the loBounds is 0, and the hibounds is unspecified) doesn't produce an // EmbeddedSignatureData, but that other cases do. This isn't a complete test as ilasm won't actually properly generate the metadata for many of these cases MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodSignature methodWithModOpt = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method5")).Signature; _output.WriteLine($"Found ModOptData '{GetModOptMethodSignatureInfo(methodWithModOpt)}'"); Assert.Equal(2, methodWithModOpt.GetEmbeddedSignatureData().Length); Assert.EndsWith(methodWithModOpt.GetEmbeddedSignatureData()[0].index.Split('|')[0], MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(1)); Assert.EndsWith(methodWithModOpt.GetEmbeddedSignatureData()[1].index.Split('|')[0], MethodSignature.GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(2)); Assert.Equal("ArrayShape1.2.2.1||0<null>ArrayShape1.2.3.1||<null>", GetModOptMethodSignatureInfo(methodWithModOpt)); } [Fact] public void TestSignatureMatches() { MetadataType atomType = _testModule.GetType("", "Atom"); MetadataType aType = _testModule.GetType("", "A`1"); MetadataType aOfAtomType = aType.MakeInstantiatedType(new Instantiation(atomType)); MetadataType baseClassType = _testModule.GetType("", "BaseClass`2"); MethodDesc baseClassMethod = baseClassType.GetMethods().Single(m => string.Equals(m.Name, "Method")); MethodSignature baseClassMethodSignature = baseClassMethod.Signature; MethodSignatureBuilder matchingSignatureBuilder = new MethodSignatureBuilder(baseClassMethodSignature); matchingSignatureBuilder[0] = aOfAtomType; matchingSignatureBuilder[1] = atomType; MethodSignature matchingSignature = matchingSignatureBuilder.ToSignature(); MetadataType derivedClassType = _testModule.GetType("", "DerivedClass"); IEnumerable<MethodDesc> derivedClassMethods = derivedClassType.GetMethods().Where(m => string.Equals(m.Name, "Method")); IEnumerable<bool> matches = derivedClassMethods.Select(m => matchingSignature.Equals(m.Signature)); int matchCount = matches.Select(b => b ? 1 : 0).Sum(); Assert.Equal(1, matchCount); } [Fact] public void TestSerializedSignatureWithArrayShapes() { MetadataType modOptTester = _testModule.GetType("", "ModOptTester"); MethodDesc methodWithInterestingShapes = modOptTester.GetMethods().Single(m => string.Equals(m.Name, "Method4")); // Create assembly with reference to interesting method TypeSystemMetadataEmitter metadataEmitter = new TypeSystemMetadataEmitter(new System.Reflection.AssemblyName("Lookup"), _context); var token = metadataEmitter.GetMethodRef(methodWithInterestingShapes); Stream peStream = new MemoryStream(); metadataEmitter.SerializeToStream(peStream); peStream.Seek(0, SeekOrigin.Begin); // Create new TypeSystemContext with just created assembly inside var lookupContext = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = lookupContext.CreateModuleForSimpleName("CoreTestAssembly"); lookupContext.SetSystemModule(systemModule); lookupContext.CreateModuleForSimpleName("Lookup", peStream); // Use generated assembly to trigger a load through the token created above and verify that it loads correctly var ilLookupModule = (EcmaModule)lookupContext.GetModuleForSimpleName("Lookup"); MethodDesc method4 = ilLookupModule.GetMethod(token); Assert.Equal("Method4", method4.Name); } [Fact] public void TestSerializedSignatureWithReferenceToMDIntArray() { var typeInInitialContext = _context.GetWellKnownType(WellKnownType.Int32).MakeArrayType(3); // Create assembly with reference to interesting type TypeSystemMetadataEmitter metadataEmitter = new TypeSystemMetadataEmitter(new System.Reflection.AssemblyName("Lookup"), _context); var token = metadataEmitter.GetTypeRef(typeInInitialContext); Stream peStream = new MemoryStream(); metadataEmitter.SerializeToStream(peStream); peStream.Seek(0, SeekOrigin.Begin); // Create new TypeSystemContext with just created assembly inside var lookupContext = new TestTypeSystemContext(TargetArchitecture.X64); var systemModule = lookupContext.CreateModuleForSimpleName("CoreTestAssembly"); lookupContext.SetSystemModule(systemModule); lookupContext.CreateModuleForSimpleName("Lookup", peStream); // Use generated assembly to trigger a load through the token created above and verify that it loads correctly var ilLookupModule = (EcmaModule)lookupContext.GetModuleForSimpleName("Lookup"); TypeDesc int32ArrayFromLookup = ilLookupModule.GetType(token); var typeInLookupContext = lookupContext.GetWellKnownType(WellKnownType.Int32).MakeArrayType(3); Assert.Equal(typeInLookupContext, int32ArrayFromLookup); } [Fact] public void TestMDArrayFunctionReading() { MetadataType mdArrayFunctionResolutionType = _testModule.GetType("", "MDArrayFunctionResolution"); MethodDesc methodWithMDArrayUsage = mdArrayFunctionResolutionType.GetMethods().Single(m => string.Equals(m.Name, "MethodWithUseOfMDArrayFunctions")); MethodIL methodIL = EcmaMethodIL.Create((EcmaMethod)methodWithMDArrayUsage); ILReader ilReader = new ILReader(methodIL.GetILBytes()); int failures = 0; int successes = 0; while (ilReader.HasNext) { ILOpcode opcode = ilReader.ReadILOpcode(); switch(opcode) { case ILOpcode.call: case ILOpcode.newobj: int token = ilReader.ReadILToken(); object tokenReferenceResult = methodIL.GetObject(token, NotFoundBehavior.ReturnNull); if (tokenReferenceResult == null) { failures++; tokenReferenceResult = "null"; } else { successes++; } _output.WriteLine($"call {tokenReferenceResult.ToString()}"); break; } } Assert.Equal(0, failures); Assert.Equal(4, successes); } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/JIT/HardwareIntrinsics/X86/Avx1/DotProduct.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics; namespace IntelHardwareIntrinsicTest { class Program { const int Pass = 100; const int Fail = 0; static unsafe int Main(string[] args) { int testResult = Pass; if (Avx.IsSupported) { using (TestTable<float> floatTable = new TestTable<float>(new float[8] { 1, -5, 100, 0, 1, -5, 100, 0 }, new float[8] { 22, -1, -50, 0, 22, -1, -50, 0 }, new float[8])) { var vf1 = Unsafe.Read<Vector256<float>>(floatTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector256<float>>(floatTable.inArray2Ptr); var vf3 = Avx.DotProduct(vf1, vf2, 255); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) + (x[2] * y[2]) + (x[3] * y[3])))) { Console.WriteLine("Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } vf3 = Avx.DotProduct(vf1, vf2, 127); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) + (x[2] * y[2])))) { Console.WriteLine("Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } vf3 = Avx.DotProduct(vf1, vf2, 63); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z.All(result => result == ((x[0] * y[0]) + (x[1] * y[1]))))) { Console.WriteLine("3 Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } vf3 = Avx.DotProduct(vf1, vf2, 85); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z[0] == ((x[0] * y[0]) + (x[2] * y[2])) && z[2] == ((x[0] * y[0]) + (x[2] * y[2])) && z[4] == ((x[4] * y[4]) + (x[6] * y[6])) && z[6] == ((x[4] * y[4]) + (x[6] * y[6])) && z[1] == 0 && z[3] == 0 && z[5] == 0 && z[7] == 0)) { Console.WriteLine("Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } vf3 = (Vector256<float>)typeof(Avx).GetMethod(nameof(Avx.DotProduct), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(255) }); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) + (x[2] * y[2]) + (x[3] * y[3])))) { Console.WriteLine("Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } } return testResult; } public unsafe struct TestTable<T> : IDisposable where T : struct { public T[] inArray1; public T[] inArray2; public T[] outArray; public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); GCHandle inHandle1; GCHandle inHandle2; GCHandle outHandle; public TestTable(T[] a, T[] b, T[] c) { this.inArray1 = a; this.inArray2 = b; this.outArray = c; inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); } public bool CheckResult(Func<T[], T[], T[], bool> check) { return check(inArray1, inArray2, outArray); } public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // using System; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics; namespace IntelHardwareIntrinsicTest { class Program { const int Pass = 100; const int Fail = 0; static unsafe int Main(string[] args) { int testResult = Pass; if (Avx.IsSupported) { using (TestTable<float> floatTable = new TestTable<float>(new float[8] { 1, -5, 100, 0, 1, -5, 100, 0 }, new float[8] { 22, -1, -50, 0, 22, -1, -50, 0 }, new float[8])) { var vf1 = Unsafe.Read<Vector256<float>>(floatTable.inArray1Ptr); var vf2 = Unsafe.Read<Vector256<float>>(floatTable.inArray2Ptr); var vf3 = Avx.DotProduct(vf1, vf2, 255); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) + (x[2] * y[2]) + (x[3] * y[3])))) { Console.WriteLine("Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } vf3 = Avx.DotProduct(vf1, vf2, 127); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) + (x[2] * y[2])))) { Console.WriteLine("Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } vf3 = Avx.DotProduct(vf1, vf2, 63); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z.All(result => result == ((x[0] * y[0]) + (x[1] * y[1]))))) { Console.WriteLine("3 Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } vf3 = Avx.DotProduct(vf1, vf2, 85); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z[0] == ((x[0] * y[0]) + (x[2] * y[2])) && z[2] == ((x[0] * y[0]) + (x[2] * y[2])) && z[4] == ((x[4] * y[4]) + (x[6] * y[6])) && z[6] == ((x[4] * y[4]) + (x[6] * y[6])) && z[1] == 0 && z[3] == 0 && z[5] == 0 && z[7] == 0)) { Console.WriteLine("Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } vf3 = (Vector256<float>)typeof(Avx).GetMethod(nameof(Avx.DotProduct), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(255) }); Unsafe.Write(floatTable.outArrayPtr, vf3); if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) + (x[2] * y[2]) + (x[3] * y[3])))) { Console.WriteLine("Avx DotProduct failed on float:"); foreach (var item in floatTable.outArray) { Console.Write(item + ", "); } Console.WriteLine(); testResult = Fail; } } } return testResult; } public unsafe struct TestTable<T> : IDisposable where T : struct { public T[] inArray1; public T[] inArray2; public T[] outArray; public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer(); public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer(); public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); GCHandle inHandle1; GCHandle inHandle2; GCHandle outHandle; public TestTable(T[] a, T[] b, T[] c) { this.inArray1 = a; this.inArray2 = b; this.outArray = c; inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned); inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned); outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); } public bool CheckResult(Func<T[], T[], T[], bool> check) { return check(inArray1, inArray2, outArray); } public void Dispose() { inHandle1.Free(); inHandle2.Free(); outHandle.Free(); } } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/SignExtendWideningLower.Vector64.SByte.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void SignExtendWideningLower_Vector64_SByte() { var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte { private struct DataTable { private byte[] inArray1; private byte[] outArray; private GCHandle inHandle1; private GCHandle outHandle; private ulong alignment; public DataTable(SByte[] inArray1, Int16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<SByte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int16>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<SByte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<SByte> _fld1; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<SByte>, byte>(ref testStruct._fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<SByte>>()); return testStruct; } public void RunStructFldScenario(SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte testClass) { var result = AdvSimd.SignExtendWideningLower(_fld1); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte testClass) { fixed (Vector64<SByte>* pFld1 = &_fld1) { var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(pFld1)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<SByte>>() / sizeof(SByte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static SByte[] _data1 = new SByte[Op1ElementCount]; private static Vector64<SByte> _clsVar1; private Vector64<SByte> _fld1; private DataTable _dataTable; static SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<SByte>>()); } public SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<SByte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } _dataTable = new DataTable(_data1, new Int16[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.SignExtendWideningLower( Unsafe.Read<Vector64<SByte>>(_dataTable.inArray1Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(_dataTable.inArray1Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SignExtendWideningLower), new Type[] { typeof(Vector64<SByte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<SByte>>(_dataTable.inArray1Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SignExtendWideningLower), new Type[] { typeof(Vector64<SByte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((SByte*)(_dataTable.inArray1Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SignExtendWideningLower( _clsVar1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<SByte>* pClsVar1 = &_clsVar1) { var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(pClsVar1)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<SByte>>(_dataTable.inArray1Ptr); var result = AdvSimd.SignExtendWideningLower(op1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((SByte*)(_dataTable.inArray1Ptr)); var result = AdvSimd.SignExtendWideningLower(op1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte(); var result = AdvSimd.SignExtendWideningLower(test._fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte(); fixed (Vector64<SByte>* pFld1 = &test._fld1) { var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(pFld1)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SignExtendWideningLower(_fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<SByte>* pFld1 = &_fld1) { var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(pFld1)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.SignExtendWideningLower(test._fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(&test._fld1)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<SByte> op1, void* result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), op1); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); ValidateResult(inArray1, outArray, method); } private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); ValidateResult(inArray1, outArray, method); } private void ValidateResult(SByte[] firstOp, Int16[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SignExtendWidening(firstOp[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SignExtendWideningLower)}<Int16>(Vector64<SByte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics.Arm\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.Arm; namespace JIT.HardwareIntrinsics.Arm { public static partial class Program { private static void SignExtendWideningLower_Vector64_SByte() { var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); } // Validates passing a static member works test.RunClsVarScenario(); if (AdvSimd.IsSupported) { // Validates passing a static member works, using pinning and Load test.RunClsVarScenario_Load(); } // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (AdvSimd.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local class works, using pinning and Load test.RunClassLclFldScenario_Load(); } // Validates passing an instance member of a class works test.RunClassFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a class works, using pinning and Load test.RunClassFldScenario_Load(); } // Validates passing the field of a local struct works test.RunStructLclFldScenario(); if (AdvSimd.IsSupported) { // Validates passing the field of a local struct works, using pinning and Load test.RunStructLclFldScenario_Load(); } // Validates passing an instance member of a struct works test.RunStructFldScenario(); if (AdvSimd.IsSupported) { // Validates passing an instance member of a struct works, using pinning and Load test.RunStructFldScenario_Load(); } } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte { private struct DataTable { private byte[] inArray1; private byte[] outArray; private GCHandle inHandle1; private GCHandle outHandle; private ulong alignment; public DataTable(SByte[] inArray1, Int16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<SByte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int16>(); if ((alignment != 16 && alignment != 8) || (alignment * 2) < sizeOfinArray1 || (alignment * 2) < sizeOfoutArray) { throw new ArgumentException("Invalid value of alignment"); } this.inArray1 = new byte[alignment * 2]; this.outArray = new byte[alignment * 2]; this.inHandle1 = GCHandle.Alloc(this.inArray1, GCHandleType.Pinned); this.outHandle = GCHandle.Alloc(this.outArray, GCHandleType.Pinned); this.alignment = (ulong)alignment; Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<SByte, byte>(ref inArray1[0]), (uint)sizeOfinArray1); } public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), alignment); public void* outArrayPtr => Align((byte*)(outHandle.AddrOfPinnedObject().ToPointer()), alignment); public void Dispose() { inHandle1.Free(); outHandle.Free(); } private static unsafe void* Align(byte* buffer, ulong expectedAlignment) { return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); } } private struct TestStruct { public Vector64<SByte> _fld1; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<SByte>, byte>(ref testStruct._fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<SByte>>()); return testStruct; } public void RunStructFldScenario(SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte testClass) { var result = AdvSimd.SignExtendWideningLower(_fld1); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte testClass) { fixed (Vector64<SByte>* pFld1 = &_fld1) { var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(pFld1)) ); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr); } } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<SByte>>() / sizeof(SByte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static SByte[] _data1 = new SByte[Op1ElementCount]; private static Vector64<SByte> _clsVar1; private Vector64<SByte> _fld1; private DataTable _dataTable; static SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<SByte>>()); } public SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<SByte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } _dataTable = new DataTable(_data1, new Int16[RetElementCount], LargestVectorSize); } public bool IsSupported => AdvSimd.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = AdvSimd.SignExtendWideningLower( Unsafe.Read<Vector64<SByte>>(_dataTable.inArray1Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(_dataTable.inArray1Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SignExtendWideningLower), new Type[] { typeof(Vector64<SByte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector64<SByte>>(_dataTable.inArray1Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SignExtendWideningLower), new Type[] { typeof(Vector64<SByte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector64((SByte*)(_dataTable.inArray1Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SignExtendWideningLower( _clsVar1 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector64<SByte>* pClsVar1 = &_clsVar1) { var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(pClsVar1)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _dataTable.outArrayPtr); } } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var op1 = Unsafe.Read<Vector64<SByte>>(_dataTable.inArray1Ptr); var result = AdvSimd.SignExtendWideningLower(op1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = AdvSimd.LoadVector64((SByte*)(_dataTable.inArray1Ptr)); var result = AdvSimd.SignExtendWideningLower(op1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte(); var result = AdvSimd.SignExtendWideningLower(test._fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunClassLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load)); var test = new SimpleUnaryOpTest__SignExtendWideningLower_Vector64_SByte(); fixed (Vector64<SByte>* pFld1 = &test._fld1) { var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(pFld1)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SignExtendWideningLower(_fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector64<SByte>* pFld1 = &_fld1) { var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(pFld1)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _dataTable.outArrayPtr); } } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = AdvSimd.SignExtendWideningLower(test._fld1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunStructLclFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load)); var test = TestStruct.Create(); var result = AdvSimd.SignExtendWideningLower( AdvSimd.LoadVector64((SByte*)(&test._fld1)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunStructFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario_Load)); var test = TestStruct.Create(); test.RunStructFldScenario_Load(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); bool succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { succeeded = true; } if (!succeeded) { Succeeded = false; } } private void ValidateResult(Vector64<SByte> op1, void* result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), op1); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); ValidateResult(inArray1, outArray, method); } private void ValidateResult(void* op1, void* result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; Int16[] outArray = new Int16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector64<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int16>>()); ValidateResult(inArray1, outArray, method); } private void ValidateResult(SByte[] firstOp, Int16[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SignExtendWidening(firstOp[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SignExtendWideningLower)}<Int16>(Vector64<SByte>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.Private.Uri/tests/FunctionalTests/UriCreationOptionsTest.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using Xunit; namespace System.PrivateUri.Tests { public class UriCreationOptionsTest { [Fact] public void UriCreationOptions_HasReasonableDefaults() { UriCreationOptions options = default; Assert.False(options.DangerousDisablePathAndQueryCanonicalization); } [Fact] public void UriCreationOptions_StoresCorrectValues() { var options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }; Assert.True(options.DangerousDisablePathAndQueryCanonicalization); options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = false }; Assert.False(options.DangerousDisablePathAndQueryCanonicalization); } public static IEnumerable<object[]> DisableCanonicalization_TestData() { var schemes = new string[] { "http", "hTTp", " http", "https" }; var hosts = new string[] { "foo", "f\u00F6\u00F6.com" }; var ports = new string[] { ":80", ":443", ":0123", ":", "" }; var pathAndQueries = new string[] { "", " ", "a b", "a%20b", "?a b", "?a%20b", "foo/./", "foo/../", "//\\//", "%41", "A?%41=%42", "?%41=%42", "? ", }; var fragments = new string[] { "", "#", "#/foo ? %20%41/..//\\a" }; var unicodeInPathModes = new int[] { 0, 1, 2, 3 }; var pathDelimiters = new string[] { "", "/" }; // Get various combinations of paths with unicode characters and delimiters string[] rawTargets = pathAndQueries .SelectMany(pq => fragments.Select(fragment => pq + fragment)) .SelectMany(pqf => unicodeInPathModes.Select(unicodeMode => unicodeMode switch { 0 => pqf, 1 => "\u00F6" + pqf, 2 => pqf + "\u00F6", _ => pqf.Insert(pqf.Length / 2, "\u00F6") })) .ToHashSet() .SelectMany(pqf => pathDelimiters.Select(delimiter => delimiter + pqf)) .Where(target => target.StartsWith('/') || target.StartsWith('?')) // Can't see where the authority ends and the path starts otherwise .ToArray(); foreach (string scheme in schemes) { foreach (string host in hosts) { foreach (string port in ports) { foreach (string rawTarget in rawTargets) { string uriString = $"{scheme}://{host}{port}{rawTarget}"; int expectedPort = port.Length > 1 ? int.Parse(port.AsSpan(1)) : new Uri($"{scheme}://foo").Port; string expectedQuery = rawTarget.Contains('?') ? rawTarget.Substring(rawTarget.IndexOf('?')) : ""; string expectedPath = rawTarget.Substring(0, rawTarget.Length - expectedQuery.Length); yield return new object[] { uriString, host, expectedPort, expectedPath, expectedQuery }; } } } } } [Theory] [MemberData(nameof(DisableCanonicalization_TestData))] public void DisableCanonicalization_IsRespected(string uriString, string expectedHost, int expectedPort, string expectedPath, string expectedQuery) { var options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }; var uri = new Uri(uriString, options); DoAsserts(uri); Assert.True(Uri.TryCreate(uriString, options, out uri)); DoAsserts(uri); void DoAsserts(Uri uri) { Assert.Equal(new Uri($"http://{expectedHost}").Host, uri.Host); Assert.Equal(new Uri($"http://{expectedHost}").IdnHost, uri.IdnHost); Assert.Equal(expectedPort, uri.Port); Assert.Same(uri.AbsolutePath, uri.AbsolutePath); Assert.Equal(expectedPath, uri.AbsolutePath); Assert.Same(uri.Query, uri.Query); Assert.Equal(expectedQuery, uri.Query); string expectedPathAndQuery = expectedPath + expectedQuery; Assert.Same(uri.PathAndQuery, uri.PathAndQuery); Assert.Equal(expectedPathAndQuery, uri.PathAndQuery); Assert.Same(uri.Fragment, uri.Fragment); Assert.Empty(uri.Fragment); // Fragment is always empty if DisableCanonicalization is set } } [Fact] public void DisableCanonicalization_OnlyEqualToUrisWithMatchingFlag() { const string AbsoluteUri = "http://host"; const string Path = "/foo"; var absolute = new Uri(AbsoluteUri + Path, new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = false }); var absoluteRaw = new Uri(AbsoluteUri + Path, new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); NotEqual(absolute, absoluteRaw); Equal(absolute, absolute); Equal(absoluteRaw, absoluteRaw); var absoluteRawCopy = new Uri(AbsoluteUri + Path, new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); Equal(absoluteRaw, absoluteRawCopy); var absoluteRawDifferentPath = new Uri(AbsoluteUri + "/bar", new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); NotEqual(absoluteRaw, absoluteRawDifferentPath); var absoluteRawSameAuthority = new Uri(AbsoluteUri + ":80" + Path, new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); Equal(absoluteRaw, absoluteRawSameAuthority); static void Equal(Uri left, Uri right) { Assert.True(left.Equals(right)); Assert.True(right.Equals(left)); Assert.Equal(left.GetHashCode(), right.GetHashCode()); } static void NotEqual(Uri left, Uri right) { Assert.False(left.Equals(right)); Assert.False(right.Equals(left)); } } private const string FilePathRawData = "//\\A%41 %20\u00F6/.././%5C%2F#%42?%43#%44"; public static IEnumerable<object[]> ImplicitFilePaths_TestData() { yield return Entry("C:/"); yield return Entry("C|/"); yield return Entry(@"//foo"); yield return Entry(@"\/foo"); yield return Entry(@"/\foo"); yield return Entry(@"\\foo"); if (!PlatformDetection.IsWindows) { yield return Entry("/foo"); } static object[] Entry(string filePath) => new object[] { $"{filePath}/{FilePathRawData}" }; } [Theory] [MemberData(nameof(ImplicitFilePaths_TestData))] public void DisableCanonicalization_WorksWithFileUris(string implicitFilePath) { var options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }; var uri = new Uri(implicitFilePath, options); DoAsserts(uri); Assert.True(Uri.TryCreate(implicitFilePath, options, out uri)); DoAsserts(uri); static void DoAsserts(Uri uri) { Assert.True(uri.IsAbsoluteUri); Assert.True(uri.IsFile); Assert.Contains(FilePathRawData, uri.AbsolutePath); Assert.Contains(FilePathRawData, uri.AbsoluteUri); Assert.Contains(FilePathRawData, uri.ToString()); } } [Theory] [InlineData("http")] [InlineData("https")] [InlineData("ftp")] [InlineData("file")] [InlineData("custom-unknown")] [InlineData("custom-registered")] public void DisableCanonicalization_WorksWithDifferentSchemes(string scheme) { if (scheme == "custom-registered") { scheme += "DisableCanonicalization"; UriParser.Register(new HttpStyleUriParser(), scheme, defaultPort: Random.Shared.Next(-1, 65536)); } string uriString = $"{scheme}://host/p%41th?a=%42#fragm%45nt"; var options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }; var referenceUri = new Uri(uriString); var uri = new Uri(uriString, options); DoAsserts(uri); Assert.True(Uri.TryCreate(uriString, options, out uri)); DoAsserts(uri); void DoAsserts(Uri uri) { Assert.Same(referenceUri.Scheme, uri.Scheme); Assert.Equal(referenceUri.Host, uri.Host); Assert.Equal(referenceUri.IdnHost, uri.IdnHost); Assert.Equal(referenceUri.Authority, uri.Authority); Assert.Equal(referenceUri.Port, uri.Port); Assert.Equal(referenceUri.IsDefaultPort, uri.IsDefaultPort); string referencePath = "/pAth"; string referenceQuery = "?a=B"; string path = "/p%41th"; string query = "?a=%42#fragm%45nt"; if (scheme == "ftp") // No query { referencePath += referenceQuery.Replace("?", "%3F"); path += query; referenceQuery = string.Empty; query = string.Empty; } Assert.Equal(referencePath, referenceUri.AbsolutePath); Assert.Equal(path, uri.AbsolutePath); Assert.Equal(referenceQuery, referenceUri.Query); Assert.Equal(query, uri.Query); Assert.Equal(referencePath + referenceQuery, referenceUri.PathAndQuery); Assert.Equal(path + query, uri.PathAndQuery); Assert.Equal("#fragmEnt", referenceUri.Fragment); Assert.Empty(uri.Fragment); _ = referenceUri.GetComponents(UriComponents.AbsoluteUri, UriFormat.UriEscaped); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.Path, UriFormat.UriEscaped)); } } [Theory] [InlineData(UriFormat.UriEscaped)] [InlineData(UriFormat.Unescaped)] [InlineData(UriFormat.SafeUnescaped)] public void DisableCanonicalization_GetComponentsThrowsForPathAndQuery(UriFormat format) { var uri = new Uri("http://host/foo?bar=abc#fragment", new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); Assert.Equal("http", uri.GetComponents(UriComponents.Scheme, format)); Assert.Equal("host", uri.GetComponents(UriComponents.Host, format)); Assert.Equal("80", uri.GetComponents(UriComponents.StrongPort, format)); Assert.Empty(uri.GetComponents(UriComponents.Fragment, format)); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.Path, format)); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.Query, format)); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.PathAndQuery, format)); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.AbsoluteUri, format)); } private sealed class CustomUriParser : UriParser { } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Linq; using Xunit; namespace System.PrivateUri.Tests { public class UriCreationOptionsTest { [Fact] public void UriCreationOptions_HasReasonableDefaults() { UriCreationOptions options = default; Assert.False(options.DangerousDisablePathAndQueryCanonicalization); } [Fact] public void UriCreationOptions_StoresCorrectValues() { var options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }; Assert.True(options.DangerousDisablePathAndQueryCanonicalization); options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = false }; Assert.False(options.DangerousDisablePathAndQueryCanonicalization); } public static IEnumerable<object[]> DisableCanonicalization_TestData() { var schemes = new string[] { "http", "hTTp", " http", "https" }; var hosts = new string[] { "foo", "f\u00F6\u00F6.com" }; var ports = new string[] { ":80", ":443", ":0123", ":", "" }; var pathAndQueries = new string[] { "", " ", "a b", "a%20b", "?a b", "?a%20b", "foo/./", "foo/../", "//\\//", "%41", "A?%41=%42", "?%41=%42", "? ", }; var fragments = new string[] { "", "#", "#/foo ? %20%41/..//\\a" }; var unicodeInPathModes = new int[] { 0, 1, 2, 3 }; var pathDelimiters = new string[] { "", "/" }; // Get various combinations of paths with unicode characters and delimiters string[] rawTargets = pathAndQueries .SelectMany(pq => fragments.Select(fragment => pq + fragment)) .SelectMany(pqf => unicodeInPathModes.Select(unicodeMode => unicodeMode switch { 0 => pqf, 1 => "\u00F6" + pqf, 2 => pqf + "\u00F6", _ => pqf.Insert(pqf.Length / 2, "\u00F6") })) .ToHashSet() .SelectMany(pqf => pathDelimiters.Select(delimiter => delimiter + pqf)) .Where(target => target.StartsWith('/') || target.StartsWith('?')) // Can't see where the authority ends and the path starts otherwise .ToArray(); foreach (string scheme in schemes) { foreach (string host in hosts) { foreach (string port in ports) { foreach (string rawTarget in rawTargets) { string uriString = $"{scheme}://{host}{port}{rawTarget}"; int expectedPort = port.Length > 1 ? int.Parse(port.AsSpan(1)) : new Uri($"{scheme}://foo").Port; string expectedQuery = rawTarget.Contains('?') ? rawTarget.Substring(rawTarget.IndexOf('?')) : ""; string expectedPath = rawTarget.Substring(0, rawTarget.Length - expectedQuery.Length); yield return new object[] { uriString, host, expectedPort, expectedPath, expectedQuery }; } } } } } [Theory] [MemberData(nameof(DisableCanonicalization_TestData))] public void DisableCanonicalization_IsRespected(string uriString, string expectedHost, int expectedPort, string expectedPath, string expectedQuery) { var options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }; var uri = new Uri(uriString, options); DoAsserts(uri); Assert.True(Uri.TryCreate(uriString, options, out uri)); DoAsserts(uri); void DoAsserts(Uri uri) { Assert.Equal(new Uri($"http://{expectedHost}").Host, uri.Host); Assert.Equal(new Uri($"http://{expectedHost}").IdnHost, uri.IdnHost); Assert.Equal(expectedPort, uri.Port); Assert.Same(uri.AbsolutePath, uri.AbsolutePath); Assert.Equal(expectedPath, uri.AbsolutePath); Assert.Same(uri.Query, uri.Query); Assert.Equal(expectedQuery, uri.Query); string expectedPathAndQuery = expectedPath + expectedQuery; Assert.Same(uri.PathAndQuery, uri.PathAndQuery); Assert.Equal(expectedPathAndQuery, uri.PathAndQuery); Assert.Same(uri.Fragment, uri.Fragment); Assert.Empty(uri.Fragment); // Fragment is always empty if DisableCanonicalization is set } } [Fact] public void DisableCanonicalization_OnlyEqualToUrisWithMatchingFlag() { const string AbsoluteUri = "http://host"; const string Path = "/foo"; var absolute = new Uri(AbsoluteUri + Path, new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = false }); var absoluteRaw = new Uri(AbsoluteUri + Path, new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); NotEqual(absolute, absoluteRaw); Equal(absolute, absolute); Equal(absoluteRaw, absoluteRaw); var absoluteRawCopy = new Uri(AbsoluteUri + Path, new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); Equal(absoluteRaw, absoluteRawCopy); var absoluteRawDifferentPath = new Uri(AbsoluteUri + "/bar", new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); NotEqual(absoluteRaw, absoluteRawDifferentPath); var absoluteRawSameAuthority = new Uri(AbsoluteUri + ":80" + Path, new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); Equal(absoluteRaw, absoluteRawSameAuthority); static void Equal(Uri left, Uri right) { Assert.True(left.Equals(right)); Assert.True(right.Equals(left)); Assert.Equal(left.GetHashCode(), right.GetHashCode()); } static void NotEqual(Uri left, Uri right) { Assert.False(left.Equals(right)); Assert.False(right.Equals(left)); } } private const string FilePathRawData = "//\\A%41 %20\u00F6/.././%5C%2F#%42?%43#%44"; public static IEnumerable<object[]> ImplicitFilePaths_TestData() { yield return Entry("C:/"); yield return Entry("C|/"); yield return Entry(@"//foo"); yield return Entry(@"\/foo"); yield return Entry(@"/\foo"); yield return Entry(@"\\foo"); if (!PlatformDetection.IsWindows) { yield return Entry("/foo"); } static object[] Entry(string filePath) => new object[] { $"{filePath}/{FilePathRawData}" }; } [Theory] [MemberData(nameof(ImplicitFilePaths_TestData))] public void DisableCanonicalization_WorksWithFileUris(string implicitFilePath) { var options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }; var uri = new Uri(implicitFilePath, options); DoAsserts(uri); Assert.True(Uri.TryCreate(implicitFilePath, options, out uri)); DoAsserts(uri); static void DoAsserts(Uri uri) { Assert.True(uri.IsAbsoluteUri); Assert.True(uri.IsFile); Assert.Contains(FilePathRawData, uri.AbsolutePath); Assert.Contains(FilePathRawData, uri.AbsoluteUri); Assert.Contains(FilePathRawData, uri.ToString()); } } [Theory] [InlineData("http")] [InlineData("https")] [InlineData("ftp")] [InlineData("file")] [InlineData("custom-unknown")] [InlineData("custom-registered")] public void DisableCanonicalization_WorksWithDifferentSchemes(string scheme) { if (scheme == "custom-registered") { scheme += "DisableCanonicalization"; UriParser.Register(new HttpStyleUriParser(), scheme, defaultPort: Random.Shared.Next(-1, 65536)); } string uriString = $"{scheme}://host/p%41th?a=%42#fragm%45nt"; var options = new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }; var referenceUri = new Uri(uriString); var uri = new Uri(uriString, options); DoAsserts(uri); Assert.True(Uri.TryCreate(uriString, options, out uri)); DoAsserts(uri); void DoAsserts(Uri uri) { Assert.Same(referenceUri.Scheme, uri.Scheme); Assert.Equal(referenceUri.Host, uri.Host); Assert.Equal(referenceUri.IdnHost, uri.IdnHost); Assert.Equal(referenceUri.Authority, uri.Authority); Assert.Equal(referenceUri.Port, uri.Port); Assert.Equal(referenceUri.IsDefaultPort, uri.IsDefaultPort); string referencePath = "/pAth"; string referenceQuery = "?a=B"; string path = "/p%41th"; string query = "?a=%42#fragm%45nt"; if (scheme == "ftp") // No query { referencePath += referenceQuery.Replace("?", "%3F"); path += query; referenceQuery = string.Empty; query = string.Empty; } Assert.Equal(referencePath, referenceUri.AbsolutePath); Assert.Equal(path, uri.AbsolutePath); Assert.Equal(referenceQuery, referenceUri.Query); Assert.Equal(query, uri.Query); Assert.Equal(referencePath + referenceQuery, referenceUri.PathAndQuery); Assert.Equal(path + query, uri.PathAndQuery); Assert.Equal("#fragmEnt", referenceUri.Fragment); Assert.Empty(uri.Fragment); _ = referenceUri.GetComponents(UriComponents.AbsoluteUri, UriFormat.UriEscaped); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.Path, UriFormat.UriEscaped)); } } [Theory] [InlineData(UriFormat.UriEscaped)] [InlineData(UriFormat.Unescaped)] [InlineData(UriFormat.SafeUnescaped)] public void DisableCanonicalization_GetComponentsThrowsForPathAndQuery(UriFormat format) { var uri = new Uri("http://host/foo?bar=abc#fragment", new UriCreationOptions { DangerousDisablePathAndQueryCanonicalization = true }); Assert.Equal("http", uri.GetComponents(UriComponents.Scheme, format)); Assert.Equal("host", uri.GetComponents(UriComponents.Host, format)); Assert.Equal("80", uri.GetComponents(UriComponents.StrongPort, format)); Assert.Empty(uri.GetComponents(UriComponents.Fragment, format)); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.Path, format)); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.Query, format)); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.PathAndQuery, format)); Assert.Throws<InvalidOperationException>(() => uri.GetComponents(UriComponents.AbsoluteUri, format)); } private sealed class CustomUriParser : UriParser { } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.Private.Xml/tests/Readers/ReaderSettings/MaxSettings.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; using System; using System.IO; using XmlCoreTest.Common; namespace System.Xml.Tests { [TestCase(Name = "MaxCharacters Settings", Desc = "MaxCharacters Settings")] public partial class TCMaxSettings : TCXMLReaderBaseGeneral { private long _defaultCharsEnt = (long)1e7; // By default, entity resolving is limited to 10 million characters (On .NET Framework the default used to be zero (=unlimited) as LegacyXmlSettings was enabled) private long _defaultCharsDoc = 0; private long _maxVal = long.MaxValue; private long _bigVal = 100000; private string _path = Path.Combine(FilePathUtil.GetStandardPath(), @"xml10\entityexpansion\"); private string _path2 = Path.Combine(FilePathUtil.GetStandardPath(), @"XML10\ms_xml\"); private string[] _skipFiles = { "billionlaughs", "extent_4.xml", "surrogate_parameterentities_2.xml" }; private bool IsSkipped(string uri) { if (!uri.EndsWith(".xml")) { return true; } for (int i = 0; i < _skipFiles.Length; i++) { if (uri.Contains(_skipFiles[i])) return true; } return false; } [Variation(Pri = 0, Desc = "MaxSettings: get default values")] public int v1() { XmlReaderSettings rs = new XmlReaderSettings(); CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); using (XmlReader r = ReaderHelper.Create(new StringReader("<foo/>"))) { CError.Compare(r.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(r.Settings.MaxCharactersInDocument, _defaultCharsDoc, "Error"); } return TEST_PASS; } [Variation(Pri = 0, Desc = "MaxSettings: set, get values")] public int v2() { XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = 1; CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)rs.MaxCharactersInDocument, 1, "Error"); return TEST_PASS; } [Variation(Pri = 2, Desc = "MaxSettings: set negative, get default values, set 10 and get 10")] public int v3() { string xml = "<a/>"; XmlReaderSettings rs = new XmlReaderSettings(); try { rs.MaxCharactersFromEntities = -1; return TEST_FAIL; } catch (ArgumentOutOfRangeException) { } try { rs.MaxCharactersInDocument = -1; return TEST_FAIL; } catch (ArgumentOutOfRangeException) { } CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); rs.MaxCharactersFromEntities = 10; rs.MaxCharactersInDocument = 10; using (XmlReader r = ReaderHelper.Create(new StringReader(xml), rs)) { while (r.Read()) ; CError.Compare((int)r.Settings.MaxCharactersFromEntities, 10, "Error"); CError.Compare((int)r.Settings.MaxCharactersInDocument, 10, "Error"); } return TEST_PASS; } //[Variation(Pri = 2, Desc = "MaxCharactersFromEntities: set negative values, get default", Param = 1)] //[Variation(Pri = 2, Desc = "MaxCharactersFromEntities: set max negative values, get default", Param = 2)] public int v9() { long param = -1; if ((int)CurVariation.Param == 2) { param = -_maxVal; } XmlReaderSettings rs = new XmlReaderSettings(); try { rs.MaxCharactersFromEntities = param; } catch (ArgumentOutOfRangeException) { try { rs.MaxCharactersFromEntities = param; } catch (ArgumentOutOfRangeException) { CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); return TEST_PASS; } } return TEST_FAIL; } //[Variation(Pri = 2, Desc = "MaxCharactersInDocument: set negative values, get default", Param = 1)] //[Variation(Pri = 2, Desc = "MaxCharactersInDocument: set huge negative values, get default", Param = 2)] public int v10() { long param = -1; if ((int)CurVariation.Param == 2) { param = -_maxVal; } XmlReaderSettings rs = new XmlReaderSettings(); try { rs.MaxCharactersInDocument = param; } catch (ArgumentOutOfRangeException) { try { rs.MaxCharactersInDocument = param; } catch (ArgumentOutOfRangeException) { CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); return TEST_PASS; } } return TEST_FAIL; } //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A />"})] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE doc [ <!ELEMENT doc ANY> <!ENTITY book 'a&a'>]><doc>&book;</doc>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE doc [ <!ELEMENT doc ANY> <!ENTITY book 'a%a'>]><doc>&book;</doc> " })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE root [<!ELEMENT root ANY><!ENTITY e '\uD812\uDD12'>]><root>&e;</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v20() { string xml = CurVariation.Params[0] as string; int val = xml.Length - 1; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; try { XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs); if (AsyncUtil.IsAsyncEnabled) reader.Read(); } catch (XmlException) { CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)rs.MaxCharactersInDocument, val, "Error"); return TEST_PASS; } return TEST_FAIL; } //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v30() { string xml = CurVariation.Params[0] as string; int val = xml.Length; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersInDocument = val; rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; CError.Compare(reader.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare((int)reader.Settings.MaxCharactersInDocument, val, "Error"); } return TEST_PASS; } //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v40() { string xml = CurVariation.Params[0] as string; int val = xml.Length; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; CError.Compare((int)reader.Settings.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)reader.Settings.MaxCharactersInDocument, val, "Error"); } return TEST_PASS; } //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v50() { string xml = CurVariation.Params[0] as string; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 0; rs.MaxCharactersInDocument = 0; rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; CError.Compare((int)reader.Settings.MaxCharactersFromEntities, 0, "Error"); CError.Compare((int)reader.Settings.MaxCharactersInDocument, 0, "Error"); } return TEST_PASS; } //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v60() { string xml = CurVariation.Params[0] as string; XmlReaderSettings rs = new XmlReaderSettings(); rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; CError.Compare((long)reader.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare((long)reader.Settings.MaxCharactersInDocument, _defaultCharsDoc, "Error"); } return TEST_PASS; } //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&amp;</a>'>]><test>&a;<test>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<q = 'a'/>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { string.Format("<!-- http://www.w3.org is bound to n1 and n2 -->{0}<x xmlns:n1=\"http://www.w3.org\"{0} xmlns:n2=\"http://www.w3.org\" >{0} <bad n1:a=\"1\" n2:a=\"2\" /></x>", Environment.NewLine) })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<root><!--comment \uD812><!--comment \uD812>-->--></root>" })] public int v260() { string xml = CurVariation.Params[0] as string; XmlReaderSettings rs = new XmlReaderSettings(); rs.DtdProcessing = DtdProcessing.Ignore; rs.MaxCharactersFromEntities = _bigVal; rs.MaxCharactersInDocument = _bigVal; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { try { while (reader.Read()) ; } catch (XmlException) { CError.Compare(reader.Settings.MaxCharactersFromEntities, _bigVal, "Error"); CError.Compare(reader.Settings.MaxCharactersInDocument, _bigVal, "Error"); return TEST_PASS; } } return TEST_FAIL; } //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>", 10 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>", 25 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&amp;</a>'>]><test>&a;<test>", 26 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<q = 'a'/>", 5 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { string.Format("<!-- http://www.w3.org is bound to n1 and n2 -->{0}<x xmlns:n1=\"http://www.w3.org\"{0} xmlns:n2=\"http://www.w3.org\" >{0} <bad n1:a=\"1\" n2:a=\"2\" /></x>", Environment.NewLine), 35 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<root><!--comment \uD812><!--comment \uD812>-->--></root>", 18 })] public int v270() { string xml = CurVariation.Params[0] as string; int val = (int)CurVariation.Params[1]; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; try { using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; } } catch (XmlException) { CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)rs.MaxCharactersInDocument, val, "Error"); return TEST_PASS; } return TEST_FAIL; } private string _xml = @"<!DOCTYPE r [<!ENTITY e SYSTEM '" + Path.Combine(FilePathUtil.GetTestDataPath(), "XmlReader", "ent.ent") + @"'>]><r>&e;</r>"; } } internal class OneByteStream : Stream { private Stream _inner; public OneByteStream(string fileName) { _inner = FilePathUtil.getStream(fileName); } public override bool CanRead { get { return true; } } public override bool CanSeek { get { throw new Exception("The method or operation is not implemented."); } } public override bool CanWrite { get { throw new Exception("The method or operation is not implemented."); } } public override void Flush() { throw new Exception("The method or operation is not implemented."); } public override long Length { get { throw new Exception("The method or operation is not implemented."); } } public override long Position { get { throw new Exception("The method or operation is not implemented."); } set { throw new Exception("The method or operation is not implemented."); } } public override int Read(byte[] buffer, int offset, int count) { return _inner.Read(buffer, offset, 1); } public override long Seek(long offset, SeekOrigin origin) { throw new Exception("The method or operation is not implemented."); } public override void SetLength(long value) { throw new Exception("The method or operation is not implemented."); } public override void Write(byte[] buffer, int offset, int count) { throw new Exception("The method or operation is not implemented."); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; using System; using System.IO; using XmlCoreTest.Common; namespace System.Xml.Tests { [TestCase(Name = "MaxCharacters Settings", Desc = "MaxCharacters Settings")] public partial class TCMaxSettings : TCXMLReaderBaseGeneral { private long _defaultCharsEnt = (long)1e7; // By default, entity resolving is limited to 10 million characters (On .NET Framework the default used to be zero (=unlimited) as LegacyXmlSettings was enabled) private long _defaultCharsDoc = 0; private long _maxVal = long.MaxValue; private long _bigVal = 100000; private string _path = Path.Combine(FilePathUtil.GetStandardPath(), @"xml10\entityexpansion\"); private string _path2 = Path.Combine(FilePathUtil.GetStandardPath(), @"XML10\ms_xml\"); private string[] _skipFiles = { "billionlaughs", "extent_4.xml", "surrogate_parameterentities_2.xml" }; private bool IsSkipped(string uri) { if (!uri.EndsWith(".xml")) { return true; } for (int i = 0; i < _skipFiles.Length; i++) { if (uri.Contains(_skipFiles[i])) return true; } return false; } [Variation(Pri = 0, Desc = "MaxSettings: get default values")] public int v1() { XmlReaderSettings rs = new XmlReaderSettings(); CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); using (XmlReader r = ReaderHelper.Create(new StringReader("<foo/>"))) { CError.Compare(r.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(r.Settings.MaxCharactersInDocument, _defaultCharsDoc, "Error"); } return TEST_PASS; } [Variation(Pri = 0, Desc = "MaxSettings: set, get values")] public int v2() { XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = 1; CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)rs.MaxCharactersInDocument, 1, "Error"); return TEST_PASS; } [Variation(Pri = 2, Desc = "MaxSettings: set negative, get default values, set 10 and get 10")] public int v3() { string xml = "<a/>"; XmlReaderSettings rs = new XmlReaderSettings(); try { rs.MaxCharactersFromEntities = -1; return TEST_FAIL; } catch (ArgumentOutOfRangeException) { } try { rs.MaxCharactersInDocument = -1; return TEST_FAIL; } catch (ArgumentOutOfRangeException) { } CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); rs.MaxCharactersFromEntities = 10; rs.MaxCharactersInDocument = 10; using (XmlReader r = ReaderHelper.Create(new StringReader(xml), rs)) { while (r.Read()) ; CError.Compare((int)r.Settings.MaxCharactersFromEntities, 10, "Error"); CError.Compare((int)r.Settings.MaxCharactersInDocument, 10, "Error"); } return TEST_PASS; } //[Variation(Pri = 2, Desc = "MaxCharactersFromEntities: set negative values, get default", Param = 1)] //[Variation(Pri = 2, Desc = "MaxCharactersFromEntities: set max negative values, get default", Param = 2)] public int v9() { long param = -1; if ((int)CurVariation.Param == 2) { param = -_maxVal; } XmlReaderSettings rs = new XmlReaderSettings(); try { rs.MaxCharactersFromEntities = param; } catch (ArgumentOutOfRangeException) { try { rs.MaxCharactersFromEntities = param; } catch (ArgumentOutOfRangeException) { CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); return TEST_PASS; } } return TEST_FAIL; } //[Variation(Pri = 2, Desc = "MaxCharactersInDocument: set negative values, get default", Param = 1)] //[Variation(Pri = 2, Desc = "MaxCharactersInDocument: set huge negative values, get default", Param = 2)] public int v10() { long param = -1; if ((int)CurVariation.Param == 2) { param = -_maxVal; } XmlReaderSettings rs = new XmlReaderSettings(); try { rs.MaxCharactersInDocument = param; } catch (ArgumentOutOfRangeException) { try { rs.MaxCharactersInDocument = param; } catch (ArgumentOutOfRangeException) { CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error"); return TEST_PASS; } } return TEST_FAIL; } //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A />"})] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE doc [ <!ELEMENT doc ANY> <!ENTITY book 'a&a'>]><doc>&book;</doc>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE doc [ <!ELEMENT doc ANY> <!ENTITY book 'a%a'>]><doc>&book;</doc> " })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE root [<!ELEMENT root ANY><!ENTITY e '\uD812\uDD12'>]><root>&e;</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 2, Desc = "MaxEnt = 1, MaxDoc = length - 1", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v20() { string xml = CurVariation.Params[0] as string; int val = xml.Length - 1; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; try { XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs); if (AsyncUtil.IsAsyncEnabled) reader.Read(); } catch (XmlException) { CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)rs.MaxCharactersInDocument, val, "Error"); return TEST_PASS; } return TEST_FAIL; } //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc = length", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v30() { string xml = CurVariation.Params[0] as string; int val = xml.Length; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersInDocument = val; rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; CError.Compare(reader.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare((int)reader.Settings.MaxCharactersInDocument, val, "Error"); } return TEST_PASS; } //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 1, MaxDoc = length", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v40() { string xml = CurVariation.Params[0] as string; int val = xml.Length; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; CError.Compare((int)reader.Settings.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)reader.Settings.MaxCharactersInDocument, val, "Error"); } return TEST_PASS; } //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt = 0, MaxDoc = 0", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v50() { string xml = CurVariation.Params[0] as string; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 0; rs.MaxCharactersInDocument = 0; rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; CError.Compare((int)reader.Settings.MaxCharactersFromEntities, 0, "Error"); CError.Compare((int)reader.Settings.MaxCharactersInDocument, 0, "Error"); } return TEST_PASS; } //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A>truck</A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root><!--\uD812\uDD12--></Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root>&#x58341;<Elem>&#xCFE44;</Elem>&#x18022;</Root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<X>t0<A>truck</A>t00</X>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<a:A xmlns:a='a'><C xmlns:p='nsc' /><B /></a:A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns:p='nsc'><p:C xmlns:a='a'><a:S /></p:C><B /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns='ns0'><![CDATA[tralala]]></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A xmlns='ns0'><![CDATA[ja_a_hele]]><?PI?><X />text<Y /></A>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<A attr='1' a2='a2' a3='a3' xmlns='def' xmlns:p='ns' p:a3='pa3' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<!DOCTYPE root[<!ENTITY x 'somevalue'><!ELEMENT root ANY>]><root>value&amp;x;</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<root>va&lt;/root&gt;lue</root>" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a='&amp;' b='&amp;#65;' c='&amp;#x43;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a='b&quot;c' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root a=' &#x9;&#xD;&#xA;' />" })] //[Variation(Pri = 0, Desc = "MaxEnt not set, MaxDoc not set", Params = new object[] { "<Root foo='&amp; &lt; &gt; &quot; &apos; &#65;'/>" })] public int v60() { string xml = CurVariation.Params[0] as string; XmlReaderSettings rs = new XmlReaderSettings(); rs.DtdProcessing = DtdProcessing.Ignore; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; CError.Compare((long)reader.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error"); CError.Compare((long)reader.Settings.MaxCharactersInDocument, _defaultCharsDoc, "Error"); } return TEST_PASS; } //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&amp;</a>'>]><test>&a;<test>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<q = 'a'/>" })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { string.Format("<!-- http://www.w3.org is bound to n1 and n2 -->{0}<x xmlns:n1=\"http://www.w3.org\"{0} xmlns:n2=\"http://www.w3.org\" >{0} <bad n1:a=\"1\" n2:a=\"2\" /></x>", Environment.NewLine) })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = bigVal, MaxDoc = bigVal", Params = new object[] { "<root><!--comment \uD812><!--comment \uD812>-->--></root>" })] public int v260() { string xml = CurVariation.Params[0] as string; XmlReaderSettings rs = new XmlReaderSettings(); rs.DtdProcessing = DtdProcessing.Ignore; rs.MaxCharactersFromEntities = _bigVal; rs.MaxCharactersInDocument = _bigVal; using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { try { while (reader.Read()) ; } catch (XmlException) { CError.Compare(reader.Settings.MaxCharactersFromEntities, _bigVal, "Error"); CError.Compare(reader.Settings.MaxCharactersInDocument, _bigVal, "Error"); return TEST_PASS; } } return TEST_FAIL; } //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<!DOCTYPE ROOT [<!ENTITY a '&a;'>]><ROOT att='&a;'/>", 10 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&a;</a>'>]><test>&a;</test>", 25 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<?xml version='1.0'?><!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT a ANY> <!ELEMENT b ANY> <!ELEMENT c ANY> <!ENTITY a '<a>&amp;</a>'>]><test>&a;<test>", 26 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<q = 'a'/>", 5 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { string.Format("<!-- http://www.w3.org is bound to n1 and n2 -->{0}<x xmlns:n1=\"http://www.w3.org\"{0} xmlns:n2=\"http://www.w3.org\" >{0} <bad n1:a=\"1\" n2:a=\"2\" /></x>", Environment.NewLine), 35 })] //[Variation(Pri = 2, Desc = "nwf xml: MaxEnt = 1, MaxDoc = val", Params = new object[] { "<root><!--comment \uD812><!--comment \uD812>-->--></root>", 18 })] public int v270() { string xml = CurVariation.Params[0] as string; int val = (int)CurVariation.Params[1]; XmlReaderSettings rs = new XmlReaderSettings(); rs.MaxCharactersFromEntities = 1; rs.MaxCharactersInDocument = val; try { using (XmlReader reader = ReaderHelper.Create(new StringReader(xml), rs)) { while (reader.Read()) ; } } catch (XmlException) { CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error"); CError.Compare((int)rs.MaxCharactersInDocument, val, "Error"); return TEST_PASS; } return TEST_FAIL; } private string _xml = @"<!DOCTYPE r [<!ENTITY e SYSTEM '" + Path.Combine(FilePathUtil.GetTestDataPath(), "XmlReader", "ent.ent") + @"'>]><r>&e;</r>"; } } internal class OneByteStream : Stream { private Stream _inner; public OneByteStream(string fileName) { _inner = FilePathUtil.getStream(fileName); } public override bool CanRead { get { return true; } } public override bool CanSeek { get { throw new Exception("The method or operation is not implemented."); } } public override bool CanWrite { get { throw new Exception("The method or operation is not implemented."); } } public override void Flush() { throw new Exception("The method or operation is not implemented."); } public override long Length { get { throw new Exception("The method or operation is not implemented."); } } public override long Position { get { throw new Exception("The method or operation is not implemented."); } set { throw new Exception("The method or operation is not implemented."); } } public override int Read(byte[] buffer, int offset, int count) { return _inner.Read(buffer, offset, 1); } public override long Seek(long offset, SeekOrigin origin) { throw new Exception("The method or operation is not implemented."); } public override void SetLength(long value) { throw new Exception("The method or operation is not implemented."); } public override void Write(byte[] buffer, int offset, int count) { throw new Exception("The method or operation is not implemented."); } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Win32.SafeHandles; using System.Diagnostics; using System.Net.Security; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Security.Principal; namespace System.Net { internal static partial class CertificateValidationPal { internal static SslPolicyErrors VerifyCertificateProperties( SafeDeleteContext? securityContext, X509Chain chain, X509Certificate2 remoteCertificate, bool checkCertName, bool isServer, string? hostName) { return CertificateValidation.BuildChainAndVerifyProperties(chain, remoteCertificate, checkCertName, isServer, hostName); } // // Extracts a remote certificate upon request. // internal static X509Certificate2? GetRemoteCertificate(SafeDeleteContext? securityContext) => GetRemoteCertificate(securityContext, retrieveCollection: false, out _); internal static X509Certificate2? GetRemoteCertificate(SafeDeleteContext? securityContext, out X509Certificate2Collection? remoteCertificateCollection) => GetRemoteCertificate(securityContext, retrieveCollection: true, out remoteCertificateCollection); private static X509Certificate2? GetRemoteCertificate( SafeDeleteContext? securityContext, bool retrieveCollection, out X509Certificate2Collection? remoteCertificateCollection) { remoteCertificateCollection = null; if (securityContext == null) { return null; } X509Certificate2? result = null; SafeFreeCertContext? remoteContext = null; try { // SECPKG_ATTR_REMOTE_CERT_CONTEXT will not succeed before TLS handshake completes. Inside the handshake, // we need to use (more expensive) SECPKG_ATTR_REMOTE_CERT_CHAIN. That one may be unsupported on older // versions of windows. In that case, we have no option than to return null. // // We can use retrieveCollection to distinguish between in-handshake and after-handshake calls, because // the collection is retrieved for cert validation purposes after the handshake completes. if (retrieveCollection) // handshake completed { SSPIWrapper.QueryContextAttributes_SECPKG_ATTR_REMOTE_CERT_CONTEXT(GlobalSSPI.SSPISecureChannel, securityContext, out remoteContext); } else // in handshake { SSPIWrapper.QueryContextAttributes_SECPKG_ATTR_REMOTE_CERT_CHAIN(GlobalSSPI.SSPISecureChannel, securityContext, out remoteContext); } if (remoteContext != null && !remoteContext.IsInvalid) { result = new X509Certificate2(remoteContext.DangerousGetHandle()); } } finally { if (remoteContext != null && !remoteContext.IsInvalid) { if (retrieveCollection) { remoteCertificateCollection = UnmanagedCertificateContext.GetRemoteCertificatesFromStoreContext(remoteContext); } remoteContext.Dispose(); } } if (NetEventSource.Log.IsEnabled()) NetEventSource.Log.RemoteCertificate(result); return result; } // // Used only by client SSL code, never returns null. // internal static string[] GetRequestCertificateAuthorities(SafeDeleteContext securityContext) { Interop.SspiCli.SecPkgContext_IssuerListInfoEx issuerList = default; bool success = SSPIWrapper.QueryContextAttributes_SECPKG_ATTR_ISSUER_LIST_EX(GlobalSSPI.SSPISecureChannel, securityContext, ref issuerList, out SafeHandle? sspiHandle); string[] issuers = Array.Empty<string>(); try { if (success && issuerList.cIssuers > 0) { unsafe { issuers = new string[issuerList.cIssuers]; var elements = new Span<Interop.SspiCli.CERT_CHAIN_ELEMENT>((void*)sspiHandle!.DangerousGetHandle(), issuers.Length); for (int i = 0; i < elements.Length; ++i) { Debug.Assert(elements[i].cbSize > 0, $"Interop.SspiCli._CERT_CHAIN_ELEMENT size is not positive: {elements[i].cbSize}"); if (elements[i].cbSize > 0) { byte[] x = new Span<byte>((byte*)elements[i].pCertContext, checked((int)elements[i].cbSize)).ToArray(); var x500DistinguishedName = new X500DistinguishedName(x); issuers[i] = x500DistinguishedName.Name; if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(securityContext, $"IssuerListEx[{issuers[i]}]"); } } } } } finally { sspiHandle?.Dispose(); } return issuers; } // // Security: We temporarily reset thread token to open the cert store under process account. // internal static X509Store OpenStore(StoreLocation storeLocation) { X509Store store = new X509Store(StoreName.My, storeLocation); // For app-compat We want to ensure the store is opened under the **process** account. try { WindowsIdentity.RunImpersonated(SafeAccessTokenHandle.InvalidHandle, () => { store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); }); } catch { throw; } return store; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Win32.SafeHandles; using System.Diagnostics; using System.Net.Security; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Security.Principal; namespace System.Net { internal static partial class CertificateValidationPal { internal static SslPolicyErrors VerifyCertificateProperties( SafeDeleteContext? securityContext, X509Chain chain, X509Certificate2 remoteCertificate, bool checkCertName, bool isServer, string? hostName) { return CertificateValidation.BuildChainAndVerifyProperties(chain, remoteCertificate, checkCertName, isServer, hostName); } // // Extracts a remote certificate upon request. // internal static X509Certificate2? GetRemoteCertificate(SafeDeleteContext? securityContext) => GetRemoteCertificate(securityContext, retrieveCollection: false, out _); internal static X509Certificate2? GetRemoteCertificate(SafeDeleteContext? securityContext, out X509Certificate2Collection? remoteCertificateCollection) => GetRemoteCertificate(securityContext, retrieveCollection: true, out remoteCertificateCollection); private static X509Certificate2? GetRemoteCertificate( SafeDeleteContext? securityContext, bool retrieveCollection, out X509Certificate2Collection? remoteCertificateCollection) { remoteCertificateCollection = null; if (securityContext == null) { return null; } X509Certificate2? result = null; SafeFreeCertContext? remoteContext = null; try { // SECPKG_ATTR_REMOTE_CERT_CONTEXT will not succeed before TLS handshake completes. Inside the handshake, // we need to use (more expensive) SECPKG_ATTR_REMOTE_CERT_CHAIN. That one may be unsupported on older // versions of windows. In that case, we have no option than to return null. // // We can use retrieveCollection to distinguish between in-handshake and after-handshake calls, because // the collection is retrieved for cert validation purposes after the handshake completes. if (retrieveCollection) // handshake completed { SSPIWrapper.QueryContextAttributes_SECPKG_ATTR_REMOTE_CERT_CONTEXT(GlobalSSPI.SSPISecureChannel, securityContext, out remoteContext); } else // in handshake { SSPIWrapper.QueryContextAttributes_SECPKG_ATTR_REMOTE_CERT_CHAIN(GlobalSSPI.SSPISecureChannel, securityContext, out remoteContext); } if (remoteContext != null && !remoteContext.IsInvalid) { result = new X509Certificate2(remoteContext.DangerousGetHandle()); } } finally { if (remoteContext != null && !remoteContext.IsInvalid) { if (retrieveCollection) { remoteCertificateCollection = UnmanagedCertificateContext.GetRemoteCertificatesFromStoreContext(remoteContext); } remoteContext.Dispose(); } } if (NetEventSource.Log.IsEnabled()) NetEventSource.Log.RemoteCertificate(result); return result; } // // Used only by client SSL code, never returns null. // internal static string[] GetRequestCertificateAuthorities(SafeDeleteContext securityContext) { Interop.SspiCli.SecPkgContext_IssuerListInfoEx issuerList = default; bool success = SSPIWrapper.QueryContextAttributes_SECPKG_ATTR_ISSUER_LIST_EX(GlobalSSPI.SSPISecureChannel, securityContext, ref issuerList, out SafeHandle? sspiHandle); string[] issuers = Array.Empty<string>(); try { if (success && issuerList.cIssuers > 0) { unsafe { issuers = new string[issuerList.cIssuers]; var elements = new Span<Interop.SspiCli.CERT_CHAIN_ELEMENT>((void*)sspiHandle!.DangerousGetHandle(), issuers.Length); for (int i = 0; i < elements.Length; ++i) { Debug.Assert(elements[i].cbSize > 0, $"Interop.SspiCli._CERT_CHAIN_ELEMENT size is not positive: {elements[i].cbSize}"); if (elements[i].cbSize > 0) { byte[] x = new Span<byte>((byte*)elements[i].pCertContext, checked((int)elements[i].cbSize)).ToArray(); var x500DistinguishedName = new X500DistinguishedName(x); issuers[i] = x500DistinguishedName.Name; if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(securityContext, $"IssuerListEx[{issuers[i]}]"); } } } } } finally { sspiHandle?.Dispose(); } return issuers; } // // Security: We temporarily reset thread token to open the cert store under process account. // internal static X509Store OpenStore(StoreLocation storeLocation) { X509Store store = new X509Store(StoreName.My, storeLocation); // For app-compat We want to ensure the store is opened under the **process** account. try { WindowsIdentity.RunImpersonated(SafeAccessTokenHandle.InvalidHandle, () => { store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); }); } catch { throw; } return store; } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/Microsoft.Extensions.HostFactoryResolver/tests/MockHostTypes/WebHostBuilder.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace MockHostTypes { public class WebHostBuilder : IWebHostBuilder { public IWebHost Build() => new WebHost(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace MockHostTypes { public class WebHostBuilder : IWebHostBuilder { public IWebHost Build() => new WebHost(); } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // ------------------------------------------------------------------------------ // Changes to this file must follow the https://aka.ms/api-review process. // ------------------------------------------------------------------------------ namespace System.Text.RegularExpressions { public partial class Capture { internal Capture() { } public int Index { get { throw null; } } public int Length { get { throw null; } } public string Value { get { throw null; } } public System.ReadOnlySpan<char> ValueSpan { get { throw null; } } public override string ToString() { throw null; } } public partial class CaptureCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Capture>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList { internal CaptureCollection() { } public int Count { get { throw null; } } public bool IsReadOnly { get { throw null; } } public bool IsSynchronized { get { throw null; } } public System.Text.RegularExpressions.Capture this[int i] { get { throw null; } } public object SyncRoot { get { throw null; } } System.Text.RegularExpressions.Capture System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.this[int index] { get { throw null; } set { } } bool System.Collections.IList.IsFixedSize { get { throw null; } } object? System.Collections.IList.this[int index] { get { throw null; } set { } } public void CopyTo(System.Array array, int arrayIndex) { } public void CopyTo(System.Text.RegularExpressions.Capture[] array, int arrayIndex) { } public System.Collections.IEnumerator GetEnumerator() { throw null; } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Add(System.Text.RegularExpressions.Capture item) { } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Clear() { } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Contains(System.Text.RegularExpressions.Capture item) { throw null; } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Remove(System.Text.RegularExpressions.Capture item) { throw null; } System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Capture> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Capture>.GetEnumerator() { throw null; } int System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.IndexOf(System.Text.RegularExpressions.Capture item) { throw null; } void System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.Insert(int index, System.Text.RegularExpressions.Capture item) { } void System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.RemoveAt(int index) { } int System.Collections.IList.Add(object? value) { throw null; } void System.Collections.IList.Clear() { } bool System.Collections.IList.Contains(object? value) { throw null; } int System.Collections.IList.IndexOf(object? value) { throw null; } void System.Collections.IList.Insert(int index, object? value) { } void System.Collections.IList.Remove(object? value) { } void System.Collections.IList.RemoveAt(int index) { } } public partial class Group : System.Text.RegularExpressions.Capture { internal Group() { } public System.Text.RegularExpressions.CaptureCollection Captures { get { throw null; } } public string Name { get { throw null; } } public bool Success { get { throw null; } } public static System.Text.RegularExpressions.Group Synchronized(System.Text.RegularExpressions.Group inner) { throw null; } } public partial class GroupCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, System.Text.RegularExpressions.Group>>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group>, System.Collections.Generic.IList<System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<string, System.Text.RegularExpressions.Group>>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyDictionary<string, System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Group>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList { internal GroupCollection() { } public int Count { get { throw null; } } public bool IsReadOnly { get { throw null; } } public bool IsSynchronized { get { throw null; } } public System.Text.RegularExpressions.Group this[int groupnum] { get { throw null; } } public System.Text.RegularExpressions.Group this[string groupname] { get { throw null; } } public System.Collections.Generic.IEnumerable<string> Keys { get { throw null; } } public object SyncRoot { get { throw null; } } System.Text.RegularExpressions.Group System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.this[int index] { get { throw null; } set { } } bool System.Collections.IList.IsFixedSize { get { throw null; } } object? System.Collections.IList.this[int index] { get { throw null; } set { } } public System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group> Values { get { throw null; } } public bool ContainsKey(string key) { throw null; } public void CopyTo(System.Array array, int arrayIndex) { } public void CopyTo(System.Text.RegularExpressions.Group[] array, int arrayIndex) { } public System.Collections.IEnumerator GetEnumerator() { throw null; } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Add(System.Text.RegularExpressions.Group item) { } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Clear() { } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Contains(System.Text.RegularExpressions.Group item) { throw null; } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Remove(System.Text.RegularExpressions.Group item) { throw null; } System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, System.Text.RegularExpressions.Group>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, System.Text.RegularExpressions.Group>>.GetEnumerator() { throw null; } System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Group> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group>.GetEnumerator() { throw null; } int System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.IndexOf(System.Text.RegularExpressions.Group item) { throw null; } void System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.Insert(int index, System.Text.RegularExpressions.Group item) { } void System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.RemoveAt(int index) { } int System.Collections.IList.Add(object? value) { throw null; } void System.Collections.IList.Clear() { } bool System.Collections.IList.Contains(object? value) { throw null; } int System.Collections.IList.IndexOf(object? value) { throw null; } void System.Collections.IList.Insert(int index, object? value) { } void System.Collections.IList.Remove(object? value) { } void System.Collections.IList.RemoveAt(int index) { } public bool TryGetValue(string key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Text.RegularExpressions.Group? value) { throw null; } } public partial class Match : System.Text.RegularExpressions.Group { internal Match() { } public static System.Text.RegularExpressions.Match Empty { get { throw null; } } public virtual System.Text.RegularExpressions.GroupCollection Groups { get { throw null; } } public System.Text.RegularExpressions.Match NextMatch() { throw null; } public virtual string Result(string replacement) { throw null; } public static System.Text.RegularExpressions.Match Synchronized(System.Text.RegularExpressions.Match inner) { throw null; } } public partial class MatchCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>, System.Collections.Generic.IList<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Match>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList { internal MatchCollection() { } public int Count { get { throw null; } } public bool IsReadOnly { get { throw null; } } public bool IsSynchronized { get { throw null; } } public virtual System.Text.RegularExpressions.Match this[int i] { get { throw null; } } public object SyncRoot { get { throw null; } } System.Text.RegularExpressions.Match System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.this[int index] { get { throw null; } set { } } bool System.Collections.IList.IsFixedSize { get { throw null; } } object? System.Collections.IList.this[int index] { get { throw null; } set { } } public void CopyTo(System.Array array, int arrayIndex) { } public void CopyTo(System.Text.RegularExpressions.Match[] array, int arrayIndex) { } public System.Collections.IEnumerator GetEnumerator() { throw null; } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Add(System.Text.RegularExpressions.Match item) { } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Clear() { } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Contains(System.Text.RegularExpressions.Match item) { throw null; } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Remove(System.Text.RegularExpressions.Match item) { throw null; } System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Match> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>.GetEnumerator() { throw null; } int System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.IndexOf(System.Text.RegularExpressions.Match item) { throw null; } void System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.Insert(int index, System.Text.RegularExpressions.Match item) { } void System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.RemoveAt(int index) { } int System.Collections.IList.Add(object? value) { throw null; } void System.Collections.IList.Clear() { } bool System.Collections.IList.Contains(object? value) { throw null; } int System.Collections.IList.IndexOf(object? value) { throw null; } void System.Collections.IList.Insert(int index, object? value) { } void System.Collections.IList.Remove(object? value) { } void System.Collections.IList.RemoveAt(int index) { } } public delegate string MatchEvaluator(System.Text.RegularExpressions.Match match); public partial class Regex : System.Runtime.Serialization.ISerializable { protected internal System.Collections.Hashtable? capnames; protected internal System.Collections.Hashtable? caps; protected internal int capsize; protected internal string[]? capslist; protected internal System.Text.RegularExpressions.RegexRunnerFactory? factory; public static readonly System.TimeSpan InfiniteMatchTimeout; protected internal System.TimeSpan internalMatchTimeout; protected internal string? pattern; protected internal System.Text.RegularExpressions.RegexOptions roptions; protected Regex() { } protected Regex(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public Regex([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { } public Regex([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { } public Regex([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { } public static int CacheSize { get { throw null; } set { } } [System.CLSCompliantAttribute(false)] [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] protected System.Collections.IDictionary? CapNames { get { throw null; } set { } } [System.CLSCompliantAttribute(false)] [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] protected System.Collections.IDictionary? Caps { get { throw null; } set { } } public System.TimeSpan MatchTimeout { get { throw null; } } public System.Text.RegularExpressions.RegexOptions Options { get { throw null; } } public bool RightToLeft { get { throw null; } } [System.ObsoleteAttribute("Regex.CompileToAssembly is obsolete and not supported. Use the RegexGeneratorAttribute with the regular expression source generator instead.", DiagnosticId = "SYSLIB0036", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public static void CompileToAssembly(System.Text.RegularExpressions.RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname) { } [System.ObsoleteAttribute("Regex.CompileToAssembly is obsolete and not supported. Use the RegexGeneratorAttribute with the regular expression source generator instead.", DiagnosticId = "SYSLIB0036", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public static void CompileToAssembly(System.Text.RegularExpressions.RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname, System.Reflection.Emit.CustomAttributeBuilder[]? attributes) { } [System.ObsoleteAttribute("Regex.CompileToAssembly is obsolete and not supported. Use the RegexGeneratorAttribute with the regular expression source generator instead.", DiagnosticId = "SYSLIB0036", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public static void CompileToAssembly(System.Text.RegularExpressions.RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname, System.Reflection.Emit.CustomAttributeBuilder[]? attributes, string? resourceFile) { } public int Count(string input) { throw null; } public static int Count(string input, [System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static int Count(string input, [System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static int Count(string input, [System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public static string Escape(string str) { throw null; } public string[] GetGroupNames() { throw null; } public int[] GetGroupNumbers() { throw null; } public string GroupNameFromNumber(int i) { throw null; } public int GroupNumberFromName(string name) { throw null; } protected void InitializeReferences() { } public bool IsMatch(System.ReadOnlySpan<char> input) { throw null; } public static bool IsMatch(System.ReadOnlySpan<char> input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static bool IsMatch(System.ReadOnlySpan<char> input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static bool IsMatch(System.ReadOnlySpan<char> input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public bool IsMatch(string input) { throw null; } public bool IsMatch(string input, int startat) { throw null; } public static bool IsMatch(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static bool IsMatch(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static bool IsMatch(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public System.Text.RegularExpressions.Match Match(string input) { throw null; } public System.Text.RegularExpressions.Match Match(string input, int startat) { throw null; } public System.Text.RegularExpressions.Match Match(string input, int beginning, int length) { throw null; } public static System.Text.RegularExpressions.Match Match(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static System.Text.RegularExpressions.Match Match(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static System.Text.RegularExpressions.Match Match(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public System.Text.RegularExpressions.MatchCollection Matches(string input) { throw null; } public System.Text.RegularExpressions.MatchCollection Matches(string input, int startat) { throw null; } public static System.Text.RegularExpressions.MatchCollection Matches(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static System.Text.RegularExpressions.MatchCollection Matches(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static System.Text.RegularExpressions.MatchCollection Matches(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public string Replace(string input, string replacement) { throw null; } public string Replace(string input, string replacement, int count) { throw null; } public string Replace(string input, string replacement, int count, int startat) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern, string replacement) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, string replacement, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, string replacement, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator) { throw null; } public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count) { throw null; } public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count, int startat) { throw null; } public string[] Split(string input) { throw null; } public string[] Split(string input, int count) { throw null; } public string[] Split(string input, int count, int startat) { throw null; } public static string[] Split(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static string[] Split(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static string[] Split(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } public static string Unescape(string str) { throw null; } protected bool UseOptionC() { throw null; } protected internal bool UseOptionR() { throw null; } protected internal static void ValidateMatchTimeout(System.TimeSpan matchTimeout) { } } [System.ObsoleteAttribute("Regex.CompileToAssembly is obsolete and not supported. Use the RegexGeneratorAttribute with the regular expression source generator instead.", DiagnosticId = "SYSLIB0036", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial class RegexCompilationInfo { public RegexCompilationInfo(string pattern, System.Text.RegularExpressions.RegexOptions options, string name, string fullnamespace, bool ispublic) { } public RegexCompilationInfo(string pattern, System.Text.RegularExpressions.RegexOptions options, string name, string fullnamespace, bool ispublic, System.TimeSpan matchTimeout) { } public bool IsPublic { get { throw null; } set { } } public System.TimeSpan MatchTimeout { get { throw null; } set { } } public string Name { get { throw null; } set { } } public string Namespace { get { throw null; } set { } } public System.Text.RegularExpressions.RegexOptions Options { get { throw null; } set { } } public string Pattern { get { throw null; } set { } } } [System.AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public sealed partial class RegexGeneratorAttribute : System.Attribute { public RegexGeneratorAttribute([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { } public RegexGeneratorAttribute([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { } public RegexGeneratorAttribute([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, int matchTimeoutMilliseconds) { } public string Pattern { get; } public System.Text.RegularExpressions.RegexOptions Options { get; } public int MatchTimeoutMilliseconds { get; } } public partial class RegexMatchTimeoutException : System.TimeoutException, System.Runtime.Serialization.ISerializable { public RegexMatchTimeoutException() { } protected RegexMatchTimeoutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public RegexMatchTimeoutException(string message) { } public RegexMatchTimeoutException(string message, System.Exception inner) { } public RegexMatchTimeoutException(string regexInput, string regexPattern, System.TimeSpan matchTimeout) { } public string Input { get { throw null; } } public System.TimeSpan MatchTimeout { get { throw null; } } public string Pattern { get { throw null; } } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } [System.FlagsAttribute] public enum RegexOptions { None = 0, IgnoreCase = 1, Multiline = 2, ExplicitCapture = 4, Compiled = 8, Singleline = 16, IgnorePatternWhitespace = 32, RightToLeft = 64, ECMAScript = 256, CultureInvariant = 512, NonBacktracking = 1024, } public enum RegexParseError { Unknown = 0, AlternationHasTooManyConditions = 1, AlternationHasMalformedCondition = 2, InvalidUnicodePropertyEscape = 3, MalformedUnicodePropertyEscape = 4, UnrecognizedEscape = 5, UnrecognizedControlCharacter = 6, MissingControlCharacter = 7, InsufficientOrInvalidHexDigits = 8, QuantifierOrCaptureGroupOutOfRange = 9, UndefinedNamedReference = 10, UndefinedNumberedReference = 11, MalformedNamedReference = 12, UnescapedEndingBackslash = 13, UnterminatedComment = 14, InvalidGroupingConstruct = 15, AlternationHasNamedCapture = 16, AlternationHasComment = 17, AlternationHasMalformedReference = 18, AlternationHasUndefinedReference = 19, CaptureGroupNameInvalid = 20, CaptureGroupOfZero = 21, UnterminatedBracket = 22, ExclusionGroupNotLast = 23, ReversedCharacterRange = 24, ShorthandClassInCharacterRange = 25, InsufficientClosingParentheses = 26, ReversedQuantifierRange = 27, NestedQuantifiersNotParenthesized = 28, QuantifierAfterNothing = 29, InsufficientOpeningParentheses = 30, UnrecognizedUnicodeProperty = 31, } public sealed partial class RegexParseException : System.ArgumentException { private RegexParseException() { } public System.Text.RegularExpressions.RegexParseError Error { get { throw null; } } public int Offset { get { throw null; } } public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public abstract partial class RegexRunner { protected internal int[]? runcrawl; protected internal int runcrawlpos; protected internal System.Text.RegularExpressions.Match? runmatch; protected internal System.Text.RegularExpressions.Regex? runregex; protected internal int[]? runstack; protected internal int runstackpos; protected internal string? runtext; protected internal int runtextbeg; protected internal int runtextend; protected internal int runtextpos; protected internal int runtextstart; protected internal int[]? runtrack; protected internal int runtrackcount; protected internal int runtrackpos; protected internal RegexRunner() { } protected void Capture(int capnum, int start, int end) { } protected static bool CharInClass(char ch, string charClass) { throw null; } protected static bool CharInSet(char ch, string @set, string category) { throw null; } protected void CheckTimeout() { } protected void Crawl(int i) { } protected int Crawlpos() { throw null; } protected void DoubleCrawl() { } protected void DoubleStack() { } protected void DoubleTrack() { } protected void EnsureStorage() { } protected virtual bool FindFirstChar() { throw null; } protected virtual void Go() { throw null; } protected virtual void InitTrackCount() { throw null; } protected bool IsBoundary(int index, int startpos, int endpos) { throw null; } protected bool IsECMABoundary(int index, int startpos, int endpos) { throw null; } protected bool IsMatched(int cap) { throw null; } protected int MatchIndex(int cap) { throw null; } protected int MatchLength(int cap) { throw null; } protected int Popcrawl() { throw null; } protected internal System.Text.RegularExpressions.Match? Scan(System.Text.RegularExpressions.Regex regex, string text, int textbeg, int textend, int textstart, int prevlen, bool quick) { throw null; } protected internal System.Text.RegularExpressions.Match? Scan(System.Text.RegularExpressions.Regex regex, string text, int textbeg, int textend, int textstart, int prevlen, bool quick, System.TimeSpan timeout) { throw null; } protected internal virtual void Scan(System.ReadOnlySpan<char> text) { throw null; } protected void TransferCapture(int capnum, int uncapnum, int start, int end) { } protected void Uncapture() { } } public abstract partial class RegexRunnerFactory { protected RegexRunnerFactory() { } protected internal abstract System.Text.RegularExpressions.RegexRunner CreateInstance(); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // ------------------------------------------------------------------------------ // Changes to this file must follow the https://aka.ms/api-review process. // ------------------------------------------------------------------------------ namespace System.Text.RegularExpressions { public partial class Capture { internal Capture() { } public int Index { get { throw null; } } public int Length { get { throw null; } } public string Value { get { throw null; } } public System.ReadOnlySpan<char> ValueSpan { get { throw null; } } public override string ToString() { throw null; } } public partial class CaptureCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Capture>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList { internal CaptureCollection() { } public int Count { get { throw null; } } public bool IsReadOnly { get { throw null; } } public bool IsSynchronized { get { throw null; } } public System.Text.RegularExpressions.Capture this[int i] { get { throw null; } } public object SyncRoot { get { throw null; } } System.Text.RegularExpressions.Capture System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.this[int index] { get { throw null; } set { } } bool System.Collections.IList.IsFixedSize { get { throw null; } } object? System.Collections.IList.this[int index] { get { throw null; } set { } } public void CopyTo(System.Array array, int arrayIndex) { } public void CopyTo(System.Text.RegularExpressions.Capture[] array, int arrayIndex) { } public System.Collections.IEnumerator GetEnumerator() { throw null; } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Add(System.Text.RegularExpressions.Capture item) { } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Clear() { } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Contains(System.Text.RegularExpressions.Capture item) { throw null; } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Remove(System.Text.RegularExpressions.Capture item) { throw null; } System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Capture> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Capture>.GetEnumerator() { throw null; } int System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.IndexOf(System.Text.RegularExpressions.Capture item) { throw null; } void System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.Insert(int index, System.Text.RegularExpressions.Capture item) { } void System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.RemoveAt(int index) { } int System.Collections.IList.Add(object? value) { throw null; } void System.Collections.IList.Clear() { } bool System.Collections.IList.Contains(object? value) { throw null; } int System.Collections.IList.IndexOf(object? value) { throw null; } void System.Collections.IList.Insert(int index, object? value) { } void System.Collections.IList.Remove(object? value) { } void System.Collections.IList.RemoveAt(int index) { } } public partial class Group : System.Text.RegularExpressions.Capture { internal Group() { } public System.Text.RegularExpressions.CaptureCollection Captures { get { throw null; } } public string Name { get { throw null; } } public bool Success { get { throw null; } } public static System.Text.RegularExpressions.Group Synchronized(System.Text.RegularExpressions.Group inner) { throw null; } } public partial class GroupCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, System.Text.RegularExpressions.Group>>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group>, System.Collections.Generic.IList<System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<string, System.Text.RegularExpressions.Group>>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyDictionary<string, System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Group>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList { internal GroupCollection() { } public int Count { get { throw null; } } public bool IsReadOnly { get { throw null; } } public bool IsSynchronized { get { throw null; } } public System.Text.RegularExpressions.Group this[int groupnum] { get { throw null; } } public System.Text.RegularExpressions.Group this[string groupname] { get { throw null; } } public System.Collections.Generic.IEnumerable<string> Keys { get { throw null; } } public object SyncRoot { get { throw null; } } System.Text.RegularExpressions.Group System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.this[int index] { get { throw null; } set { } } bool System.Collections.IList.IsFixedSize { get { throw null; } } object? System.Collections.IList.this[int index] { get { throw null; } set { } } public System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group> Values { get { throw null; } } public bool ContainsKey(string key) { throw null; } public void CopyTo(System.Array array, int arrayIndex) { } public void CopyTo(System.Text.RegularExpressions.Group[] array, int arrayIndex) { } public System.Collections.IEnumerator GetEnumerator() { throw null; } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Add(System.Text.RegularExpressions.Group item) { } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Clear() { } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Contains(System.Text.RegularExpressions.Group item) { throw null; } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Remove(System.Text.RegularExpressions.Group item) { throw null; } System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, System.Text.RegularExpressions.Group>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, System.Text.RegularExpressions.Group>>.GetEnumerator() { throw null; } System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Group> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group>.GetEnumerator() { throw null; } int System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.IndexOf(System.Text.RegularExpressions.Group item) { throw null; } void System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.Insert(int index, System.Text.RegularExpressions.Group item) { } void System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.RemoveAt(int index) { } int System.Collections.IList.Add(object? value) { throw null; } void System.Collections.IList.Clear() { } bool System.Collections.IList.Contains(object? value) { throw null; } int System.Collections.IList.IndexOf(object? value) { throw null; } void System.Collections.IList.Insert(int index, object? value) { } void System.Collections.IList.Remove(object? value) { } void System.Collections.IList.RemoveAt(int index) { } public bool TryGetValue(string key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Text.RegularExpressions.Group? value) { throw null; } } public partial class Match : System.Text.RegularExpressions.Group { internal Match() { } public static System.Text.RegularExpressions.Match Empty { get { throw null; } } public virtual System.Text.RegularExpressions.GroupCollection Groups { get { throw null; } } public System.Text.RegularExpressions.Match NextMatch() { throw null; } public virtual string Result(string replacement) { throw null; } public static System.Text.RegularExpressions.Match Synchronized(System.Text.RegularExpressions.Match inner) { throw null; } } public partial class MatchCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>, System.Collections.Generic.IList<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Match>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList { internal MatchCollection() { } public int Count { get { throw null; } } public bool IsReadOnly { get { throw null; } } public bool IsSynchronized { get { throw null; } } public virtual System.Text.RegularExpressions.Match this[int i] { get { throw null; } } public object SyncRoot { get { throw null; } } System.Text.RegularExpressions.Match System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.this[int index] { get { throw null; } set { } } bool System.Collections.IList.IsFixedSize { get { throw null; } } object? System.Collections.IList.this[int index] { get { throw null; } set { } } public void CopyTo(System.Array array, int arrayIndex) { } public void CopyTo(System.Text.RegularExpressions.Match[] array, int arrayIndex) { } public System.Collections.IEnumerator GetEnumerator() { throw null; } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Add(System.Text.RegularExpressions.Match item) { } void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Clear() { } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Contains(System.Text.RegularExpressions.Match item) { throw null; } bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Remove(System.Text.RegularExpressions.Match item) { throw null; } System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Match> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>.GetEnumerator() { throw null; } int System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.IndexOf(System.Text.RegularExpressions.Match item) { throw null; } void System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.Insert(int index, System.Text.RegularExpressions.Match item) { } void System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.RemoveAt(int index) { } int System.Collections.IList.Add(object? value) { throw null; } void System.Collections.IList.Clear() { } bool System.Collections.IList.Contains(object? value) { throw null; } int System.Collections.IList.IndexOf(object? value) { throw null; } void System.Collections.IList.Insert(int index, object? value) { } void System.Collections.IList.Remove(object? value) { } void System.Collections.IList.RemoveAt(int index) { } } public delegate string MatchEvaluator(System.Text.RegularExpressions.Match match); public partial class Regex : System.Runtime.Serialization.ISerializable { protected internal System.Collections.Hashtable? capnames; protected internal System.Collections.Hashtable? caps; protected internal int capsize; protected internal string[]? capslist; protected internal System.Text.RegularExpressions.RegexRunnerFactory? factory; public static readonly System.TimeSpan InfiniteMatchTimeout; protected internal System.TimeSpan internalMatchTimeout; protected internal string? pattern; protected internal System.Text.RegularExpressions.RegexOptions roptions; protected Regex() { } protected Regex(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public Regex([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { } public Regex([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { } public Regex([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { } public static int CacheSize { get { throw null; } set { } } [System.CLSCompliantAttribute(false)] [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] protected System.Collections.IDictionary? CapNames { get { throw null; } set { } } [System.CLSCompliantAttribute(false)] [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] protected System.Collections.IDictionary? Caps { get { throw null; } set { } } public System.TimeSpan MatchTimeout { get { throw null; } } public System.Text.RegularExpressions.RegexOptions Options { get { throw null; } } public bool RightToLeft { get { throw null; } } [System.ObsoleteAttribute("Regex.CompileToAssembly is obsolete and not supported. Use the RegexGeneratorAttribute with the regular expression source generator instead.", DiagnosticId = "SYSLIB0036", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public static void CompileToAssembly(System.Text.RegularExpressions.RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname) { } [System.ObsoleteAttribute("Regex.CompileToAssembly is obsolete and not supported. Use the RegexGeneratorAttribute with the regular expression source generator instead.", DiagnosticId = "SYSLIB0036", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public static void CompileToAssembly(System.Text.RegularExpressions.RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname, System.Reflection.Emit.CustomAttributeBuilder[]? attributes) { } [System.ObsoleteAttribute("Regex.CompileToAssembly is obsolete and not supported. Use the RegexGeneratorAttribute with the regular expression source generator instead.", DiagnosticId = "SYSLIB0036", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public static void CompileToAssembly(System.Text.RegularExpressions.RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname, System.Reflection.Emit.CustomAttributeBuilder[]? attributes, string? resourceFile) { } public int Count(string input) { throw null; } public static int Count(string input, [System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static int Count(string input, [System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static int Count(string input, [System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public static string Escape(string str) { throw null; } public string[] GetGroupNames() { throw null; } public int[] GetGroupNumbers() { throw null; } public string GroupNameFromNumber(int i) { throw null; } public int GroupNumberFromName(string name) { throw null; } protected void InitializeReferences() { } public bool IsMatch(System.ReadOnlySpan<char> input) { throw null; } public static bool IsMatch(System.ReadOnlySpan<char> input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static bool IsMatch(System.ReadOnlySpan<char> input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static bool IsMatch(System.ReadOnlySpan<char> input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public bool IsMatch(string input) { throw null; } public bool IsMatch(string input, int startat) { throw null; } public static bool IsMatch(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static bool IsMatch(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static bool IsMatch(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public System.Text.RegularExpressions.Match Match(string input) { throw null; } public System.Text.RegularExpressions.Match Match(string input, int startat) { throw null; } public System.Text.RegularExpressions.Match Match(string input, int beginning, int length) { throw null; } public static System.Text.RegularExpressions.Match Match(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static System.Text.RegularExpressions.Match Match(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static System.Text.RegularExpressions.Match Match(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public System.Text.RegularExpressions.MatchCollection Matches(string input) { throw null; } public System.Text.RegularExpressions.MatchCollection Matches(string input, int startat) { throw null; } public static System.Text.RegularExpressions.MatchCollection Matches(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static System.Text.RegularExpressions.MatchCollection Matches(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static System.Text.RegularExpressions.MatchCollection Matches(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public string Replace(string input, string replacement) { throw null; } public string Replace(string input, string replacement, int count) { throw null; } public string Replace(string input, string replacement, int count, int startat) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern, string replacement) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, string replacement, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, string replacement, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static string Replace(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator) { throw null; } public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count) { throw null; } public string Replace(string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count, int startat) { throw null; } public string[] Split(string input) { throw null; } public string[] Split(string input, int count) { throw null; } public string[] Split(string input, int count, int startat) { throw null; } public static string[] Split(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { throw null; } public static string[] Split(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { throw null; } public static string[] Split(string input, [System.Diagnostics.CodeAnalysis.StringSyntaxAttribute(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { throw null; } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { } public override string ToString() { throw null; } public static string Unescape(string str) { throw null; } protected bool UseOptionC() { throw null; } protected internal bool UseOptionR() { throw null; } protected internal static void ValidateMatchTimeout(System.TimeSpan matchTimeout) { } } [System.ObsoleteAttribute("Regex.CompileToAssembly is obsolete and not supported. Use the RegexGeneratorAttribute with the regular expression source generator instead.", DiagnosticId = "SYSLIB0036", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public partial class RegexCompilationInfo { public RegexCompilationInfo(string pattern, System.Text.RegularExpressions.RegexOptions options, string name, string fullnamespace, bool ispublic) { } public RegexCompilationInfo(string pattern, System.Text.RegularExpressions.RegexOptions options, string name, string fullnamespace, bool ispublic, System.TimeSpan matchTimeout) { } public bool IsPublic { get { throw null; } set { } } public System.TimeSpan MatchTimeout { get { throw null; } set { } } public string Name { get { throw null; } set { } } public string Namespace { get { throw null; } set { } } public System.Text.RegularExpressions.RegexOptions Options { get { throw null; } set { } } public string Pattern { get { throw null; } set { } } } [System.AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] public sealed partial class RegexGeneratorAttribute : System.Attribute { public RegexGeneratorAttribute([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex)] string pattern) { } public RegexGeneratorAttribute([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options) { } public RegexGeneratorAttribute([System.Diagnostics.CodeAnalysis.StringSyntax(System.Diagnostics.CodeAnalysis.StringSyntaxAttribute.Regex, "options")] string pattern, System.Text.RegularExpressions.RegexOptions options, int matchTimeoutMilliseconds) { } public string Pattern { get; } public System.Text.RegularExpressions.RegexOptions Options { get; } public int MatchTimeoutMilliseconds { get; } } public partial class RegexMatchTimeoutException : System.TimeoutException, System.Runtime.Serialization.ISerializable { public RegexMatchTimeoutException() { } protected RegexMatchTimeoutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public RegexMatchTimeoutException(string message) { } public RegexMatchTimeoutException(string message, System.Exception inner) { } public RegexMatchTimeoutException(string regexInput, string regexPattern, System.TimeSpan matchTimeout) { } public string Input { get { throw null; } } public System.TimeSpan MatchTimeout { get { throw null; } } public string Pattern { get { throw null; } } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } [System.FlagsAttribute] public enum RegexOptions { None = 0, IgnoreCase = 1, Multiline = 2, ExplicitCapture = 4, Compiled = 8, Singleline = 16, IgnorePatternWhitespace = 32, RightToLeft = 64, ECMAScript = 256, CultureInvariant = 512, NonBacktracking = 1024, } public enum RegexParseError { Unknown = 0, AlternationHasTooManyConditions = 1, AlternationHasMalformedCondition = 2, InvalidUnicodePropertyEscape = 3, MalformedUnicodePropertyEscape = 4, UnrecognizedEscape = 5, UnrecognizedControlCharacter = 6, MissingControlCharacter = 7, InsufficientOrInvalidHexDigits = 8, QuantifierOrCaptureGroupOutOfRange = 9, UndefinedNamedReference = 10, UndefinedNumberedReference = 11, MalformedNamedReference = 12, UnescapedEndingBackslash = 13, UnterminatedComment = 14, InvalidGroupingConstruct = 15, AlternationHasNamedCapture = 16, AlternationHasComment = 17, AlternationHasMalformedReference = 18, AlternationHasUndefinedReference = 19, CaptureGroupNameInvalid = 20, CaptureGroupOfZero = 21, UnterminatedBracket = 22, ExclusionGroupNotLast = 23, ReversedCharacterRange = 24, ShorthandClassInCharacterRange = 25, InsufficientClosingParentheses = 26, ReversedQuantifierRange = 27, NestedQuantifiersNotParenthesized = 28, QuantifierAfterNothing = 29, InsufficientOpeningParentheses = 30, UnrecognizedUnicodeProperty = 31, } public sealed partial class RegexParseException : System.ArgumentException { private RegexParseException() { } public System.Text.RegularExpressions.RegexParseError Error { get { throw null; } } public int Offset { get { throw null; } } public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public abstract partial class RegexRunner { protected internal int[]? runcrawl; protected internal int runcrawlpos; protected internal System.Text.RegularExpressions.Match? runmatch; protected internal System.Text.RegularExpressions.Regex? runregex; protected internal int[]? runstack; protected internal int runstackpos; protected internal string? runtext; protected internal int runtextbeg; protected internal int runtextend; protected internal int runtextpos; protected internal int runtextstart; protected internal int[]? runtrack; protected internal int runtrackcount; protected internal int runtrackpos; protected internal RegexRunner() { } protected void Capture(int capnum, int start, int end) { } protected static bool CharInClass(char ch, string charClass) { throw null; } protected static bool CharInSet(char ch, string @set, string category) { throw null; } protected void CheckTimeout() { } protected void Crawl(int i) { } protected int Crawlpos() { throw null; } protected void DoubleCrawl() { } protected void DoubleStack() { } protected void DoubleTrack() { } protected void EnsureStorage() { } protected virtual bool FindFirstChar() { throw null; } protected virtual void Go() { throw null; } protected virtual void InitTrackCount() { throw null; } protected bool IsBoundary(int index, int startpos, int endpos) { throw null; } protected bool IsECMABoundary(int index, int startpos, int endpos) { throw null; } protected bool IsMatched(int cap) { throw null; } protected int MatchIndex(int cap) { throw null; } protected int MatchLength(int cap) { throw null; } protected int Popcrawl() { throw null; } protected internal System.Text.RegularExpressions.Match? Scan(System.Text.RegularExpressions.Regex regex, string text, int textbeg, int textend, int textstart, int prevlen, bool quick) { throw null; } protected internal System.Text.RegularExpressions.Match? Scan(System.Text.RegularExpressions.Regex regex, string text, int textbeg, int textend, int textstart, int prevlen, bool quick, System.TimeSpan timeout) { throw null; } protected internal virtual void Scan(System.ReadOnlySpan<char> text) { throw null; } protected void TransferCapture(int capnum, int uncapnum, int start, int end) { } protected void Uncapture() { } } public abstract partial class RegexRunnerFactory { protected RegexRunnerFactory() { } protected internal abstract System.Text.RegularExpressions.RegexRunner CreateInstance(); } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/JIT/Methodical/eh/nested/general/rethrowincatchnestedinfinally.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Re-throw an exception in catch nested in finally which is nested in try with catch and finally. // NDPWhidbey 10959 using System; namespace Test { class Class1 { private static TestUtil.TestLog testLog; static Class1() { // Create test writer object to hold expected output System.IO.StringWriter expectedOut = new System.IO.StringWriter(); // Write expected output to string writer object expectedOut.WriteLine(" try"); expectedOut.WriteLine("\t try"); expectedOut.WriteLine("\t finally"); expectedOut.WriteLine("\t\t try \t [throwing an exception here]"); expectedOut.WriteLine("\t\t catch \t [re-throwing the same exception]"); expectedOut.WriteLine(" catch"); expectedOut.WriteLine(" finally"); expectedOut.WriteLine(" inside loop i = 0"); expectedOut.WriteLine(" inside loop i = 1"); expectedOut.WriteLine(" inside loop i = 2"); expectedOut.WriteLine(" inside loop i = 3"); // Create and initialize test log object testLog = new TestUtil.TestLog(expectedOut); } static public int Main() { //Start recording testLog.StartRecording(); try { Console.WriteLine(" try"); try { Console.WriteLine("\t try"); } finally { Console.WriteLine("\t finally"); try { Console.WriteLine("\t\t try \t [throwing an exception here]"); int x = 0; int y = 5 / x; } catch (System.Exception) { Console.WriteLine("\t\t catch \t [re-throwing the same exception]"); throw; } } } catch (System.Exception) { Console.WriteLine(" catch"); } finally { Console.WriteLine(" finally"); } for (int i = 0; i < 4; ++i) { Console.WriteLine(" inside loop i = " + i); } // stop recoding testLog.StopRecording(); return testLog.VerifyOutput(); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Re-throw an exception in catch nested in finally which is nested in try with catch and finally. // NDPWhidbey 10959 using System; namespace Test { class Class1 { private static TestUtil.TestLog testLog; static Class1() { // Create test writer object to hold expected output System.IO.StringWriter expectedOut = new System.IO.StringWriter(); // Write expected output to string writer object expectedOut.WriteLine(" try"); expectedOut.WriteLine("\t try"); expectedOut.WriteLine("\t finally"); expectedOut.WriteLine("\t\t try \t [throwing an exception here]"); expectedOut.WriteLine("\t\t catch \t [re-throwing the same exception]"); expectedOut.WriteLine(" catch"); expectedOut.WriteLine(" finally"); expectedOut.WriteLine(" inside loop i = 0"); expectedOut.WriteLine(" inside loop i = 1"); expectedOut.WriteLine(" inside loop i = 2"); expectedOut.WriteLine(" inside loop i = 3"); // Create and initialize test log object testLog = new TestUtil.TestLog(expectedOut); } static public int Main() { //Start recording testLog.StartRecording(); try { Console.WriteLine(" try"); try { Console.WriteLine("\t try"); } finally { Console.WriteLine("\t finally"); try { Console.WriteLine("\t\t try \t [throwing an exception here]"); int x = 0; int y = 5 / x; } catch (System.Exception) { Console.WriteLine("\t\t catch \t [re-throwing the same exception]"); throw; } } } catch (System.Exception) { Console.WriteLine(" catch"); } finally { Console.WriteLine(" finally"); } for (int i = 0; i < 4; ++i) { Console.WriteLine(" inside loop i = " + i); } // stop recoding testLog.StopRecording(); return testLog.VerifyOutput(); } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/reflection/Modifiers/modifiersdata.il
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib { } .assembly modifiersdata { } .class public BaseClass { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } .method public hidebysig virtual newslot instance int32 Override(int32 modopt (FooModifier)) { ldstr "In int32 BaseClass::Override(int32 modopt (FooModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.0 ret } .method public hidebysig virtual newslot instance int32 Override(int32 modopt (BarModifier)) { ldstr "In int32 BaseClass::Override(int32 modopt (BarModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.1 ret } .method public hidebysig virtual newslot instance int32 Override(int32 modreq (FooModifier)) { ldstr "In int32 BaseClass::Override(int32 modreq (FooModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.2 ret } .method public hidebysig virtual newslot instance int32 Override(int32) { ldstr "In int32 BaseClass::Override(int32)" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.3 ret } .method public hidebysig virtual newslot instance int32 modopt (FooModifier) Override(int32) { ldstr "In int32 modopt (FooModifier) BaseClass::Override(int32)" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.4 ret } .method public hidebysig virtual newslot instance int32 Override(int32 modopt (FooModifier)[]) { ldstr "In int32 BaseClass::Override(int32 modopt (FooModifier)[])" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.5 ret } .method public hidebysig virtual newslot instance int32 Override(int32 modopt (BarModifier)[]) { ldstr "In int32 BaseClass::Override(int32 modopt (BarModifier)[])" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.6 ret } } .class public DerivedClass extends BaseClass { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void BaseClass::.ctor() ret } .method public hidebysig virtual instance int32 Override(int32 modopt (FooModifier)) { ldstr "In int32 DerivedClass::Override(int32 modopt (FooModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 100 ret } .method public hidebysig virtual instance int32 Override(int32 modopt (BarModifier)) { ldstr "In int32 DerivedClass::Override(int32 modopt (BarModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 101 ret } .method public hidebysig virtual instance int32 Override(int32 modreq (FooModifier)) { ldstr "In int32 DerivedClass::Override(int32 modreq (FooModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 102 ret } .method public hidebysig virtual instance int32 Override(int32) { ldstr "In int32 DerivedClass::Override(int32)" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 103 ret } .method public hidebysig virtual instance int32 modopt (FooModifier) Override(int32) { ldstr "In int32 modopt (FooModifier) DerivedClass::Override(int32)" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 104 ret } .method public hidebysig virtual instance int32 Override(int32 modopt (FooModifier)[]) { ldstr "In int32 DerivedClass::Override(int32 modopt (FooModifier)[])" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 105 ret } .method public hidebysig virtual instance int32 Override(int32 modopt (BarModifier)[]) { ldstr "In int32 DerivedClass::Override(int32 modopt (BarModifier)[])" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 106 ret } } .class public GenericClass`1<T> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class public value sequential GenericStruct`1<T> { .size 1 } .class public Factory { .method public static hidebysig object TryAllocWithModifiedArray() { newobj instance void class GenericClass`1<int32 modopt (FooModifier)[]>::.ctor() ret } .method public static hidebysig object TryBoxWithModifiedPointer() { .locals init (valuetype GenericStruct`1<int32 modreq (BarModifier)*[]>) ldloc 0 box valuetype GenericStruct`1<int32 modreq (BarModifier)*[]> ret } } .class public FooModifier { } .class public BarModifier { }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. .assembly extern mscorlib { } .assembly modifiersdata { } .class public BaseClass { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } .method public hidebysig virtual newslot instance int32 Override(int32 modopt (FooModifier)) { ldstr "In int32 BaseClass::Override(int32 modopt (FooModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.0 ret } .method public hidebysig virtual newslot instance int32 Override(int32 modopt (BarModifier)) { ldstr "In int32 BaseClass::Override(int32 modopt (BarModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.1 ret } .method public hidebysig virtual newslot instance int32 Override(int32 modreq (FooModifier)) { ldstr "In int32 BaseClass::Override(int32 modreq (FooModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.2 ret } .method public hidebysig virtual newslot instance int32 Override(int32) { ldstr "In int32 BaseClass::Override(int32)" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.3 ret } .method public hidebysig virtual newslot instance int32 modopt (FooModifier) Override(int32) { ldstr "In int32 modopt (FooModifier) BaseClass::Override(int32)" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.4 ret } .method public hidebysig virtual newslot instance int32 Override(int32 modopt (FooModifier)[]) { ldstr "In int32 BaseClass::Override(int32 modopt (FooModifier)[])" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.5 ret } .method public hidebysig virtual newslot instance int32 Override(int32 modopt (BarModifier)[]) { ldstr "In int32 BaseClass::Override(int32 modopt (BarModifier)[])" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4.6 ret } } .class public DerivedClass extends BaseClass { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void BaseClass::.ctor() ret } .method public hidebysig virtual instance int32 Override(int32 modopt (FooModifier)) { ldstr "In int32 DerivedClass::Override(int32 modopt (FooModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 100 ret } .method public hidebysig virtual instance int32 Override(int32 modopt (BarModifier)) { ldstr "In int32 DerivedClass::Override(int32 modopt (BarModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 101 ret } .method public hidebysig virtual instance int32 Override(int32 modreq (FooModifier)) { ldstr "In int32 DerivedClass::Override(int32 modreq (FooModifier))" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 102 ret } .method public hidebysig virtual instance int32 Override(int32) { ldstr "In int32 DerivedClass::Override(int32)" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 103 ret } .method public hidebysig virtual instance int32 modopt (FooModifier) Override(int32) { ldstr "In int32 modopt (FooModifier) DerivedClass::Override(int32)" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 104 ret } .method public hidebysig virtual instance int32 Override(int32 modopt (FooModifier)[]) { ldstr "In int32 DerivedClass::Override(int32 modopt (FooModifier)[])" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 105 ret } .method public hidebysig virtual instance int32 Override(int32 modopt (BarModifier)[]) { ldstr "In int32 DerivedClass::Override(int32 modopt (BarModifier)[])" call void class [mscorlib]System.Console::WriteLine(string) ldc.i4 106 ret } } .class public GenericClass`1<T> { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } } .class public value sequential GenericStruct`1<T> { .size 1 } .class public Factory { .method public static hidebysig object TryAllocWithModifiedArray() { newobj instance void class GenericClass`1<int32 modopt (FooModifier)[]>::.ctor() ret } .method public static hidebysig object TryBoxWithModifiedPointer() { .locals init (valuetype GenericStruct`1<int32 modreq (BarModifier)*[]>) ldloc 0 box valuetype GenericStruct`1<int32 modreq (BarModifier)*[]> ret } } .class public FooModifier { } .class public BarModifier { }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/libraries/System.Security.Cryptography.X509Certificates/tests/RevocationTests/AiaTests.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Linq; using System.Security.Cryptography.X509Certificates.Tests.Common; using Test.Cryptography; using Xunit; namespace System.Security.Cryptography.X509Certificates.Tests.RevocationTests { [ActiveIssue("https://github.com/dotnet/runtime/issues/57506", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsMariner))] [SkipOnPlatform(TestPlatforms.Android, "Android does not support AIA fetching")] public static class AiaTests { [Fact] public static void EmptyAiaResponseIsIgnored() { CertificateAuthority.BuildPrivatePki( PkiOptions.AllRevocation, out RevocationResponder responder, out CertificateAuthority root, out CertificateAuthority[] intermediates, out X509Certificate2 endEntity, intermediateAuthorityCount: 2, pkiOptionsInSubject: false, testName: nameof(EmptyAiaResponseIsIgnored)); using (responder) using (root) using (CertificateAuthority intermediate1 = intermediates[0]) using (CertificateAuthority intermediate2 = intermediates[1]) using (endEntity) using (X509Certificate2 intermediate2Cert = intermediate2.CloneIssuerCert()) { responder.RespondEmpty = true; RetryHelper.Execute(() => { using (ChainHolder holder = new ChainHolder()) { X509Chain chain = holder.Chain; chain.ChainPolicy.ExtraStore.Add(intermediate2Cert); chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust; chain.ChainPolicy.VerificationTime = endEntity.NotBefore.AddMinutes(1); chain.ChainPolicy.UrlRetrievalTimeout = DynamicRevocationTests.s_urlRetrievalLimit; chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; Assert.False(chain.Build(endEntity)); X509ChainStatusFlags chainFlags = chain.AllStatusFlags(); Assert.True(chainFlags.HasFlag(X509ChainStatusFlags.PartialChain), $"expected partial chain flags, got {chainFlags}"); Assert.Equal(2, chain.ChainElements.Count); } }); } } [Fact] [SkipOnPlatform(PlatformSupport.MobileAppleCrypto, "CA store is not available")] public static void DisableAiaOptionWorks() { CertificateAuthority.BuildPrivatePki( PkiOptions.AllRevocation, out RevocationResponder responder, out CertificateAuthority root, out CertificateAuthority intermediate, out X509Certificate2 endEntity, pkiOptionsInSubject: false, testName: nameof(DisableAiaOptionWorks)); using (responder) using (root) using (intermediate) using (endEntity) using (X509Certificate2 rootCert = root.CloneIssuerCert()) using (X509Certificate2 intermediateCert = intermediate.CloneIssuerCert()) { RetryHelper.Execute(() => { using (ChainHolder holder = new ChainHolder()) using (var cuCaStore = new X509Store(StoreName.CertificateAuthority, StoreLocation.CurrentUser)) { cuCaStore.Open(OpenFlags.ReadWrite); X509Chain chain = holder.Chain; // macOS combines revocation and AIA fetching in to a single flag. Both need to be disabled // to prevent AIA fetches. if (PlatformDetection.IsOSX) { chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; } chain.ChainPolicy.DisableCertificateDownloads = true; chain.ChainPolicy.CustomTrustStore.Add(rootCert); chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust; chain.ChainPolicy.VerificationTime = endEntity.NotBefore.AddMinutes(1); chain.ChainPolicy.UrlRetrievalTimeout = DynamicRevocationTests.s_urlRetrievalLimit; Assert.False(chain.Build(endEntity), "Chain build with no intermediate, AIA disabled"); // If a previous run of this test leaves contamination in the CU\CA store on Windows // the Windows chain engine will match the bad issuer and report NotSignatureValid instead // of PartialChain. X509ChainStatusFlags chainFlags = chain.AllStatusFlags(); if (chainFlags.HasFlag(X509ChainStatusFlags.NotSignatureValid)) { Assert.Equal(3, chain.ChainElements.Count); foreach (X509Certificate2 storeCert in cuCaStore.Certificates) { if (storeCert.Subject.Equals(intermediateCert.Subject)) { cuCaStore.Remove(storeCert); } storeCert.Dispose(); } holder.DisposeChainElements(); // Try again, with no caching side effect. Assert.False(chain.Build(endEntity), "Chain build 2 with no intermediate, AIA disabled"); } Assert.Equal(1, chain.ChainElements.Count); Assert.Contains(X509ChainStatusFlags.PartialChain, chain.ChainStatus.Select(s => s.Status)); holder.DisposeChainElements(); chain.ChainPolicy.ExtraStore.Add(intermediateCert); Assert.True(chain.Build(endEntity), "Chain build with intermediate, AIA disabled"); Assert.Equal(3, chain.ChainElements.Count); Assert.Equal(X509ChainStatusFlags.NoError, chain.AllStatusFlags()); holder.DisposeChainElements(); chain.ChainPolicy.DisableCertificateDownloads = false; chain.ChainPolicy.ExtraStore.Clear(); Assert.True(chain.Build(endEntity), "Chain build with no intermediate, AIA enabled"); Assert.Equal(3, chain.ChainElements.Count); Assert.Equal(X509ChainStatusFlags.NoError, chain.AllStatusFlags()); cuCaStore.Remove(intermediateCert); } }); } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Linq; using System.Security.Cryptography.X509Certificates.Tests.Common; using Test.Cryptography; using Xunit; namespace System.Security.Cryptography.X509Certificates.Tests.RevocationTests { [ActiveIssue("https://github.com/dotnet/runtime/issues/57506", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsMariner))] [SkipOnPlatform(TestPlatforms.Android, "Android does not support AIA fetching")] public static class AiaTests { [Fact] public static void EmptyAiaResponseIsIgnored() { CertificateAuthority.BuildPrivatePki( PkiOptions.AllRevocation, out RevocationResponder responder, out CertificateAuthority root, out CertificateAuthority[] intermediates, out X509Certificate2 endEntity, intermediateAuthorityCount: 2, pkiOptionsInSubject: false, testName: nameof(EmptyAiaResponseIsIgnored)); using (responder) using (root) using (CertificateAuthority intermediate1 = intermediates[0]) using (CertificateAuthority intermediate2 = intermediates[1]) using (endEntity) using (X509Certificate2 intermediate2Cert = intermediate2.CloneIssuerCert()) { responder.RespondEmpty = true; RetryHelper.Execute(() => { using (ChainHolder holder = new ChainHolder()) { X509Chain chain = holder.Chain; chain.ChainPolicy.ExtraStore.Add(intermediate2Cert); chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust; chain.ChainPolicy.VerificationTime = endEntity.NotBefore.AddMinutes(1); chain.ChainPolicy.UrlRetrievalTimeout = DynamicRevocationTests.s_urlRetrievalLimit; chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; Assert.False(chain.Build(endEntity)); X509ChainStatusFlags chainFlags = chain.AllStatusFlags(); Assert.True(chainFlags.HasFlag(X509ChainStatusFlags.PartialChain), $"expected partial chain flags, got {chainFlags}"); Assert.Equal(2, chain.ChainElements.Count); } }); } } [Fact] [SkipOnPlatform(PlatformSupport.MobileAppleCrypto, "CA store is not available")] public static void DisableAiaOptionWorks() { CertificateAuthority.BuildPrivatePki( PkiOptions.AllRevocation, out RevocationResponder responder, out CertificateAuthority root, out CertificateAuthority intermediate, out X509Certificate2 endEntity, pkiOptionsInSubject: false, testName: nameof(DisableAiaOptionWorks)); using (responder) using (root) using (intermediate) using (endEntity) using (X509Certificate2 rootCert = root.CloneIssuerCert()) using (X509Certificate2 intermediateCert = intermediate.CloneIssuerCert()) { RetryHelper.Execute(() => { using (ChainHolder holder = new ChainHolder()) using (var cuCaStore = new X509Store(StoreName.CertificateAuthority, StoreLocation.CurrentUser)) { cuCaStore.Open(OpenFlags.ReadWrite); X509Chain chain = holder.Chain; // macOS combines revocation and AIA fetching in to a single flag. Both need to be disabled // to prevent AIA fetches. if (PlatformDetection.IsOSX) { chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; } chain.ChainPolicy.DisableCertificateDownloads = true; chain.ChainPolicy.CustomTrustStore.Add(rootCert); chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust; chain.ChainPolicy.VerificationTime = endEntity.NotBefore.AddMinutes(1); chain.ChainPolicy.UrlRetrievalTimeout = DynamicRevocationTests.s_urlRetrievalLimit; Assert.False(chain.Build(endEntity), "Chain build with no intermediate, AIA disabled"); // If a previous run of this test leaves contamination in the CU\CA store on Windows // the Windows chain engine will match the bad issuer and report NotSignatureValid instead // of PartialChain. X509ChainStatusFlags chainFlags = chain.AllStatusFlags(); if (chainFlags.HasFlag(X509ChainStatusFlags.NotSignatureValid)) { Assert.Equal(3, chain.ChainElements.Count); foreach (X509Certificate2 storeCert in cuCaStore.Certificates) { if (storeCert.Subject.Equals(intermediateCert.Subject)) { cuCaStore.Remove(storeCert); } storeCert.Dispose(); } holder.DisposeChainElements(); // Try again, with no caching side effect. Assert.False(chain.Build(endEntity), "Chain build 2 with no intermediate, AIA disabled"); } Assert.Equal(1, chain.ChainElements.Count); Assert.Contains(X509ChainStatusFlags.PartialChain, chain.ChainStatus.Select(s => s.Status)); holder.DisposeChainElements(); chain.ChainPolicy.ExtraStore.Add(intermediateCert); Assert.True(chain.Build(endEntity), "Chain build with intermediate, AIA disabled"); Assert.Equal(3, chain.ChainElements.Count); Assert.Equal(X509ChainStatusFlags.NoError, chain.AllStatusFlags()); holder.DisposeChainElements(); chain.ChainPolicy.DisableCertificateDownloads = false; chain.ChainPolicy.ExtraStore.Clear(); Assert.True(chain.Build(endEntity), "Chain build with no intermediate, AIA enabled"); Assert.Equal(3, chain.ChainElements.Count); Assert.Equal(X509ChainStatusFlags.NoError, chain.AllStatusFlags()); cuCaStore.Remove(intermediateCert); } }); } } } }
-1
dotnet/runtime
66,290
Fix workaround for static virtual methods
The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
MichalStrehovsky
2022-03-07T11:38:33Z
2022-03-07T15:58:30Z
29e6159623292fe882a2df7ae4bdfa2bd0d1e2ce
154386d63b3ba55ce3251fa4caf3dfa89279d982
Fix workaround for static virtual methods. The workaround for reflection invoking static virtual methods wasn't working around well enough. Fixes #66028. The repro case also hit a scanning failure due to scanner not scanning a throw helper. Those are more of asserts, so add them to the collection of throw helpers to ignore.
./src/tests/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b353858/b353858.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).il" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>PdbOnly</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).il" /> </ItemGroup> </Project>
-1