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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Text.Encoding/tests/Fallback/EncoderReplacementFallbackTests.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 Xunit; namespace System.Text.Tests { public class EncoderReplacementFallbackTests { [Fact] public void Ctor_Empty() { EncoderReplacementFallback exception = new EncoderReplacementFallback(); Assert.Equal(1, exception.MaxCharCount); Assert.Equal("?", exception.DefaultString); Assert.Equal("?".GetHashCode(), exception.GetHashCode()); } [Theory] [InlineData("")] [InlineData("a")] [InlineData("abc")] [InlineData("\uD800\uDC00")] public void Ctor_String(string replacement) { EncoderReplacementFallback fallback = new EncoderReplacementFallback(replacement); Assert.Equal(replacement.Length, fallback.MaxCharCount); Assert.Equal(replacement, fallback.DefaultString); Assert.Equal(replacement.GetHashCode(), fallback.GetHashCode()); } [Fact] public void Ctor_Invalid() { AssertExtensions.Throws<ArgumentNullException>("replacement", () => new EncoderReplacementFallback(null)); // Invalid surrogate pair AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uD800")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uD800a")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uDC00")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("a\uDC00")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uDC00\uDC00")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uD800\uD800")); } public static IEnumerable<object[]> Equals_TestData() { yield return new object[] { new EncoderReplacementFallback(), new EncoderReplacementFallback(), true }; yield return new object[] { new EncoderReplacementFallback(), new EncoderReplacementFallback("?"), true }; yield return new object[] { new EncoderReplacementFallback("abc"), new EncoderReplacementFallback("abc"), true }; yield return new object[] { new EncoderReplacementFallback("abc"), new EncoderReplacementFallback("def"), false }; yield return new object[] { new EncoderReplacementFallback(), new object(), false }; yield return new object[] { new EncoderReplacementFallback(), null, false }; } [Theory] [MemberData(nameof(Equals_TestData))] public void EqualsTest(EncoderReplacementFallback fallback, object value, bool expected) { Assert.Equal(expected, fallback.Equals(value)); } [Fact] public void CreateFallbackBuffer() { EncoderFallbackBuffer buffer = new EncoderReplacementFallback().CreateFallbackBuffer(); Assert.Equal((char)0, buffer.GetNextChar()); Assert.False(buffer.MovePrevious()); Assert.Equal(0, buffer.Remaining); } [Theory] [InlineData("", 'a', false)] [InlineData("?", 'a', true)] public void CreateFallbackBuffer_Fallback_Char(string replacement, char charUnknown, bool expected) { EncoderFallbackBuffer buffer = new EncoderReplacementFallback(replacement).CreateFallbackBuffer(); Assert.Equal(expected, buffer.Fallback(charUnknown, 0)); } [Theory] [InlineData("?")] [InlineData("\uD800\uDC00")] public void CreateFallbackBuffer_MultipleFallback_ThrowsArgumentException(string replacement) { EncoderFallbackBuffer buffer = new EncoderReplacementFallback(replacement).CreateFallbackBuffer(); buffer.Fallback('a', 0); AssertExtensions.Throws<ArgumentException>("chars", () => buffer.Fallback('a', 0)); AssertExtensions.Throws<ArgumentException>("chars", () => buffer.Fallback('\uD800', '\uDC00', 0)); } [Theory] [InlineData("", false)] [InlineData("a", true)] public void CreateFallbackBuffer_Fallback_Char_Char(string replacement, bool expected) { EncoderFallbackBuffer buffer = new EncoderReplacementFallback(replacement).CreateFallbackBuffer(); Assert.Equal(expected, buffer.Fallback('\uD800', '\uDC00', 0)); } [Fact] public void CreateFallbackBuffer_Fallback_InvalidSurrogateChars_ThrowsArgumentOutOfRangeException() { EncoderFallbackBuffer buffer = new EncoderReplacementFallback().CreateFallbackBuffer(); AssertExtensions.Throws<ArgumentOutOfRangeException>("charUnknownHigh", () => buffer.Fallback('a', '\uDC00', 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charUnknownLow", () => buffer.Fallback('\uD800', 'a', 0)); } } }
// 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 Xunit; namespace System.Text.Tests { public class EncoderReplacementFallbackTests { [Fact] public void Ctor_Empty() { EncoderReplacementFallback exception = new EncoderReplacementFallback(); Assert.Equal(1, exception.MaxCharCount); Assert.Equal("?", exception.DefaultString); Assert.Equal("?".GetHashCode(), exception.GetHashCode()); } [Theory] [InlineData("")] [InlineData("a")] [InlineData("abc")] [InlineData("\uD800\uDC00")] public void Ctor_String(string replacement) { EncoderReplacementFallback fallback = new EncoderReplacementFallback(replacement); Assert.Equal(replacement.Length, fallback.MaxCharCount); Assert.Equal(replacement, fallback.DefaultString); Assert.Equal(replacement.GetHashCode(), fallback.GetHashCode()); } [Fact] public void Ctor_Invalid() { AssertExtensions.Throws<ArgumentNullException>("replacement", () => new EncoderReplacementFallback(null)); // Invalid surrogate pair AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uD800")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uD800a")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uDC00")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("a\uDC00")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uDC00\uDC00")); AssertExtensions.Throws<ArgumentException>("replacement", () => new EncoderReplacementFallback("\uD800\uD800")); } public static IEnumerable<object[]> Equals_TestData() { yield return new object[] { new EncoderReplacementFallback(), new EncoderReplacementFallback(), true }; yield return new object[] { new EncoderReplacementFallback(), new EncoderReplacementFallback("?"), true }; yield return new object[] { new EncoderReplacementFallback("abc"), new EncoderReplacementFallback("abc"), true }; yield return new object[] { new EncoderReplacementFallback("abc"), new EncoderReplacementFallback("def"), false }; yield return new object[] { new EncoderReplacementFallback(), new object(), false }; yield return new object[] { new EncoderReplacementFallback(), null, false }; } [Theory] [MemberData(nameof(Equals_TestData))] public void EqualsTest(EncoderReplacementFallback fallback, object value, bool expected) { Assert.Equal(expected, fallback.Equals(value)); } [Fact] public void CreateFallbackBuffer() { EncoderFallbackBuffer buffer = new EncoderReplacementFallback().CreateFallbackBuffer(); Assert.Equal((char)0, buffer.GetNextChar()); Assert.False(buffer.MovePrevious()); Assert.Equal(0, buffer.Remaining); } [Theory] [InlineData("", 'a', false)] [InlineData("?", 'a', true)] public void CreateFallbackBuffer_Fallback_Char(string replacement, char charUnknown, bool expected) { EncoderFallbackBuffer buffer = new EncoderReplacementFallback(replacement).CreateFallbackBuffer(); Assert.Equal(expected, buffer.Fallback(charUnknown, 0)); } [Theory] [InlineData("?")] [InlineData("\uD800\uDC00")] public void CreateFallbackBuffer_MultipleFallback_ThrowsArgumentException(string replacement) { EncoderFallbackBuffer buffer = new EncoderReplacementFallback(replacement).CreateFallbackBuffer(); buffer.Fallback('a', 0); AssertExtensions.Throws<ArgumentException>("chars", () => buffer.Fallback('a', 0)); AssertExtensions.Throws<ArgumentException>("chars", () => buffer.Fallback('\uD800', '\uDC00', 0)); } [Theory] [InlineData("", false)] [InlineData("a", true)] public void CreateFallbackBuffer_Fallback_Char_Char(string replacement, bool expected) { EncoderFallbackBuffer buffer = new EncoderReplacementFallback(replacement).CreateFallbackBuffer(); Assert.Equal(expected, buffer.Fallback('\uD800', '\uDC00', 0)); } [Fact] public void CreateFallbackBuffer_Fallback_InvalidSurrogateChars_ThrowsArgumentOutOfRangeException() { EncoderFallbackBuffer buffer = new EncoderReplacementFallback().CreateFallbackBuffer(); AssertExtensions.Throws<ArgumentOutOfRangeException>("charUnknownHigh", () => buffer.Fallback('a', '\uDC00', 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("charUnknownLow", () => buffer.Fallback('\uD800', 'a', 0)); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Net.WebSockets/tests/WebSocketTestStream.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.Threading; using System.Threading.Tasks; namespace System.Net.WebSockets.Tests { /// <summary> /// A helper stream class that can be used simulate sending / receiving (duplex) data in a websocket. /// </summary> public class WebSocketTestStream : Stream { private readonly SemaphoreSlim _inputLock = new(initialCount: 0); private readonly Queue<Block> _inputQueue = new(); private readonly CancellationTokenSource _disposed = new(); public WebSocketTestStream() { GC.SuppressFinalize(this); Remote = new WebSocketTestStream(this); } private WebSocketTestStream(WebSocketTestStream remote) { GC.SuppressFinalize(this); Remote = remote; } public WebSocketTestStream Remote { get; } /// <summary> /// Returns the number of unread bytes. /// </summary> public int Available { get { int available = 0; lock (_inputQueue) { foreach (Block x in _inputQueue) { available += x.AvailableLength; } } return available; } } public Span<byte> NextAvailableBytes { get { lock (_inputQueue) { if (_inputQueue.TryPeek(out Block block)) { return block.Available; } return default; } } } /// <summary> /// If set, would cause the next send operation to be delayed /// and complete asynchronously. Can be used to test cancellation tokens /// and async code branches. /// </summary> public TimeSpan DelayForNextSend { get; set; } public override bool CanRead => true; public override bool CanSeek => false; public override bool CanWrite => true; public override long Length => -1; public override long Position { get => -1; set => throw new NotSupportedException(); } protected override void Dispose(bool disposing) { if (!_disposed.IsCancellationRequested) { _disposed.Cancel(); lock (Remote._inputQueue) { Remote._inputLock.Release(); Remote._inputQueue.Enqueue(Block.ConnectionClosed); } } } public override async ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken) { using CancellationTokenSource cancellation = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _disposed.Token); try { await _inputLock.WaitAsync(cancellation.Token).ConfigureAwait(false); } catch (TaskCanceledException) when (cancellationToken.IsCancellationRequested) { throw new OperationCanceledException(cancellationToken); } catch (OperationCanceledException) when (_disposed.IsCancellationRequested) { return 0; } lock (_inputQueue) { Block block = _inputQueue.Peek(); if (block == Block.ConnectionClosed) { return 0; } int count = Math.Min(block.AvailableLength, buffer.Length); block.Available.Slice(0, count).CopyTo(buffer.Span); block.Advance(count); if (block.AvailableLength == 0) { _inputQueue.Dequeue(); } else { // Because we haven't fully consumed the buffer // we should release once the input lock so we can acquire // it again on consequent receive. _inputLock.Release(); } return count; } } /// <summary> /// Enqueues the provided data for receive by the WebSocket. /// </summary> public void Enqueue(params byte[] data) { lock (_inputQueue) { _inputLock.Release(); _inputQueue.Enqueue(new Block(data)); } } /// <summary> /// Enqueues the provided data for receive by the WebSocket. /// </summary> public void Enqueue(ReadOnlySpan<byte> data) { lock (_inputQueue) { _inputLock.Release(); _inputQueue.Enqueue(new Block(data.ToArray())); } } public void Clear() { lock (_inputQueue) { while (_inputQueue.Count > 0) { if (_inputQueue.Peek() == Block.ConnectionClosed) { break; } _inputQueue.Dequeue(); } while (_inputLock.CurrentCount > _inputQueue.Count) { _inputLock.Wait(0); } } } public override void Write(ReadOnlySpan<byte> buffer) { lock (Remote._inputQueue) { Remote._inputLock.Release(); Remote._inputQueue.Enqueue(new Block(buffer.ToArray())); } } public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken) { if (DelayForNextSend > TimeSpan.Zero) { await Task.Delay(DelayForNextSend, cancellationToken); DelayForNextSend = TimeSpan.Zero; } Write(buffer.Span); } public override void Flush() => throw new NotSupportedException(); public override int Read(byte[] buffer, int offset, int count) => throw new NotSupportedException(); public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException(); public override void SetLength(long value) => throw new NotSupportedException(); public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(); private sealed class Block { public static readonly Block ConnectionClosed = new(Array.Empty<byte>()); private readonly byte[] _data; private int _position; public Block(byte[] data) { _data = data; } public Span<byte> Available => _data.AsSpan(_position); public int AvailableLength => _data.Length - _position; public void Advance(int count) => _position += 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.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; namespace System.Net.WebSockets.Tests { /// <summary> /// A helper stream class that can be used simulate sending / receiving (duplex) data in a websocket. /// </summary> public class WebSocketTestStream : Stream { private readonly SemaphoreSlim _inputLock = new(initialCount: 0); private readonly Queue<Block> _inputQueue = new(); private readonly CancellationTokenSource _disposed = new(); public WebSocketTestStream() { GC.SuppressFinalize(this); Remote = new WebSocketTestStream(this); } private WebSocketTestStream(WebSocketTestStream remote) { GC.SuppressFinalize(this); Remote = remote; } public WebSocketTestStream Remote { get; } /// <summary> /// Returns the number of unread bytes. /// </summary> public int Available { get { int available = 0; lock (_inputQueue) { foreach (Block x in _inputQueue) { available += x.AvailableLength; } } return available; } } public Span<byte> NextAvailableBytes { get { lock (_inputQueue) { if (_inputQueue.TryPeek(out Block block)) { return block.Available; } return default; } } } /// <summary> /// If set, would cause the next send operation to be delayed /// and complete asynchronously. Can be used to test cancellation tokens /// and async code branches. /// </summary> public TimeSpan DelayForNextSend { get; set; } public override bool CanRead => true; public override bool CanSeek => false; public override bool CanWrite => true; public override long Length => -1; public override long Position { get => -1; set => throw new NotSupportedException(); } protected override void Dispose(bool disposing) { if (!_disposed.IsCancellationRequested) { _disposed.Cancel(); lock (Remote._inputQueue) { Remote._inputLock.Release(); Remote._inputQueue.Enqueue(Block.ConnectionClosed); } } } public override async ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken) { using CancellationTokenSource cancellation = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _disposed.Token); try { await _inputLock.WaitAsync(cancellation.Token).ConfigureAwait(false); } catch (TaskCanceledException) when (cancellationToken.IsCancellationRequested) { throw new OperationCanceledException(cancellationToken); } catch (OperationCanceledException) when (_disposed.IsCancellationRequested) { return 0; } lock (_inputQueue) { Block block = _inputQueue.Peek(); if (block == Block.ConnectionClosed) { return 0; } int count = Math.Min(block.AvailableLength, buffer.Length); block.Available.Slice(0, count).CopyTo(buffer.Span); block.Advance(count); if (block.AvailableLength == 0) { _inputQueue.Dequeue(); } else { // Because we haven't fully consumed the buffer // we should release once the input lock so we can acquire // it again on consequent receive. _inputLock.Release(); } return count; } } /// <summary> /// Enqueues the provided data for receive by the WebSocket. /// </summary> public void Enqueue(params byte[] data) { lock (_inputQueue) { _inputLock.Release(); _inputQueue.Enqueue(new Block(data)); } } /// <summary> /// Enqueues the provided data for receive by the WebSocket. /// </summary> public void Enqueue(ReadOnlySpan<byte> data) { lock (_inputQueue) { _inputLock.Release(); _inputQueue.Enqueue(new Block(data.ToArray())); } } public void Clear() { lock (_inputQueue) { while (_inputQueue.Count > 0) { if (_inputQueue.Peek() == Block.ConnectionClosed) { break; } _inputQueue.Dequeue(); } while (_inputLock.CurrentCount > _inputQueue.Count) { _inputLock.Wait(0); } } } public override void Write(ReadOnlySpan<byte> buffer) { lock (Remote._inputQueue) { Remote._inputLock.Release(); Remote._inputQueue.Enqueue(new Block(buffer.ToArray())); } } public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken) { if (DelayForNextSend > TimeSpan.Zero) { await Task.Delay(DelayForNextSend, cancellationToken); DelayForNextSend = TimeSpan.Zero; } Write(buffer.Span); } public override void Flush() => throw new NotSupportedException(); public override int Read(byte[] buffer, int offset, int count) => throw new NotSupportedException(); public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException(); public override void SetLength(long value) => throw new NotSupportedException(); public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException(); private sealed class Block { public static readonly Block ConnectionClosed = new(Array.Empty<byte>()); private readonly byte[] _data; private int _position; public Block(byte[] data) { _data = data; } public Span<byte> Available => _data.AsSpan(_position); public int AvailableLength => _data.Length - _position; public void Advance(int count) => _position += count; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ReadEventLog.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 Microsoft.Win32.SafeHandles; internal static partial class Interop { internal static partial class Advapi32 { internal const int SEEK_READ = 0x2; internal const int FORWARDS_READ = 0x4; internal const int BACKWARDS_READ = 0x8; [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ReadEventLogW", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool ReadEventLog( SafeEventLogReadHandle hEventLog, int dwReadFlags, int dwRecordOffset, byte[] lpBuffer, int nNumberOfBytesRead, out int pnBytesRead, out int pnMinNumberOfBytesNeeded); } }
// 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 Microsoft.Win32.SafeHandles; internal static partial class Interop { internal static partial class Advapi32 { internal const int SEEK_READ = 0x2; internal const int FORWARDS_READ = 0x4; internal const int BACKWARDS_READ = 0x8; [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ReadEventLogW", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool ReadEventLog( SafeEventLogReadHandle hEventLog, int dwReadFlags, int dwRecordOffset, byte[] lpBuffer, int nNumberOfBytesRead, out int pnBytesRead, out int pnMinNumberOfBytesNeeded); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/BitwiseClear.Vector128.UInt64.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 BitwiseClear_Vector128_UInt64() { var test = new SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64(); 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__BitwiseClear_Vector128_UInt64 { 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(UInt64[] inArray1, UInt64[] inArray2, UInt64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt64>(); 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<UInt64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt64, 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<UInt64> _fld1; public Vector128<UInt64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64 testClass) { var result = AdvSimd.BitwiseClear(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64 testClass) { fixed (Vector128<UInt64>* pFld1 = &_fld1) fixed (Vector128<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(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<UInt64>>() / sizeof(UInt64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); private static UInt64[] _data1 = new UInt64[Op1ElementCount]; private static UInt64[] _data2 = new UInt64[Op2ElementCount]; private static Vector128<UInt64> _clsVar1; private static Vector128<UInt64> _clsVar2; private Vector128<UInt64> _fld1; private Vector128<UInt64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); } public SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } _dataTable = new DataTable(_data1, _data2, new UInt64[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.BitwiseClear( Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt64>>(_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.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((UInt64*)(_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).GetMethod(nameof(AdvSimd.BitwiseClear), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.BitwiseClear), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.BitwiseClear( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<UInt64>* pClsVar1 = &_clsVar1) fixed (Vector128<UInt64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(pClsVar1)), AdvSimd.LoadVector128((UInt64*)(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<UInt64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr); var result = AdvSimd.BitwiseClear(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((UInt64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.BitwiseClear(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64(); var result = AdvSimd.BitwiseClear(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__BitwiseClear_Vector128_UInt64(); fixed (Vector128<UInt64>* pFld1 = &test._fld1) fixed (Vector128<UInt64>* pFld2 = &test._fld2) { var result = AdvSimd.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.BitwiseClear(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<UInt64>* pFld1 = &_fld1) fixed (Vector128<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(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.BitwiseClear(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.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(&test._fld1)), AdvSimd.LoadVector128((UInt64*)(&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<UInt64> op1, Vector128<UInt64> op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.BitwiseClear(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.BitwiseClear)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {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 BitwiseClear_Vector128_UInt64() { var test = new SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64(); 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__BitwiseClear_Vector128_UInt64 { 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(UInt64[] inArray1, UInt64[] inArray2, UInt64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt64>(); 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<UInt64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt64, 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<UInt64> _fld1; public Vector128<UInt64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64 testClass) { var result = AdvSimd.BitwiseClear(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64 testClass) { fixed (Vector128<UInt64>* pFld1 = &_fld1) fixed (Vector128<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(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<UInt64>>() / sizeof(UInt64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); private static UInt64[] _data1 = new UInt64[Op1ElementCount]; private static UInt64[] _data2 = new UInt64[Op2ElementCount]; private static Vector128<UInt64> _clsVar1; private static Vector128<UInt64> _clsVar2; private Vector128<UInt64> _fld1; private Vector128<UInt64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); } public SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } _dataTable = new DataTable(_data1, _data2, new UInt64[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.BitwiseClear( Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt64>>(_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.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((UInt64*)(_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).GetMethod(nameof(AdvSimd.BitwiseClear), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.BitwiseClear), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.BitwiseClear( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<UInt64>* pClsVar1 = &_clsVar1) fixed (Vector128<UInt64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(pClsVar1)), AdvSimd.LoadVector128((UInt64*)(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<UInt64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr); var result = AdvSimd.BitwiseClear(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((UInt64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.BitwiseClear(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__BitwiseClear_Vector128_UInt64(); var result = AdvSimd.BitwiseClear(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__BitwiseClear_Vector128_UInt64(); fixed (Vector128<UInt64>* pFld1 = &test._fld1) fixed (Vector128<UInt64>* pFld2 = &test._fld2) { var result = AdvSimd.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.BitwiseClear(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<UInt64>* pFld1 = &_fld1) fixed (Vector128<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(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.BitwiseClear(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.BitwiseClear( AdvSimd.LoadVector128((UInt64*)(&test._fld1)), AdvSimd.LoadVector128((UInt64*)(&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<UInt64> op1, Vector128<UInt64> op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt64[] outArray = new UInt64[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.BitwiseClear(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.BitwiseClear)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/GC/API/GC/KeepAliveRecur.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // Tests KeepAlive() in Recursive method using System; public class Test_KeepAliveRecur { public class Dummy { public static bool visited; ~Dummy() { Console.WriteLine("In Finalize() of Dummy"); visited = true; } } public static int count; public static void foo(Object o) { if (count == 10) return; Console.WriteLine("Count: {0}", count); count++; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); foo(o); //Recursive call GC.KeepAlive(o); // Keeping object alive } public static int Main() { Dummy obj = new Dummy(); foo(obj); Console.WriteLine("After call to foo()"); if (Dummy.visited == false) { // has not visited the Finalize() Console.WriteLine("Test for KeepAlive() recursively passed!"); return 100; } else { Console.WriteLine("Test for KeepAlive() recursively 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 KeepAlive() in Recursive method using System; public class Test_KeepAliveRecur { public class Dummy { public static bool visited; ~Dummy() { Console.WriteLine("In Finalize() of Dummy"); visited = true; } } public static int count; public static void foo(Object o) { if (count == 10) return; Console.WriteLine("Count: {0}", count); count++; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); foo(o); //Recursive call GC.KeepAlive(o); // Keeping object alive } public static int Main() { Dummy obj = new Dummy(); foo(obj); Console.WriteLine("After call to foo()"); if (Dummy.visited == false) { // has not visited the Finalize() Console.WriteLine("Test for KeepAlive() recursively passed!"); return 100; } else { Console.WriteLine("Test for KeepAlive() recursively failed!"); return 1; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.ComponentModel.Composition/tests/System/Integration/ConstructorInjectionTests.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.Composition; using System.ComponentModel.Composition.Factories; using System.ComponentModel.Composition.Hosting; using Xunit; namespace Tests.Integration { public class ConstructorInjectionTests { [Fact] public void SimpleConstructorInjection() { var container = ContainerFactory.Create(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(PartFactory.CreateAttributed(typeof(SimpleConstructorInjectedObject))); batch.AddExportedValue("CISimpleValue", 42); container.Compose(batch); SimpleConstructorInjectedObject simple = container.GetExportedValue<SimpleConstructorInjectedObject>(); Assert.Equal(42, simple.CISimpleValue); } public interface IOptionalRef { } [Export] public class OptionalExportProvided { } [Export] public class AWithOptionalParameter { [ImportingConstructor] public AWithOptionalParameter([Import(AllowDefault = true)]IOptionalRef import, [Import("ContractThatShouldNotBeFound", AllowDefault = true)]int value, [Import(AllowDefault=true)]OptionalExportProvided provided) { Assert.Null(import); Assert.Equal(0, value); Assert.NotNull(provided); } } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException): Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void OptionalConstructorArgument() { var container = GetContainerWithCatalog(); var a = container.GetExportedValue<AWithOptionalParameter>(); // A should verify that it receieved optional arugments properly Assert.NotNull(a); } [Export] public class AWithCollectionArgument { private IEnumerable<int> _values; [ImportingConstructor] public AWithCollectionArgument([ImportMany("MyConstructorCollectionItem")]IEnumerable<int> values) { this._values = values; } public IEnumerable<int> Values { get { return this._values; } } } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException): Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void RebindingShouldNotHappenForConstructorArguments() { var container = GetContainerWithCatalog(); CompositionBatch batch = new CompositionBatch(); var p1 = batch.AddExportedValue("MyConstructorCollectionItem", 1); batch.AddExportedValue("MyConstructorCollectionItem", 2); batch.AddExportedValue("MyConstructorCollectionItem", 3); container.Compose(batch); var a = container.GetExportedValue<AWithCollectionArgument>(); Assert.Equal(a.Values, new int[3] { 1, 2, 3 }); batch = new CompositionBatch(); batch.AddExportedValue("MyConstructorCollectionItem", 4); batch.AddExportedValue("MyConstructorCollectionItem", 5); batch.AddExportedValue("MyConstructorCollectionItem", 6); // After rejection changes that are incompatible with existing assumptions are no // longer silently ignored. The batch attempting to make this change is rejected // with a ChangeRejectedException Assert.Throws<ChangeRejectedException>(() => { container.Compose(batch); }); // The collection which is a constructor import should not be rebound Assert.Equal(a.Values, new int[3] { 1, 2, 3 }); batch.RemovePart(p1); // After rejection changes that are incompatible with existing assumptions are no // longer silently ignored. The batch attempting to make this change is rejected // with a ChangeRejectedException Assert.Throws<ChangeRejectedException>(() => { container.Compose(batch); }); // The collection which is a constructor import should not be rebound Assert.Equal(a.Values, new int[3] { 1, 2, 3 }); } [Fact] public void MissingConstructorArgsWithAlreadyCreatedInstance() { var container = GetContainerWithCatalog(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(new ClassWithNotFoundConstructorArgs(21)); container.Compose(batch); } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException): Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void MissingConstructorArgsWithTypeFromCatalogMissingArg() { var container = GetContainerWithCatalog(); // After rejection part definitions in catalogs whose dependencies cannot be // satisfied are now silently ignored, turning this into a cardinality // exception for the GetExportedValue call Assert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<ClassWithNotFoundConstructorArgs>(); }); } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException): Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void MissingConstructorArgsWithWithTypeFromCatalogWithArg() { var container = GetContainerWithCatalog(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("ContractThatDoesntExist", 21); container.Compose(batch); Assert.True(container.IsPresent<ClassWithNotFoundConstructorArgs>()); } [Export] public class ClassWithNotFoundConstructorArgs { [ImportingConstructor] public ClassWithNotFoundConstructorArgs([Import("ContractThatDoesntExist")]int i) { } } private CompositionContainer GetContainerWithCatalog() { var catalog = new AssemblyCatalog(typeof(ConstructorInjectionTests).Assembly); return new CompositionContainer(catalog); } [Export] public class InvalidImportManyCI { [ImportingConstructor] public InvalidImportManyCI( [ImportMany]List<MyExport> exports) { } } [Fact] public void ImportMany_ConstructorParameter_OnNonAssiganbleType_ShouldThrowCompositionException() { var container = ContainerFactory.CreateWithAttributedCatalog(typeof(InvalidImportManyCI)); Assert.Throws<CompositionException>( () => container.GetExportedValue<InvalidImportManyCI>()); } } }
// 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.Composition; using System.ComponentModel.Composition.Factories; using System.ComponentModel.Composition.Hosting; using Xunit; namespace Tests.Integration { public class ConstructorInjectionTests { [Fact] public void SimpleConstructorInjection() { var container = ContainerFactory.Create(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(PartFactory.CreateAttributed(typeof(SimpleConstructorInjectedObject))); batch.AddExportedValue("CISimpleValue", 42); container.Compose(batch); SimpleConstructorInjectedObject simple = container.GetExportedValue<SimpleConstructorInjectedObject>(); Assert.Equal(42, simple.CISimpleValue); } public interface IOptionalRef { } [Export] public class OptionalExportProvided { } [Export] public class AWithOptionalParameter { [ImportingConstructor] public AWithOptionalParameter([Import(AllowDefault = true)]IOptionalRef import, [Import("ContractThatShouldNotBeFound", AllowDefault = true)]int value, [Import(AllowDefault=true)]OptionalExportProvided provided) { Assert.Null(import); Assert.Equal(0, value); Assert.NotNull(provided); } } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException): Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void OptionalConstructorArgument() { var container = GetContainerWithCatalog(); var a = container.GetExportedValue<AWithOptionalParameter>(); // A should verify that it receieved optional arugments properly Assert.NotNull(a); } [Export] public class AWithCollectionArgument { private IEnumerable<int> _values; [ImportingConstructor] public AWithCollectionArgument([ImportMany("MyConstructorCollectionItem")]IEnumerable<int> values) { this._values = values; } public IEnumerable<int> Values { get { return this._values; } } } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException): Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void RebindingShouldNotHappenForConstructorArguments() { var container = GetContainerWithCatalog(); CompositionBatch batch = new CompositionBatch(); var p1 = batch.AddExportedValue("MyConstructorCollectionItem", 1); batch.AddExportedValue("MyConstructorCollectionItem", 2); batch.AddExportedValue("MyConstructorCollectionItem", 3); container.Compose(batch); var a = container.GetExportedValue<AWithCollectionArgument>(); Assert.Equal(a.Values, new int[3] { 1, 2, 3 }); batch = new CompositionBatch(); batch.AddExportedValue("MyConstructorCollectionItem", 4); batch.AddExportedValue("MyConstructorCollectionItem", 5); batch.AddExportedValue("MyConstructorCollectionItem", 6); // After rejection changes that are incompatible with existing assumptions are no // longer silently ignored. The batch attempting to make this change is rejected // with a ChangeRejectedException Assert.Throws<ChangeRejectedException>(() => { container.Compose(batch); }); // The collection which is a constructor import should not be rebound Assert.Equal(a.Values, new int[3] { 1, 2, 3 }); batch.RemovePart(p1); // After rejection changes that are incompatible with existing assumptions are no // longer silently ignored. The batch attempting to make this change is rejected // with a ChangeRejectedException Assert.Throws<ChangeRejectedException>(() => { container.Compose(batch); }); // The collection which is a constructor import should not be rebound Assert.Equal(a.Values, new int[3] { 1, 2, 3 }); } [Fact] public void MissingConstructorArgsWithAlreadyCreatedInstance() { var container = GetContainerWithCatalog(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(new ClassWithNotFoundConstructorArgs(21)); container.Compose(batch); } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException): Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void MissingConstructorArgsWithTypeFromCatalogMissingArg() { var container = GetContainerWithCatalog(); // After rejection part definitions in catalogs whose dependencies cannot be // satisfied are now silently ignored, turning this into a cardinality // exception for the GetExportedValue call Assert.Throws<ImportCardinalityMismatchException>(() => { container.GetExportedValue<ClassWithNotFoundConstructorArgs>(); }); } [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/24240", TestPlatforms.AnyUnix)] // Actual: typeof(System.Reflection.ReflectionTypeLoadException): Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void MissingConstructorArgsWithWithTypeFromCatalogWithArg() { var container = GetContainerWithCatalog(); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("ContractThatDoesntExist", 21); container.Compose(batch); Assert.True(container.IsPresent<ClassWithNotFoundConstructorArgs>()); } [Export] public class ClassWithNotFoundConstructorArgs { [ImportingConstructor] public ClassWithNotFoundConstructorArgs([Import("ContractThatDoesntExist")]int i) { } } private CompositionContainer GetContainerWithCatalog() { var catalog = new AssemblyCatalog(typeof(ConstructorInjectionTests).Assembly); return new CompositionContainer(catalog); } [Export] public class InvalidImportManyCI { [ImportingConstructor] public InvalidImportManyCI( [ImportMany]List<MyExport> exports) { } } [Fact] public void ImportMany_ConstructorParameter_OnNonAssiganbleType_ShouldThrowCompositionException() { var container = ContainerFactory.CreateWithAttributedCatalog(typeof(InvalidImportManyCI)); Assert.Throws<CompositionException>( () => container.GetExportedValue<InvalidImportManyCI>()); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Symbolic/TransitionRegexKind.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.RegularExpressions.Symbolic { /// <summary>Kinds of transition regexes. Transition regexes maintain a DNF form that pushes all intersections and complements to the leaves.</summary> internal enum TransitionRegexKind { Leaf, Conditional, Union, OrderedUnion, Lookaround, Effect } }
// 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.RegularExpressions.Symbolic { /// <summary>Kinds of transition regexes. Transition regexes maintain a DNF form that pushes all intersections and complements to the leaves.</summary> internal enum TransitionRegexKind { Leaf, Conditional, Union, OrderedUnion, Lookaround, Effect } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversions.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; using System.Diagnostics.CodeAnalysis; using Microsoft.CSharp.RuntimeBinder.Syntax; namespace Microsoft.CSharp.RuntimeBinder.Semantics { // Encapsulates all logic about convertibility between types. // // WARNING: These methods do not precisely match the spec. // WARNING: For example most also return true for identity conversions, // WARNING: FExpRefConv includes all Implicit and Explicit reference conversions. internal static class CConversions { // WARNING: These methods do not precisely match the spec. // WARNING: For example most also return true for identity conversions, // WARNING: FExpRefConv includes all Implicit and Explicit reference conversions. /*************************************************************************************************** Determine whether there is an implicit reference conversion from typeSrc to typeDst. This is when the source is a reference type and the destination is a base type of the source. Note that typeDst.IsRefType() may still return false (when both are type parameters). ***************************************************************************************************/ [RequiresUnreferencedCode(Binder.TrimmerWarning)] public static bool FImpRefConv(CType typeSrc, CType typeDst) => typeSrc.IsReferenceType && SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeSrc, typeDst); /*************************************************************************************************** Determine whether there is an explicit or implicit reference conversion (or identity conversion) from typeSrc to typeDst. This is when: 13.2.3 Explicit reference conversions The explicit reference conversions are: * From object to any reference-type. * From any class-type S to any class-type T, provided S is a base class of T. * From any class-type S to any interface-type T, provided S is not sealed and provided S does not implement T. * From any interface-type S to any class-type T, provided T is not sealed or provided T implements S. * From any interface-type S to any interface-type T, provided S is not derived from T. * From an array-type S with an element type SE to an array-type T with an element type TE, provided all of the following are true: o S and T differ only in element type. (In other words, S and T have the same number of dimensions.) o An explicit reference conversion exists from SE to TE. * From System.Array and the interfaces it implements, to any array-type. * From System.Delegate and the interfaces it implements, to any delegate-type. * From a one-dimensional array-type S[] to System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> and their base interfaces, provided there is an explicit reference conversion from S to T. * From a generic delegate type S to generic delegate type T, provided all of the follow are true: o Both types are constructed generic types of the same generic delegate type, D<X1,... Xk>.That is, S is D<S1,... Sk> and T is D<T1,... Tk>. o S is not compatible with or identical to T. o If type parameter Xi is declared to be invariant then Si must be identical to Ti. o If type parameter Xi is declared to be covariant ("out") then Si must be convertible to Ti via an identify conversion, implicit reference conversion, or explicit reference conversion. o If type parameter Xi is declared to be contravariant ("in") then either Si must be identical to Ti, or Si and Ti must both be reference types. * From System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> and their base interfaces to a one-dimensional array-type S[], provided there is an implicit or explicit reference conversion from S[] to System.Collections.Generic.IList<T> or System.Collections.Generic.IReadOnlyList<T>. This is precisely when either S and T are the same type or there is an implicit or explicit reference conversion from S to T. For a type-parameter T that is known to be a reference type (25.7), the following explicit reference conversions exist: * From the effective base class C of T to T and from any base class of C to T. * From any interface-type to T. * From T to any interface-type I provided there isn't already an implicit reference conversion from T to I. * From a type-parameter U to T provided that T depends on U (25.7). [Note: Since T is known to be a reference type, within the scope of T, the run-time type of U will always be a reference type, even if U is not known to be a reference type at compile-time. end note] * Both src and dst are reference types and there is a builtin explicit conversion from src to dst. * Or src is a reference type and dst is a base type of src (in which case the conversion is implicit as well). * Or dst is a reference type and src is a base type of dst. The latter two cases can happen with type variables even though the other type variable is not a reference type. ***************************************************************************************************/ [RequiresUnreferencedCode(Binder.TrimmerWarning)] public static bool FExpRefConv(CType typeSrc, CType typeDst) { Debug.Assert(typeSrc != null); Debug.Assert(typeDst != null); if (typeSrc.IsReferenceType && typeDst.IsReferenceType) { // is there an implicit reference conversion in either direction? // this handles the bulk of the cases ... if (SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeSrc, typeDst) || SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeDst, typeSrc)) { return true; } // For a type-parameter T that is known to be a reference type (25.7), the following explicit reference conversions exist: // * From any interface-type to T. // * From T to any interface-type I provided there isn't already an implicit reference conversion from T to I. if (typeSrc.IsInterfaceType && typeDst is TypeParameterType || typeSrc is TypeParameterType && typeDst.IsInterfaceType) { return true; } // * From any class-type S to any interface-type T, provided S is not sealed // * From any interface-type S to any class-type T, provided T is not sealed // * From any interface-type S to any interface-type T, provided S is not derived from T. if (typeSrc is AggregateType atSrc && typeDst is AggregateType atDst) { AggregateSymbol aggSrc = atSrc.OwningAggregate; AggregateSymbol aggDest = atDst.OwningAggregate; if ((aggSrc.IsClass() && !aggSrc.IsSealed() && aggDest.IsInterface()) || (aggSrc.IsInterface() && aggDest.IsClass() && !aggDest.IsSealed()) || (aggSrc.IsInterface() && aggDest.IsInterface())) { return true; } } if (typeSrc is ArrayType arrSrc) { // * From an array-type S with an element type SE to an array-type T with an element type TE, provided all of the following are true: // o S and T differ only in element type. (In other words, S and T have the same number of dimensions.) // o An explicit reference conversion exists from SE to TE. if (typeDst is ArrayType arrDst) { return arrSrc.Rank == arrDst.Rank && arrSrc.IsSZArray == arrDst.IsSZArray && FExpRefConv(arrSrc.ElementType, arrDst.ElementType); } // * From a one-dimensional array-type S[] to System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> // and their base interfaces, provided there is an explicit reference conversion from S to T. if (!arrSrc.IsSZArray || !typeDst.IsInterfaceType) { return false; } AggregateType aggDst = (AggregateType)typeDst; TypeArray typeArgsAll = aggDst.TypeArgsAll; if (typeArgsAll.Count != 1) { return false; } AggregateSymbol aggIList = SymbolLoader.GetPredefAgg(PredefinedType.PT_G_ILIST); AggregateSymbol aggIReadOnlyList = SymbolLoader.GetPredefAgg(PredefinedType.PT_G_IREADONLYLIST); if ((aggIList == null || !SymbolLoader.IsBaseAggregate(aggIList, aggDst.OwningAggregate)) && (aggIReadOnlyList == null || !SymbolLoader.IsBaseAggregate(aggIReadOnlyList, aggDst.OwningAggregate))) { return false; } return FExpRefConv(arrSrc.ElementType, typeArgsAll[0]); } if (typeDst is ArrayType arrayDest && typeSrc is AggregateType aggtypeSrc) { // * From System.Array and the interfaces it implements, to any array-type. if (SymbolLoader.HasIdentityOrImplicitReferenceConversion(SymbolLoader.GetPredefindType(PredefinedType.PT_ARRAY), typeSrc)) { return true; } // * From System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> and their base interfaces to a // one-dimensional array-type S[], provided there is an implicit or explicit reference conversion from S[] to // System.Collections.Generic.IList<T> or System.Collections.Generic.IReadOnlyList<T>. This is precisely when either S and T // are the same type or there is an implicit or explicit reference conversion from S to T. if (!arrayDest.IsSZArray || !typeSrc.IsInterfaceType || aggtypeSrc.TypeArgsAll.Count != 1) { return false; } AggregateSymbol aggIList = SymbolLoader.GetPredefAgg(PredefinedType.PT_G_ILIST); AggregateSymbol aggIReadOnlyList = SymbolLoader.GetPredefAgg(PredefinedType.PT_G_IREADONLYLIST); if ((aggIList == null || !SymbolLoader.IsBaseAggregate(aggIList, aggtypeSrc.OwningAggregate)) && (aggIReadOnlyList == null || !SymbolLoader.IsBaseAggregate(aggIReadOnlyList, aggtypeSrc.OwningAggregate))) { return false; } CType typeArr = arrayDest.ElementType; CType typeLst = aggtypeSrc.TypeArgsAll[0]; Debug.Assert(!(typeArr is MethodGroupType)); return typeArr == typeLst || FExpRefConv(typeArr, typeLst); } if (HasGenericDelegateExplicitReferenceConversion(typeSrc, typeDst)) { return true; } } else if (typeSrc.IsReferenceType) { // conversion of T . U, where T : class, U // .. these constraints implies where U : class return SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeSrc, typeDst); } else if (typeDst.IsReferenceType) { // conversion of T . U, where U : class, T // .. these constraints implies where T : class return SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeDst, typeSrc); } return false; } /*************************************************************************************************** There exists an explicit conversion ... * From a generic delegate type S to generic delegate type T, provided all of the follow are true: o Both types are constructed generic types of the same generic delegate type, D<X1,... Xk>.That is, S is D<S1,... Sk> and T is D<T1,... Tk>. o S is not compatible with or identical to T. o If type parameter Xi is declared to be invariant then Si must be identical to Ti. o If type parameter Xi is declared to be covariant ("out") then Si must be convertible to Ti via an identify conversion, implicit reference conversion, or explicit reference conversion. o If type parameter Xi is declared to be contravariant ("in") then either Si must be identical to Ti, or Si and Ti must both be reference types. ***************************************************************************************************/ [RequiresUnreferencedCode(Binder.TrimmerWarning)] public static bool HasGenericDelegateExplicitReferenceConversion(CType source, CType target) => target is AggregateType aggTarget && HasGenericDelegateExplicitReferenceConversion(source, aggTarget); [RequiresUnreferencedCode(Binder.TrimmerWarning)] public static bool HasGenericDelegateExplicitReferenceConversion(CType pSource, AggregateType pTarget) { if (!(pSource is AggregateType aggSrc) || !aggSrc.IsDelegateType || !pTarget.IsDelegateType || aggSrc.OwningAggregate != pTarget.OwningAggregate || SymbolLoader.HasIdentityOrImplicitReferenceConversion(aggSrc, pTarget)) { return false; } TypeArray pTypeParams = aggSrc.OwningAggregate.GetTypeVarsAll(); TypeArray pSourceArgs = aggSrc.TypeArgsAll; TypeArray pTargetArgs = pTarget.TypeArgsAll; Debug.Assert(pTypeParams.Count == pSourceArgs.Count); Debug.Assert(pTypeParams.Count == pTargetArgs.Count); for (int iParam = 0; iParam < pTypeParams.Count; ++iParam) { CType pSourceArg = pSourceArgs[iParam]; CType pTargetArg = pTargetArgs[iParam]; // If they're identical then this one is automatically good, so skip it. // If we have an error type, then we're in some fault tolerance. Let it through. if (pSourceArg == pTargetArg) { continue; } TypeParameterType pParam = (TypeParameterType)pTypeParams[iParam]; if (pParam.Invariant) { return false; } if (pParam.Covariant) { if (!FExpRefConv(pSourceArg, pTargetArg)) { return false; } } else if (pParam.Contravariant) { if (!pSourceArg.IsReferenceType || !pTargetArg.IsReferenceType) { return false; } } } return true; } /*************************************************************************************************** 13.1.1 Identity conversion An identity conversion converts from any type to the same type. This conversion exists only such that an entity that already has a required type can be said to be convertible to that type. Always returns false if the types are error, anonymous method, or method group ***************************************************************************************************/ /*************************************************************************************************** Determines whether there is a boxing conversion from typeSrc to typeDst 13.1.5 Boxing conversions A boxing conversion permits any non-nullable-value-type to be implicitly converted to the type object or System.ValueType or to any interface-type implemented by the non-nullable-value-type, and any enum type to be implicitly converted to System.Enum as well. ... An enum can be boxed to the type System.Enum, since that is the direct base class for all enums (21.4). A struct or enum can be boxed to the type System.ValueType, since that is the direct base class for all structs (18.3.2) and a base class for all enums. A nullable-type has a boxing conversion to the same set of types to which the nullable-type's underlying type has boxing conversions. For a type-parameter T that is not known to be a reference type (25.7), the following conversions involving T are considered to be boxing conversions at compile-time. At run-time, if T is a value type, the conversion is executed as a boxing conversion. At run-time, if T is a reference type, the conversion is executed as an implicit reference conversion or identity conversion. * From T to its effective base class C, from T to any base class of C, and from T to any interface implemented by C. [Note: C will be one of the types System.Object, System.ValueType, or System.Enum (otherwise T would be known to be a reference type and 13.1.4 would apply instead of this clause). end note] * From T to an interface-type I in T's effective interface set and from T to any base interface of I. ***************************************************************************************************/ /*************************************************************************************************** Determines whether there is a wrapping conversion from typeSrc to typeDst 13.7 Conversions involving nullable types The following terms are used in the subsequent sections: * The term wrapping denotes the process of packaging a value, of type T, in an instance of type T?. A value x of type T is wrapped to type T? by evaluating the expression new T?(x). ***************************************************************************************************/ public static bool FWrappingConv(CType typeSrc, CType typeDst) => typeDst is NullableType nubDst && typeSrc == nubDst.UnderlyingType; /*************************************************************************************************** Determines whether there is a unwrapping conversion from typeSrc to typeDst 13.7 Conversions involving nullable types The following terms are used in the subsequent sections: * The term unwrapping denotes the process of obtaining the value, of type T, contained in an instance of type T?. A value x of type T? is unwrapped to type T by evaluating the expression x.Value. Attempting to unwrap a null instance causes a System.InvalidOperationException to be thrown. ***************************************************************************************************/ public static bool FUnwrappingConv(CType typeSrc, CType typeDst) { return FWrappingConv(typeDst, typeSrc); } } }
// 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; using System.Diagnostics.CodeAnalysis; using Microsoft.CSharp.RuntimeBinder.Syntax; namespace Microsoft.CSharp.RuntimeBinder.Semantics { // Encapsulates all logic about convertibility between types. // // WARNING: These methods do not precisely match the spec. // WARNING: For example most also return true for identity conversions, // WARNING: FExpRefConv includes all Implicit and Explicit reference conversions. internal static class CConversions { // WARNING: These methods do not precisely match the spec. // WARNING: For example most also return true for identity conversions, // WARNING: FExpRefConv includes all Implicit and Explicit reference conversions. /*************************************************************************************************** Determine whether there is an implicit reference conversion from typeSrc to typeDst. This is when the source is a reference type and the destination is a base type of the source. Note that typeDst.IsRefType() may still return false (when both are type parameters). ***************************************************************************************************/ [RequiresUnreferencedCode(Binder.TrimmerWarning)] public static bool FImpRefConv(CType typeSrc, CType typeDst) => typeSrc.IsReferenceType && SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeSrc, typeDst); /*************************************************************************************************** Determine whether there is an explicit or implicit reference conversion (or identity conversion) from typeSrc to typeDst. This is when: 13.2.3 Explicit reference conversions The explicit reference conversions are: * From object to any reference-type. * From any class-type S to any class-type T, provided S is a base class of T. * From any class-type S to any interface-type T, provided S is not sealed and provided S does not implement T. * From any interface-type S to any class-type T, provided T is not sealed or provided T implements S. * From any interface-type S to any interface-type T, provided S is not derived from T. * From an array-type S with an element type SE to an array-type T with an element type TE, provided all of the following are true: o S and T differ only in element type. (In other words, S and T have the same number of dimensions.) o An explicit reference conversion exists from SE to TE. * From System.Array and the interfaces it implements, to any array-type. * From System.Delegate and the interfaces it implements, to any delegate-type. * From a one-dimensional array-type S[] to System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> and their base interfaces, provided there is an explicit reference conversion from S to T. * From a generic delegate type S to generic delegate type T, provided all of the follow are true: o Both types are constructed generic types of the same generic delegate type, D<X1,... Xk>.That is, S is D<S1,... Sk> and T is D<T1,... Tk>. o S is not compatible with or identical to T. o If type parameter Xi is declared to be invariant then Si must be identical to Ti. o If type parameter Xi is declared to be covariant ("out") then Si must be convertible to Ti via an identify conversion, implicit reference conversion, or explicit reference conversion. o If type parameter Xi is declared to be contravariant ("in") then either Si must be identical to Ti, or Si and Ti must both be reference types. * From System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> and their base interfaces to a one-dimensional array-type S[], provided there is an implicit or explicit reference conversion from S[] to System.Collections.Generic.IList<T> or System.Collections.Generic.IReadOnlyList<T>. This is precisely when either S and T are the same type or there is an implicit or explicit reference conversion from S to T. For a type-parameter T that is known to be a reference type (25.7), the following explicit reference conversions exist: * From the effective base class C of T to T and from any base class of C to T. * From any interface-type to T. * From T to any interface-type I provided there isn't already an implicit reference conversion from T to I. * From a type-parameter U to T provided that T depends on U (25.7). [Note: Since T is known to be a reference type, within the scope of T, the run-time type of U will always be a reference type, even if U is not known to be a reference type at compile-time. end note] * Both src and dst are reference types and there is a builtin explicit conversion from src to dst. * Or src is a reference type and dst is a base type of src (in which case the conversion is implicit as well). * Or dst is a reference type and src is a base type of dst. The latter two cases can happen with type variables even though the other type variable is not a reference type. ***************************************************************************************************/ [RequiresUnreferencedCode(Binder.TrimmerWarning)] public static bool FExpRefConv(CType typeSrc, CType typeDst) { Debug.Assert(typeSrc != null); Debug.Assert(typeDst != null); if (typeSrc.IsReferenceType && typeDst.IsReferenceType) { // is there an implicit reference conversion in either direction? // this handles the bulk of the cases ... if (SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeSrc, typeDst) || SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeDst, typeSrc)) { return true; } // For a type-parameter T that is known to be a reference type (25.7), the following explicit reference conversions exist: // * From any interface-type to T. // * From T to any interface-type I provided there isn't already an implicit reference conversion from T to I. if (typeSrc.IsInterfaceType && typeDst is TypeParameterType || typeSrc is TypeParameterType && typeDst.IsInterfaceType) { return true; } // * From any class-type S to any interface-type T, provided S is not sealed // * From any interface-type S to any class-type T, provided T is not sealed // * From any interface-type S to any interface-type T, provided S is not derived from T. if (typeSrc is AggregateType atSrc && typeDst is AggregateType atDst) { AggregateSymbol aggSrc = atSrc.OwningAggregate; AggregateSymbol aggDest = atDst.OwningAggregate; if ((aggSrc.IsClass() && !aggSrc.IsSealed() && aggDest.IsInterface()) || (aggSrc.IsInterface() && aggDest.IsClass() && !aggDest.IsSealed()) || (aggSrc.IsInterface() && aggDest.IsInterface())) { return true; } } if (typeSrc is ArrayType arrSrc) { // * From an array-type S with an element type SE to an array-type T with an element type TE, provided all of the following are true: // o S and T differ only in element type. (In other words, S and T have the same number of dimensions.) // o An explicit reference conversion exists from SE to TE. if (typeDst is ArrayType arrDst) { return arrSrc.Rank == arrDst.Rank && arrSrc.IsSZArray == arrDst.IsSZArray && FExpRefConv(arrSrc.ElementType, arrDst.ElementType); } // * From a one-dimensional array-type S[] to System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> // and their base interfaces, provided there is an explicit reference conversion from S to T. if (!arrSrc.IsSZArray || !typeDst.IsInterfaceType) { return false; } AggregateType aggDst = (AggregateType)typeDst; TypeArray typeArgsAll = aggDst.TypeArgsAll; if (typeArgsAll.Count != 1) { return false; } AggregateSymbol aggIList = SymbolLoader.GetPredefAgg(PredefinedType.PT_G_ILIST); AggregateSymbol aggIReadOnlyList = SymbolLoader.GetPredefAgg(PredefinedType.PT_G_IREADONLYLIST); if ((aggIList == null || !SymbolLoader.IsBaseAggregate(aggIList, aggDst.OwningAggregate)) && (aggIReadOnlyList == null || !SymbolLoader.IsBaseAggregate(aggIReadOnlyList, aggDst.OwningAggregate))) { return false; } return FExpRefConv(arrSrc.ElementType, typeArgsAll[0]); } if (typeDst is ArrayType arrayDest && typeSrc is AggregateType aggtypeSrc) { // * From System.Array and the interfaces it implements, to any array-type. if (SymbolLoader.HasIdentityOrImplicitReferenceConversion(SymbolLoader.GetPredefindType(PredefinedType.PT_ARRAY), typeSrc)) { return true; } // * From System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> and their base interfaces to a // one-dimensional array-type S[], provided there is an implicit or explicit reference conversion from S[] to // System.Collections.Generic.IList<T> or System.Collections.Generic.IReadOnlyList<T>. This is precisely when either S and T // are the same type or there is an implicit or explicit reference conversion from S to T. if (!arrayDest.IsSZArray || !typeSrc.IsInterfaceType || aggtypeSrc.TypeArgsAll.Count != 1) { return false; } AggregateSymbol aggIList = SymbolLoader.GetPredefAgg(PredefinedType.PT_G_ILIST); AggregateSymbol aggIReadOnlyList = SymbolLoader.GetPredefAgg(PredefinedType.PT_G_IREADONLYLIST); if ((aggIList == null || !SymbolLoader.IsBaseAggregate(aggIList, aggtypeSrc.OwningAggregate)) && (aggIReadOnlyList == null || !SymbolLoader.IsBaseAggregate(aggIReadOnlyList, aggtypeSrc.OwningAggregate))) { return false; } CType typeArr = arrayDest.ElementType; CType typeLst = aggtypeSrc.TypeArgsAll[0]; Debug.Assert(!(typeArr is MethodGroupType)); return typeArr == typeLst || FExpRefConv(typeArr, typeLst); } if (HasGenericDelegateExplicitReferenceConversion(typeSrc, typeDst)) { return true; } } else if (typeSrc.IsReferenceType) { // conversion of T . U, where T : class, U // .. these constraints implies where U : class return SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeSrc, typeDst); } else if (typeDst.IsReferenceType) { // conversion of T . U, where U : class, T // .. these constraints implies where T : class return SymbolLoader.HasIdentityOrImplicitReferenceConversion(typeDst, typeSrc); } return false; } /*************************************************************************************************** There exists an explicit conversion ... * From a generic delegate type S to generic delegate type T, provided all of the follow are true: o Both types are constructed generic types of the same generic delegate type, D<X1,... Xk>.That is, S is D<S1,... Sk> and T is D<T1,... Tk>. o S is not compatible with or identical to T. o If type parameter Xi is declared to be invariant then Si must be identical to Ti. o If type parameter Xi is declared to be covariant ("out") then Si must be convertible to Ti via an identify conversion, implicit reference conversion, or explicit reference conversion. o If type parameter Xi is declared to be contravariant ("in") then either Si must be identical to Ti, or Si and Ti must both be reference types. ***************************************************************************************************/ [RequiresUnreferencedCode(Binder.TrimmerWarning)] public static bool HasGenericDelegateExplicitReferenceConversion(CType source, CType target) => target is AggregateType aggTarget && HasGenericDelegateExplicitReferenceConversion(source, aggTarget); [RequiresUnreferencedCode(Binder.TrimmerWarning)] public static bool HasGenericDelegateExplicitReferenceConversion(CType pSource, AggregateType pTarget) { if (!(pSource is AggregateType aggSrc) || !aggSrc.IsDelegateType || !pTarget.IsDelegateType || aggSrc.OwningAggregate != pTarget.OwningAggregate || SymbolLoader.HasIdentityOrImplicitReferenceConversion(aggSrc, pTarget)) { return false; } TypeArray pTypeParams = aggSrc.OwningAggregate.GetTypeVarsAll(); TypeArray pSourceArgs = aggSrc.TypeArgsAll; TypeArray pTargetArgs = pTarget.TypeArgsAll; Debug.Assert(pTypeParams.Count == pSourceArgs.Count); Debug.Assert(pTypeParams.Count == pTargetArgs.Count); for (int iParam = 0; iParam < pTypeParams.Count; ++iParam) { CType pSourceArg = pSourceArgs[iParam]; CType pTargetArg = pTargetArgs[iParam]; // If they're identical then this one is automatically good, so skip it. // If we have an error type, then we're in some fault tolerance. Let it through. if (pSourceArg == pTargetArg) { continue; } TypeParameterType pParam = (TypeParameterType)pTypeParams[iParam]; if (pParam.Invariant) { return false; } if (pParam.Covariant) { if (!FExpRefConv(pSourceArg, pTargetArg)) { return false; } } else if (pParam.Contravariant) { if (!pSourceArg.IsReferenceType || !pTargetArg.IsReferenceType) { return false; } } } return true; } /*************************************************************************************************** 13.1.1 Identity conversion An identity conversion converts from any type to the same type. This conversion exists only such that an entity that already has a required type can be said to be convertible to that type. Always returns false if the types are error, anonymous method, or method group ***************************************************************************************************/ /*************************************************************************************************** Determines whether there is a boxing conversion from typeSrc to typeDst 13.1.5 Boxing conversions A boxing conversion permits any non-nullable-value-type to be implicitly converted to the type object or System.ValueType or to any interface-type implemented by the non-nullable-value-type, and any enum type to be implicitly converted to System.Enum as well. ... An enum can be boxed to the type System.Enum, since that is the direct base class for all enums (21.4). A struct or enum can be boxed to the type System.ValueType, since that is the direct base class for all structs (18.3.2) and a base class for all enums. A nullable-type has a boxing conversion to the same set of types to which the nullable-type's underlying type has boxing conversions. For a type-parameter T that is not known to be a reference type (25.7), the following conversions involving T are considered to be boxing conversions at compile-time. At run-time, if T is a value type, the conversion is executed as a boxing conversion. At run-time, if T is a reference type, the conversion is executed as an implicit reference conversion or identity conversion. * From T to its effective base class C, from T to any base class of C, and from T to any interface implemented by C. [Note: C will be one of the types System.Object, System.ValueType, or System.Enum (otherwise T would be known to be a reference type and 13.1.4 would apply instead of this clause). end note] * From T to an interface-type I in T's effective interface set and from T to any base interface of I. ***************************************************************************************************/ /*************************************************************************************************** Determines whether there is a wrapping conversion from typeSrc to typeDst 13.7 Conversions involving nullable types The following terms are used in the subsequent sections: * The term wrapping denotes the process of packaging a value, of type T, in an instance of type T?. A value x of type T is wrapped to type T? by evaluating the expression new T?(x). ***************************************************************************************************/ public static bool FWrappingConv(CType typeSrc, CType typeDst) => typeDst is NullableType nubDst && typeSrc == nubDst.UnderlyingType; /*************************************************************************************************** Determines whether there is a unwrapping conversion from typeSrc to typeDst 13.7 Conversions involving nullable types The following terms are used in the subsequent sections: * The term unwrapping denotes the process of obtaining the value, of type T, contained in an instance of type T?. A value x of type T? is unwrapped to type T by evaluating the expression x.Value. Attempting to unwrap a null instance causes a System.InvalidOperationException to be thrown. ***************************************************************************************************/ public static bool FUnwrappingConv(CType typeSrc, CType typeDst) { return FWrappingConv(typeDst, typeSrc); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInfo.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; using System.Runtime.CompilerServices; namespace System.Reflection { public abstract partial class MethodInfo : MethodBase { protected MethodInfo() { } public override MemberTypes MemberType => MemberTypes.Method; public virtual ParameterInfo ReturnParameter => throw NotImplemented.ByDesign; public virtual Type ReturnType => throw NotImplemented.ByDesign; public override Type[] GetGenericArguments() { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } public virtual MethodInfo GetGenericMethodDefinition() { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } [RequiresDynamicCode("The native code for this instantiation might not be available at runtime.")] [RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")] public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } public abstract MethodInfo GetBaseDefinition(); public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; } public virtual Delegate CreateDelegate(Type delegateType) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } public virtual Delegate CreateDelegate(Type delegateType, object? target) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } /// <summary>Creates a delegate of the given type 'T' from this method.</summary> public T CreateDelegate<T>() where T : Delegate => (T)CreateDelegate(typeof(T)); /// <summary>Creates a delegate of the given type 'T' with the specified target from this method.</summary> public T CreateDelegate<T>(object? target) where T : Delegate => (T)CreateDelegate(typeof(T), target); public override bool Equals(object? obj) => base.Equals(obj); public override int GetHashCode() => base.GetHashCode(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(MethodInfo? left, MethodInfo? right) { // Test "right" first to allow branch elimination when inlined for null checks (== null) // so it can become a simple test if (right is null) { // return true/false not the test result https://github.com/dotnet/runtime/issues/4207 return (left is null) ? true : false; } // Try fast reference equality and opposite null check prior to calling the slower virtual Equals if ((object?)left == (object)right) { return true; } return (left is null) ? false : left.Equals(right); } public static bool operator !=(MethodInfo? left, MethodInfo? right) => !(left == right); } }
// 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; using System.Runtime.CompilerServices; namespace System.Reflection { public abstract partial class MethodInfo : MethodBase { protected MethodInfo() { } public override MemberTypes MemberType => MemberTypes.Method; public virtual ParameterInfo ReturnParameter => throw NotImplemented.ByDesign; public virtual Type ReturnType => throw NotImplemented.ByDesign; public override Type[] GetGenericArguments() { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } public virtual MethodInfo GetGenericMethodDefinition() { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } [RequiresDynamicCode("The native code for this instantiation might not be available at runtime.")] [RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")] public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } public abstract MethodInfo GetBaseDefinition(); public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; } public virtual Delegate CreateDelegate(Type delegateType) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } public virtual Delegate CreateDelegate(Type delegateType, object? target) { throw new NotSupportedException(SR.NotSupported_SubclassOverride); } /// <summary>Creates a delegate of the given type 'T' from this method.</summary> public T CreateDelegate<T>() where T : Delegate => (T)CreateDelegate(typeof(T)); /// <summary>Creates a delegate of the given type 'T' with the specified target from this method.</summary> public T CreateDelegate<T>(object? target) where T : Delegate => (T)CreateDelegate(typeof(T), target); public override bool Equals(object? obj) => base.Equals(obj); public override int GetHashCode() => base.GetHashCode(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(MethodInfo? left, MethodInfo? right) { // Test "right" first to allow branch elimination when inlined for null checks (== null) // so it can become a simple test if (right is null) { // return true/false not the test result https://github.com/dotnet/runtime/issues/4207 return (left is null) ? true : false; } // Try fast reference equality and opposite null check prior to calling the slower virtual Equals if ((object?)left == (object)right) { return true; } return (left is null) ? false : left.Equals(right); } public static bool operator !=(MethodInfo? left, MethodInfo? right) => !(left == right); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.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.Text; internal static partial class Interop { internal static partial class Normaliz { [GeneratedDllImport("Normaliz.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] internal static unsafe partial BOOL IsNormalizedString(NormalizationForm normForm, char* source, int length); [GeneratedDllImport("Normaliz.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] internal static unsafe partial int NormalizeString( NormalizationForm normForm, char* source, int sourceLength, char* destination, int destinationLength); } }
// 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.Text; internal static partial class Interop { internal static partial class Normaliz { [GeneratedDllImport("Normaliz.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] internal static unsafe partial BOOL IsNormalizedString(NormalizationForm normForm, char* source, int length); [GeneratedDllImport("Normaliz.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] internal static unsafe partial int NormalizeString( NormalizationForm normForm, char* source, int sourceLength, char* destination, int destinationLength); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Regression/JitBlue/Runtime_13417/Runtime_13417.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.CompilerServices; using System.Runtime.InteropServices; public class BoundsCheck { public static int Main() { ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[7]); return (int)GetKey(span) + 100; } [MethodImpl(MethodImplOptions.NoInlining)] public static ulong GetKey(ReadOnlySpan<byte> propertyName) { const int BitsInByte = 8; ulong key = 0; int length = propertyName.Length; if (length > 3) { key = MemoryMarshal.Read<uint>(propertyName); if (length == 7) { key |= (ulong)propertyName[6] << (6 * BitsInByte) | (ulong)propertyName[5] << (5 * BitsInByte) | (ulong)propertyName[4] << (4 * BitsInByte) | (ulong)7 << (7 * BitsInByte); } } return key; } }
// 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.CompilerServices; using System.Runtime.InteropServices; public class BoundsCheck { public static int Main() { ReadOnlySpan<byte> span = new ReadOnlySpan<byte>(new byte[7]); return (int)GetKey(span) + 100; } [MethodImpl(MethodImplOptions.NoInlining)] public static ulong GetKey(ReadOnlySpan<byte> propertyName) { const int BitsInByte = 8; ulong key = 0; int length = propertyName.Length; if (length > 3) { key = MemoryMarshal.Read<uint>(propertyName); if (length == 7) { key |= (ulong)propertyName[6] << (6 * BitsInByte) | (ulong)propertyName[5] << (5 * BitsInByte) | (ulong)propertyName[4] << (4 * BitsInByte) | (ulong)7 << (7 * BitsInByte); } } return key; } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Linq.Expressions/tests/TestExtensions/TestOrderer.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 Xunit.Sdk; namespace System.Linq.Expressions.Tests { /// <summary>Forces tests to be carried out according to the order of their <see cref="TestOrderAttribute.Order"/>, with /// those tests with no attribute happening in the same batch as those with an Order of zero.</summary> internal class TestOrderer : ITestCaseOrderer { IEnumerable<TTestCase> ITestCaseOrderer.OrderTestCases<TTestCase>(IEnumerable<TTestCase> testCases) { Dictionary<int, List<TTestCase>> queue = new Dictionary<int, List<TTestCase>>(); foreach (TTestCase testCase in testCases) { Xunit.Abstractions.IAttributeInfo orderAttribute = testCase.TestMethod.Method.GetCustomAttributes(typeof(TestOrderAttribute)).FirstOrDefault(); int order; if (orderAttribute == null || (order = orderAttribute.GetConstructorArguments().Cast<int>().First()) == 0) { yield return testCase; } else { List<TTestCase> batch; if (!queue.TryGetValue(order, out batch)) queue.Add(order, batch = new List<TTestCase>()); batch.Add(testCase); } } foreach (var order in queue.Keys.OrderBy(i => i)) foreach (var testCase in queue[order]) yield return testCase; } } }
// 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 Xunit.Sdk; namespace System.Linq.Expressions.Tests { /// <summary>Forces tests to be carried out according to the order of their <see cref="TestOrderAttribute.Order"/>, with /// those tests with no attribute happening in the same batch as those with an Order of zero.</summary> internal class TestOrderer : ITestCaseOrderer { IEnumerable<TTestCase> ITestCaseOrderer.OrderTestCases<TTestCase>(IEnumerable<TTestCase> testCases) { Dictionary<int, List<TTestCase>> queue = new Dictionary<int, List<TTestCase>>(); foreach (TTestCase testCase in testCases) { Xunit.Abstractions.IAttributeInfo orderAttribute = testCase.TestMethod.Method.GetCustomAttributes(typeof(TestOrderAttribute)).FirstOrDefault(); int order; if (orderAttribute == null || (order = orderAttribute.GetConstructorArguments().Cast<int>().First()) == 0) { yield return testCase; } else { List<TTestCase> batch; if (!queue.TryGetValue(order, out batch)) queue.Add(order, batch = new List<TTestCase>()); batch.Add(testCase); } } foreach (var order in queue.Keys.OrderBy(i => i)) foreach (var testCase in queue[order]) yield return testCase; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Runtime.CompilerServices.VisualC/src/System/Runtime/CompilerServices/Attributes.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // We need to add an InternalsVisibleToAttribute here to mscorlib since we need to expose some of these types via type forwards in mscorlib // since tooling expects some types to live there and not in System.Runtime.CompilerServices.VisualC, but we don't want to expose // these types publicly. [assembly:System.Runtime.CompilerServices.InternalsVisibleTo("mscorlib, PublicKey=00000000000000000400000000000000")] namespace System.Runtime.CompilerServices { // Types used by the C++/CLI compiler during linking. [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class AssemblyAttributesGoHere { internal AssemblyAttributesGoHere() { } } [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class AssemblyAttributesGoHereS { internal AssemblyAttributesGoHereS() { } } [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class AssemblyAttributesGoHereM { internal AssemblyAttributesGoHereM() { } } [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class AssemblyAttributesGoHereSM { internal AssemblyAttributesGoHereSM() { } } [AttributeUsage(AttributeTargets.All)] internal sealed class DecoratedNameAttribute : Attribute { public DecoratedNameAttribute(string decoratedName) { } } // Indicates that the modified instance is pinned in memory. public static class IsPinned { } public static partial class IsBoxed { } public static partial class IsByValue { } public static partial class IsCopyConstructed { } public static partial class IsExplicitlyDereferenced { } public static partial class IsImplicitlyDereferenced { } public static partial class IsJitIntrinsic { } public static partial class IsLong { } public static partial class IsSignUnspecifiedByte { } public static partial class IsUdtReturn { } [AttributeUsage(AttributeTargets.Struct)] public sealed class HasCopySemanticsAttribute : Attribute { public HasCopySemanticsAttribute() { } } [AttributeUsage(AttributeTargets.Enum)] public sealed class ScopelessEnumAttribute : Attribute { public ScopelessEnumAttribute() { } } [AttributeUsage(AttributeTargets.Struct, Inherited = true)] public sealed class NativeCppClassAttribute : Attribute { public NativeCppClassAttribute() { } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple=true)] public sealed class CppInlineNamespaceAttribute : Attribute { public CppInlineNamespaceAttribute(string dottedName) {} } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)] public sealed class RequiredAttributeAttribute : Attribute { public RequiredAttributeAttribute(Type requiredContract) => RequiredContract = requiredContract; public Type RequiredContract { get; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Property)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class SuppressMergeCheckAttribute : Attribute { public SuppressMergeCheckAttribute() {} } // The CLR data marshaler has some behaviors that are incompatible with // C++. Specifically, C++ treats boolean variables as byte size, whereas // the marshaller treats them as 4-byte size. Similarly, C++ treats // wchar_t variables as 4-byte size, whereas the marshaller treats them // as single byte size under certain conditions. In order to work around // such issues, the C++ compiler will emit a type that the marshaller will // marshal using the correct sizes. In addition, the compiler will place // this modopt onto the variables to indicate that the specified type is // not the true type. Any compiler that needed to deal with similar // marshalling incompatibilities could use this attribute as well. // // Indicates that the modified instance differs from its true type for // correct marshalling. public static class CompilerMarshalOverride { } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // We need to add an InternalsVisibleToAttribute here to mscorlib since we need to expose some of these types via type forwards in mscorlib // since tooling expects some types to live there and not in System.Runtime.CompilerServices.VisualC, but we don't want to expose // these types publicly. [assembly:System.Runtime.CompilerServices.InternalsVisibleTo("mscorlib, PublicKey=00000000000000000400000000000000")] namespace System.Runtime.CompilerServices { // Types used by the C++/CLI compiler during linking. [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class AssemblyAttributesGoHere { internal AssemblyAttributesGoHere() { } } [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class AssemblyAttributesGoHereS { internal AssemblyAttributesGoHereS() { } } [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class AssemblyAttributesGoHereM { internal AssemblyAttributesGoHereM() { } } [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class AssemblyAttributesGoHereSM { internal AssemblyAttributesGoHereSM() { } } [AttributeUsage(AttributeTargets.All)] internal sealed class DecoratedNameAttribute : Attribute { public DecoratedNameAttribute(string decoratedName) { } } // Indicates that the modified instance is pinned in memory. public static class IsPinned { } public static partial class IsBoxed { } public static partial class IsByValue { } public static partial class IsCopyConstructed { } public static partial class IsExplicitlyDereferenced { } public static partial class IsImplicitlyDereferenced { } public static partial class IsJitIntrinsic { } public static partial class IsLong { } public static partial class IsSignUnspecifiedByte { } public static partial class IsUdtReturn { } [AttributeUsage(AttributeTargets.Struct)] public sealed class HasCopySemanticsAttribute : Attribute { public HasCopySemanticsAttribute() { } } [AttributeUsage(AttributeTargets.Enum)] public sealed class ScopelessEnumAttribute : Attribute { public ScopelessEnumAttribute() { } } [AttributeUsage(AttributeTargets.Struct, Inherited = true)] public sealed class NativeCppClassAttribute : Attribute { public NativeCppClassAttribute() { } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple=true)] public sealed class CppInlineNamespaceAttribute : Attribute { public CppInlineNamespaceAttribute(string dottedName) {} } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)] public sealed class RequiredAttributeAttribute : Attribute { public RequiredAttributeAttribute(Type requiredContract) => RequiredContract = requiredContract; public Type RequiredContract { get; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Property)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] internal sealed class SuppressMergeCheckAttribute : Attribute { public SuppressMergeCheckAttribute() {} } // The CLR data marshaler has some behaviors that are incompatible with // C++. Specifically, C++ treats boolean variables as byte size, whereas // the marshaller treats them as 4-byte size. Similarly, C++ treats // wchar_t variables as 4-byte size, whereas the marshaller treats them // as single byte size under certain conditions. In order to work around // such issues, the C++ compiler will emit a type that the marshaller will // marshal using the correct sizes. In addition, the compiler will place // this modopt onto the variables to indicate that the specified type is // not the true type. Any compiler that needed to deal with similar // marshalling incompatibilities could use this attribute as well. // // Indicates that the modified instance differs from its true type for // correct marshalling. public static class CompilerMarshalOverride { } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/Common/tests/System/Xml/XPath/CoreFunctionLibrary/NodeSetFunctionsTests.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 System; using System.Xml; using System.Xml.XPath; using XPathTests.Common; namespace XPathTests.FunctionalTests.CoreFunctionLibrary { /// <summary> /// Core Function Library - Node Set Functions /// </summary> public static partial class NodeSetFunctionsTests { /// <summary> /// Expected: Selects the last element child of the context node. /// child::*[last()] /// </summary> [Fact] public static void NodeSetFunctionsTest221() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[last()]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child5", Name = "Child5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the second last element child of the context node. /// child::*[last() - 1] /// </summary> [Fact] public static void NodeSetFunctionsTest222() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[last() - 1]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child4", Name = "Child4", HasNameTable = true, Value = "Fourth" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the last attribute node of the context node. /// attribute::*[last()] /// </summary> [Fact] public static void NodeSetFunctionsTest223() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"attribute::*[last()]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Attribute, LocalName = "Attr5", Name = "Attr5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the second last attribute node of the context node. /// attribute::*[last() - 1] /// </summary> [Fact] public static void NodeSetFunctionsTest224() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"attribute::*[last() - 1]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Attribute, LocalName = "Attr4", Name = "Attr4", HasNameTable = true, Value = "Fourth" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the last element child of the context node. /// child::*[position() = last()] /// </summary> [Fact] public static void NodeSetFunctionsTest225() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[position() = last()]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child5", Name = "Child5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[position() = last()] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest226() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child5"; var testExpression = @"*[position() = last()]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: False (based on context node). /// *[position() = last()] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest227() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child4"; var testExpression = @"*[position() = last()]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() = last()] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest228() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr5"; var testExpression = @"@*[position() = last()]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: False (based on context node). /// @*[position() = last()] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest229() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr4"; var testExpression = @"@*[position() = last()]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[last() = 1] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2210() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test2/Child1"; var testExpression = @"*[last() = 1]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[last() = 1] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2211() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child1"; var testExpression = @"*[last() = 1]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// child::*[position() = 2] /// </summary> [Fact] public static void NodeSetFunctionsTest2212() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[position() = 2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child2", Name = "Child2", HasNameTable = true, Value = "Second" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd attribute of the context node. /// attribute::*[position() = 2] /// </summary> [Fact] public static void NodeSetFunctionsTest2213() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"attribute::*[position() = 2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Attribute, LocalName = "Attr2", Name = "Attr2", HasNameTable = true, Value = "Second" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// child::*[2] /// </summary> [Fact] public static void NodeSetFunctionsTest2214() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child2", Name = "Child2", HasNameTable = true, Value = "Second" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd attribute of the context node. /// attribute::*[2] /// </summary> [Fact] public static void NodeSetFunctionsTest2215() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"attribute::*[2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Attribute, LocalName = "Attr2", Name = "Attr2", HasNameTable = true, Value = "Second" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects all element children of the context node except the first two. /// child::*[position() > 2] /// </summary> [Fact] public static void NodeSetFunctionsTest2216() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[position() > 2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child3", Name = "Child3", HasNameTable = true, Value = "Third" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child4", Name = "Child4", HasNameTable = true, Value = "Fourth" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child5", Name = "Child5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects all element children of the context node. /// child::*[position()] /// </summary> [Fact] public static void NodeSetFunctionsTest2217() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[position()]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child1", Name = "Child1", HasNameTable = true, Value = "First" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child2", Name = "Child2", HasNameTable = true, Value = "Second" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child3", Name = "Child3", HasNameTable = true, Value = "Third" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child4", Name = "Child4", HasNameTable = true, Value = "Fourth" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child5", Name = "Child5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[position() = 2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2218() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child2"; var testExpression = @"*[position() = 2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: False (based on context node). /// *[position() = 2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2219() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child3"; var testExpression = @"*[position() = 2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() = 2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2220() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr2"; var testExpression = @"@*[position() = 2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() = 2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2221() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr3"; var testExpression = @"@*[position() = 2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// *[2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2222() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child2"; var testExpression = @"*[2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// *[2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2223() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child3"; var testExpression = @"*[2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// @*[2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2224() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr2"; var testExpression = @"@*[2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// @*[2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2225() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr1"; var testExpression = @"@*[2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[position() > 2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2226() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child3"; var testExpression = @"*[position() > 2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: False (based on context node). /// *[position() > 2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2227() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child2"; var testExpression = @"*[position() > 2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() > 2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2228() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr3"; var testExpression = @"@*[position() > 2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() > 2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2229() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr2"; var testExpression = @"@*[position() > 2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Number of attribute nodes. /// count(attribute::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2230() { var xml = "xp005.xml"; var startingNodePath = "/Doc/Test1"; var testExpression = @"count(attribute::*)"; var expected = 5d; Utils.XPathNumberTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Number of attribute nodes. /// count(descendant::para) /// </summary> [Fact] public static void NodeSetFunctionsTest2231() { var xml = "xp005.xml"; var startingNodePath = "/Doc/Test1"; var testExpression = @"count(descendant::Child3)"; var expected = 1d; Utils.XPathNumberTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Namespace URI of the context node. /// namespace-uri() (element node) /// </summary> [Fact] public static void NodeSetFunctionsTest2235() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"uri:this is a test"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: Namespace URI of the context node. /// namespace-uri() (attribute node) /// </summary> [Fact] public static void NodeSetFunctionsTest2236() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem/@ns:attr"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"uri:this is a test"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: Namespace URI of the first child node of the context node. /// namespace-uri(child::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2237() { var xml = "xp008.xml"; var startingNodePath = "/Doc"; var testExpression = @"namespace-uri(child::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"uri:this is a test"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: Namespace URI of the first attribute node of the context node. /// namespace-uri(attribute::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2238() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"namespace-uri(attribute::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"uri:this is a test"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the context node. /// name() (with prefix, element node) /// </summary> [Fact] public static void NodeSetFunctionsTest2241() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"ns:elem"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the context node. /// name() (with prefix, attribute node) /// </summary> [Fact] public static void NodeSetFunctionsTest2242() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem/@ns:attr"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"ns:attr"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the first child node of the context node. /// name(child::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2243() { var xml = "xp008.xml"; var startingNodePath = "/Doc"; var testExpression = @"name(child::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"ns:elem"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the first attribute node of the context node. /// name(attribute::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2244() { var xml = "xp008.xml"; var startingNodePath = "/child::*/child::*"; var testExpression = @"name(attribute::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"ns:attr"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the context node. /// local-name() (with prefix, element node) /// </summary> [Fact] public static void NodeSetFunctionsTest2247() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"local-name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"elem"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the context node. /// local-name() (with prefix, attribute node) /// </summary> [Fact] public static void NodeSetFunctionsTest2248() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem/@ns:attr"; var testExpression = @"local-name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"attr"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: Local part of the expanded-name of the first child node of the context node. /// local-name(child::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2249() { var xml = "xp008.xml"; var startingNodePath = "/Doc"; var testExpression = @"local-name(child::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"elem"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the first attribute node of the context node. /// local-name(attribute::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2250() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"local-name(attribute::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"attr"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } #if FEATURE_XML_XPATH_ID /// <summary> /// Data file has no DTD, so no element has an ID, expected empty node-set /// id("1") /// </summary> [Fact] public static void NodeSetFunctionsTest2267() { var xml = "id4.xml"; var testExpression = @"id(""1"")"; var expected = new XPathResult(0); Utils.XPathNodesetTest(xml, testExpression, expected); } #endif /// <summary> /// Expected: empty namespace uri /// namespace-uri() (namespace node) /// </summary> [Fact] public static void NodeSetFunctionsTest2294() { var xml = "name2.xml"; var startingNodePath = "/ns:store/ns:booksection/namespace::NSbook"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// namespace-uri() (namespace node = xml) /// </summary> [Fact] public static void NodeSetFunctionsTest2295() { var xml = "name2.xml"; var startingNodePath = "/ns:store/namespace::*[1]"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// namespace-uri() (namespace node = default ns) /// </summary> [Fact] public static void NodeSetFunctionsTest2296() { var xml = "name2.xml"; var startingNodePath = "/ns:store/namespace::*[2]"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// namespace-uri() (namespace node) /// </summary> [Fact] public static void NodeSetFunctionsTest2297() { var xml = "name2.xml"; var testExpression = @"namespace-uri(ns:store/ns:booksection/namespace::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager); } /// <summary> /// Expected: empty namespace uri /// name() (namespace node) /// </summary> [Fact] public static void NodeSetFunctionsTest2298() { var xml = "name2.xml"; var startingNodePath = "/ns:store/ns:booksection/namespace::NSbook"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @"NSbook"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// name() (namespace node = xml) /// </summary> [Fact] public static void NodeSetFunctionsTest2299() { var xml = "name2.xml"; var startingNodePath = "/ns:store/namespace::*[1]"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// name() (namespace node = default ns) /// </summary> [Fact] public static void NodeSetFunctionsTest22100() { var xml = "name2.xml"; var startingNodePath = "/ns:store/namespace::*[1]"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// name() (namespace node) /// </summary> [Fact] public static void NodeSetFunctionsTest22101() { var xml = "name2.xml"; var testExpression = @"name(ns:store/ns:booksection/namespace::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @"NSbook"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager); } } }
// 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 System; using System.Xml; using System.Xml.XPath; using XPathTests.Common; namespace XPathTests.FunctionalTests.CoreFunctionLibrary { /// <summary> /// Core Function Library - Node Set Functions /// </summary> public static partial class NodeSetFunctionsTests { /// <summary> /// Expected: Selects the last element child of the context node. /// child::*[last()] /// </summary> [Fact] public static void NodeSetFunctionsTest221() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[last()]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child5", Name = "Child5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the second last element child of the context node. /// child::*[last() - 1] /// </summary> [Fact] public static void NodeSetFunctionsTest222() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[last() - 1]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child4", Name = "Child4", HasNameTable = true, Value = "Fourth" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the last attribute node of the context node. /// attribute::*[last()] /// </summary> [Fact] public static void NodeSetFunctionsTest223() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"attribute::*[last()]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Attribute, LocalName = "Attr5", Name = "Attr5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the second last attribute node of the context node. /// attribute::*[last() - 1] /// </summary> [Fact] public static void NodeSetFunctionsTest224() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"attribute::*[last() - 1]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Attribute, LocalName = "Attr4", Name = "Attr4", HasNameTable = true, Value = "Fourth" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the last element child of the context node. /// child::*[position() = last()] /// </summary> [Fact] public static void NodeSetFunctionsTest225() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[position() = last()]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child5", Name = "Child5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[position() = last()] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest226() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child5"; var testExpression = @"*[position() = last()]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: False (based on context node). /// *[position() = last()] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest227() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child4"; var testExpression = @"*[position() = last()]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() = last()] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest228() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr5"; var testExpression = @"@*[position() = last()]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: False (based on context node). /// @*[position() = last()] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest229() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr4"; var testExpression = @"@*[position() = last()]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[last() = 1] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2210() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test2/Child1"; var testExpression = @"*[last() = 1]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[last() = 1] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2211() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child1"; var testExpression = @"*[last() = 1]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// child::*[position() = 2] /// </summary> [Fact] public static void NodeSetFunctionsTest2212() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[position() = 2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child2", Name = "Child2", HasNameTable = true, Value = "Second" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd attribute of the context node. /// attribute::*[position() = 2] /// </summary> [Fact] public static void NodeSetFunctionsTest2213() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"attribute::*[position() = 2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Attribute, LocalName = "Attr2", Name = "Attr2", HasNameTable = true, Value = "Second" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// child::*[2] /// </summary> [Fact] public static void NodeSetFunctionsTest2214() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child2", Name = "Child2", HasNameTable = true, Value = "Second" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd attribute of the context node. /// attribute::*[2] /// </summary> [Fact] public static void NodeSetFunctionsTest2215() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"attribute::*[2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Attribute, LocalName = "Attr2", Name = "Attr2", HasNameTable = true, Value = "Second" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects all element children of the context node except the first two. /// child::*[position() > 2] /// </summary> [Fact] public static void NodeSetFunctionsTest2216() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[position() > 2]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child3", Name = "Child3", HasNameTable = true, Value = "Third" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child4", Name = "Child4", HasNameTable = true, Value = "Fourth" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child5", Name = "Child5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects all element children of the context node. /// child::*[position()] /// </summary> [Fact] public static void NodeSetFunctionsTest2217() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1"; var testExpression = @"child::*[position()]"; var expected = new XPathResult(0, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child1", Name = "Child1", HasNameTable = true, Value = "First" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child2", Name = "Child2", HasNameTable = true, Value = "Second" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child3", Name = "Child3", HasNameTable = true, Value = "Third" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child4", Name = "Child4", HasNameTable = true, Value = "Fourth" }, new XPathResultToken { NodeType = XPathNodeType.Element, HasChildren = true, LocalName = "Child5", Name = "Child5", HasNameTable = true, Value = "Last" }); Utils.XPathNodesetTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[position() = 2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2218() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child2"; var testExpression = @"*[position() = 2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: False (based on context node). /// *[position() = 2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2219() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child3"; var testExpression = @"*[position() = 2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() = 2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2220() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr2"; var testExpression = @"@*[position() = 2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() = 2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2221() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr3"; var testExpression = @"@*[position() = 2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// *[2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2222() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child2"; var testExpression = @"*[2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// *[2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2223() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child3"; var testExpression = @"*[2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// @*[2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2224() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr2"; var testExpression = @"@*[2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Selects the 2nd element child of the context node. /// @*[2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2225() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr1"; var testExpression = @"@*[2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// *[position() > 2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2226() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child3"; var testExpression = @"*[position() > 2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: False (based on context node). /// *[position() > 2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2227() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/Child2"; var testExpression = @"*[position() > 2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() > 2] (Matches = true) /// </summary> [Fact] public static void NodeSetFunctionsTest2228() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr3"; var testExpression = @"@*[position() > 2]"; var expected = true; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: True (based on context node). /// @*[position() > 2] (Matches = false) /// </summary> [Fact] public static void NodeSetFunctionsTest2229() { var xml = "xp005.xml"; var startingNodePath = "Doc/Test1/@Attr2"; var testExpression = @"@*[position() > 2]"; var expected = false; Utils.XPathMatchTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Number of attribute nodes. /// count(attribute::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2230() { var xml = "xp005.xml"; var startingNodePath = "/Doc/Test1"; var testExpression = @"count(attribute::*)"; var expected = 5d; Utils.XPathNumberTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Number of attribute nodes. /// count(descendant::para) /// </summary> [Fact] public static void NodeSetFunctionsTest2231() { var xml = "xp005.xml"; var startingNodePath = "/Doc/Test1"; var testExpression = @"count(descendant::Child3)"; var expected = 1d; Utils.XPathNumberTest(xml, testExpression, expected, startingNodePath: startingNodePath); } /// <summary> /// Expected: Namespace URI of the context node. /// namespace-uri() (element node) /// </summary> [Fact] public static void NodeSetFunctionsTest2235() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"uri:this is a test"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: Namespace URI of the context node. /// namespace-uri() (attribute node) /// </summary> [Fact] public static void NodeSetFunctionsTest2236() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem/@ns:attr"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"uri:this is a test"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: Namespace URI of the first child node of the context node. /// namespace-uri(child::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2237() { var xml = "xp008.xml"; var startingNodePath = "/Doc"; var testExpression = @"namespace-uri(child::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"uri:this is a test"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: Namespace URI of the first attribute node of the context node. /// namespace-uri(attribute::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2238() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"namespace-uri(attribute::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"uri:this is a test"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the context node. /// name() (with prefix, element node) /// </summary> [Fact] public static void NodeSetFunctionsTest2241() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"ns:elem"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the context node. /// name() (with prefix, attribute node) /// </summary> [Fact] public static void NodeSetFunctionsTest2242() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem/@ns:attr"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"ns:attr"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the first child node of the context node. /// name(child::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2243() { var xml = "xp008.xml"; var startingNodePath = "/Doc"; var testExpression = @"name(child::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"ns:elem"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the first attribute node of the context node. /// name(attribute::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2244() { var xml = "xp008.xml"; var startingNodePath = "/child::*/child::*"; var testExpression = @"name(attribute::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"ns:attr"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the context node. /// local-name() (with prefix, element node) /// </summary> [Fact] public static void NodeSetFunctionsTest2247() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"local-name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"elem"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the context node. /// local-name() (with prefix, attribute node) /// </summary> [Fact] public static void NodeSetFunctionsTest2248() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem/@ns:attr"; var testExpression = @"local-name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"attr"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: Local part of the expanded-name of the first child node of the context node. /// local-name(child::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2249() { var xml = "xp008.xml"; var startingNodePath = "/Doc"; var testExpression = @"local-name(child::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"elem"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: QName of the first attribute node of the context node. /// local-name(attribute::*) /// </summary> [Fact] public static void NodeSetFunctionsTest2250() { var xml = "xp008.xml"; var startingNodePath = "/Doc/ns:elem"; var testExpression = @"local-name(attribute::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "uri:this is a test"); var expected = @"attr"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } #if FEATURE_XML_XPATH_ID /// <summary> /// Data file has no DTD, so no element has an ID, expected empty node-set /// id("1") /// </summary> [Fact] public static void NodeSetFunctionsTest2267() { var xml = "id4.xml"; var testExpression = @"id(""1"")"; var expected = new XPathResult(0); Utils.XPathNodesetTest(xml, testExpression, expected); } #endif /// <summary> /// Expected: empty namespace uri /// namespace-uri() (namespace node) /// </summary> [Fact] public static void NodeSetFunctionsTest2294() { var xml = "name2.xml"; var startingNodePath = "/ns:store/ns:booksection/namespace::NSbook"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// namespace-uri() (namespace node = xml) /// </summary> [Fact] public static void NodeSetFunctionsTest2295() { var xml = "name2.xml"; var startingNodePath = "/ns:store/namespace::*[1]"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// namespace-uri() (namespace node = default ns) /// </summary> [Fact] public static void NodeSetFunctionsTest2296() { var xml = "name2.xml"; var startingNodePath = "/ns:store/namespace::*[2]"; var testExpression = @"namespace-uri()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// namespace-uri() (namespace node) /// </summary> [Fact] public static void NodeSetFunctionsTest2297() { var xml = "name2.xml"; var testExpression = @"namespace-uri(ns:store/ns:booksection/namespace::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager); } /// <summary> /// Expected: empty namespace uri /// name() (namespace node) /// </summary> [Fact] public static void NodeSetFunctionsTest2298() { var xml = "name2.xml"; var startingNodePath = "/ns:store/ns:booksection/namespace::NSbook"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @"NSbook"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// name() (namespace node = xml) /// </summary> [Fact] public static void NodeSetFunctionsTest2299() { var xml = "name2.xml"; var startingNodePath = "/ns:store/namespace::*[1]"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// name() (namespace node = default ns) /// </summary> [Fact] public static void NodeSetFunctionsTest22100() { var xml = "name2.xml"; var startingNodePath = "/ns:store/namespace::*[1]"; var testExpression = @"name()"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @""; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager, startingNodePath: startingNodePath); } /// <summary> /// Expected: empty namespace uri /// name() (namespace node) /// </summary> [Fact] public static void NodeSetFunctionsTest22101() { var xml = "name2.xml"; var testExpression = @"name(ns:store/ns:booksection/namespace::*)"; var namespaceManager = new XmlNamespaceManager(new NameTable()); namespaceManager.AddNamespace("ns", "http://default.htm"); var expected = @"NSbook"; Utils.XPathStringTest(xml, testExpression, expected, namespaceManager: namespaceManager); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/coreclr/tools/r2rtest/Linux.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.Diagnostics; using System.IO; using System.Runtime.InteropServices; namespace R2RTest { internal static class Linux { [Flags] private enum Permissions : byte { Read = 1, Write = 2, Execute = 4, ReadExecute = Read | Execute, ReadWriteExecute = Read | Write | Execute, } private enum PermissionGroupShift : int { Owner = 6, Group = 3, Other = 0, } [DllImport("libc", SetLastError = true)] private static extern int chmod(string path, int flags); public static void MakeExecutable(string path) { int errno = chmod(path, ((byte)Permissions.ReadWriteExecute << (int)PermissionGroupShift.Owner) | ((byte)Permissions.ReadExecute << (int)PermissionGroupShift.Group) | ((byte)Permissions.ReadExecute << (int)PermissionGroupShift.Other)); if (errno != 0) { throw new Exception($@"Failed to set permissions on {path}: error code {errno}"); } } } }
// 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.Diagnostics; using System.IO; using System.Runtime.InteropServices; namespace R2RTest { internal static class Linux { [Flags] private enum Permissions : byte { Read = 1, Write = 2, Execute = 4, ReadExecute = Read | Execute, ReadWriteExecute = Read | Write | Execute, } private enum PermissionGroupShift : int { Owner = 6, Group = 3, Other = 0, } [DllImport("libc", SetLastError = true)] private static extern int chmod(string path, int flags); public static void MakeExecutable(string path) { int errno = chmod(path, ((byte)Permissions.ReadWriteExecute << (int)PermissionGroupShift.Owner) | ((byte)Permissions.ReadExecute << (int)PermissionGroupShift.Group) | ((byte)Permissions.ReadExecute << (int)PermissionGroupShift.Other)); if (errno != 0) { throw new Exception($@"Failed to set permissions on {path}: error code {errno}"); } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/General/Vector128_1/Zero.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\General\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 ZeroSingle() { var test = new VectorZero__ZeroSingle(); // Validates basic functionality works test.RunBasicScenario(); // Validates calling via reflection works test.RunReflectionScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorZero__ZeroSingle { private static readonly int LargestVectorSize = 16; private static readonly int ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); public bool Succeeded { get; set; } = true; public void RunBasicScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); Vector128<Single> result = Vector128<Single>.Zero; ValidateResult(result); } public void RunReflectionScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario)); object result = typeof(Vector128<Single>) .GetProperty(nameof(Vector128<Single>.Zero), new Type[] { }) .GetGetMethod() .Invoke(null, new object[] { }); ValidateResult((Vector128<Single>)(result)); } private void ValidateResult(Vector128<Single> result, [CallerMemberName] string method = "") { Single[] resultElements = new Single[ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref resultElements[0]), result); ValidateResult(resultElements, method); } private void ValidateResult(Single[] resultElements, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < ElementCount; i++) { if (resultElements[i] != 0) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"Vector128.Zero(Single): {method} failed:"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})"); 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\General\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 ZeroSingle() { var test = new VectorZero__ZeroSingle(); // Validates basic functionality works test.RunBasicScenario(); // Validates calling via reflection works test.RunReflectionScenario(); if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class VectorZero__ZeroSingle { private static readonly int LargestVectorSize = 16; private static readonly int ElementCount = Unsafe.SizeOf<Vector128<Single>>() / sizeof(Single); public bool Succeeded { get; set; } = true; public void RunBasicScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); Vector128<Single> result = Vector128<Single>.Zero; ValidateResult(result); } public void RunReflectionScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario)); object result = typeof(Vector128<Single>) .GetProperty(nameof(Vector128<Single>.Zero), new Type[] { }) .GetGetMethod() .Invoke(null, new object[] { }); ValidateResult((Vector128<Single>)(result)); } private void ValidateResult(Vector128<Single> result, [CallerMemberName] string method = "") { Single[] resultElements = new Single[ElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Single, byte>(ref resultElements[0]), result); ValidateResult(resultElements, method); } private void ValidateResult(Single[] resultElements, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < ElementCount; i++) { if (resultElements[i] != 0) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"Vector128.Zero(Single): {method} failed:"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/SubtractWideningLower.Vector128.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.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 SubtractWideningLower_Vector128_Int64() { var test = new SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64(); 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__SubtractWideningLower_Vector128_Int64 { 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(Int64[] inArray1, Int32[] inArray2, Int64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int32>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>(); 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<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int32, 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<Int64> _fld1; public Vector64<Int32> _fld2; 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>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref testStruct._fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64 testClass) { var result = AdvSimd.SubtractWideningLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64 testClass) { fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector64<Int32>* pFld2 = &_fld2) { var result = AdvSimd.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector64((Int32*)(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<Int64>>() / sizeof(Int64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static Int64[] _data1 = new Int64[Op1ElementCount]; private static Int32[] _data2 = new Int32[Op2ElementCount]; private static Vector128<Int64> _clsVar1; private static Vector64<Int32> _clsVar2; private Vector128<Int64> _fld1; private Vector64<Int32> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64() { 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>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); } public SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64() { 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 < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } _dataTable = new DataTable(_data1, _data2, new Int64[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.SubtractWideningLower( Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Int32>>(_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.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((Int32*)(_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).GetMethod(nameof(AdvSimd.SubtractWideningLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector64<Int32>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Int32>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractWideningLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector64<Int32>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((Int32*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SubtractWideningLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int64>* pClsVar1 = &_clsVar1) fixed (Vector64<Int32>* pClsVar2 = &_clsVar2) { var result = AdvSimd.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(pClsVar1)), AdvSimd.LoadVector64((Int32*)(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<Int64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Int32>>(_dataTable.inArray2Ptr); var result = AdvSimd.SubtractWideningLower(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((Int64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector64((Int32*)(_dataTable.inArray2Ptr)); var result = AdvSimd.SubtractWideningLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64(); var result = AdvSimd.SubtractWideningLower(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__SubtractWideningLower_Vector128_Int64(); fixed (Vector128<Int64>* pFld1 = &test._fld1) fixed (Vector64<Int32>* pFld2 = &test._fld2) { var result = AdvSimd.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector64((Int32*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SubtractWideningLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector64<Int32>* pFld2 = &_fld2) { var result = AdvSimd.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector64((Int32*)(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.SubtractWideningLower(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.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(&test._fld1)), AdvSimd.LoadVector64((Int32*)(&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<Int64> op1, Vector64<Int32> op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int32[] inArray2 = new Int32[Op2ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int32[] inArray2 = new Int32[Op2ElementCount]; 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<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Int32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int64[] left, Int32[] right, Int64[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SubtractWidening(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SubtractWideningLower)}<Int64>(Vector128<Int64>, Vector64<Int32>): {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 SubtractWideningLower_Vector128_Int64() { var test = new SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64(); 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__SubtractWideningLower_Vector128_Int64 { 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(Int64[] inArray1, Int32[] inArray2, Int64[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int32>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int64>(); 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<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int32, 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<Int64> _fld1; public Vector64<Int32> _fld2; 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>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref testStruct._fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64 testClass) { var result = AdvSimd.SubtractWideningLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64 testClass) { fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector64<Int32>* pFld2 = &_fld2) { var result = AdvSimd.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector64((Int32*)(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<Int64>>() / sizeof(Int64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static Int64[] _data1 = new Int64[Op1ElementCount]; private static Int32[] _data2 = new Int32[Op2ElementCount]; private static Vector128<Int64> _clsVar1; private static Vector64<Int32> _clsVar2; private Vector128<Int64> _fld1; private Vector64<Int32> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64() { 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>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); } public SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64() { 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 < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Int32>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } _dataTable = new DataTable(_data1, _data2, new Int64[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.SubtractWideningLower( Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Int32>>(_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.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((Int32*)(_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).GetMethod(nameof(AdvSimd.SubtractWideningLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector64<Int32>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Int32>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractWideningLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector64<Int32>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((Int32*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int64>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SubtractWideningLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int64>* pClsVar1 = &_clsVar1) fixed (Vector64<Int32>* pClsVar2 = &_clsVar2) { var result = AdvSimd.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(pClsVar1)), AdvSimd.LoadVector64((Int32*)(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<Int64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Int32>>(_dataTable.inArray2Ptr); var result = AdvSimd.SubtractWideningLower(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((Int64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector64((Int32*)(_dataTable.inArray2Ptr)); var result = AdvSimd.SubtractWideningLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__SubtractWideningLower_Vector128_Int64(); var result = AdvSimd.SubtractWideningLower(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__SubtractWideningLower_Vector128_Int64(); fixed (Vector128<Int64>* pFld1 = &test._fld1) fixed (Vector64<Int32>* pFld2 = &test._fld2) { var result = AdvSimd.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector64((Int32*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SubtractWideningLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector64<Int32>* pFld2 = &_fld2) { var result = AdvSimd.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector64((Int32*)(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.SubtractWideningLower(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.SubtractWideningLower( AdvSimd.LoadVector128((Int64*)(&test._fld1)), AdvSimd.LoadVector64((Int32*)(&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<Int64> op1, Vector64<Int32> op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int32[] inArray2 = new Int32[Op2ElementCount]; Int64[] outArray = new Int64[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int32[] inArray2 = new Int32[Op2ElementCount]; 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<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Int32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int64>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int64[] left, Int32[] right, Int64[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SubtractWidening(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SubtractWideningLower)}<Int64>(Vector128<Int64>, Vector64<Int32>): {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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.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; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void CompareEqualUInt32() { var test = new SimpleBinaryOpTest__CompareEqualUInt32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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__CompareEqualUInt32 { 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 * 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 Vector128<UInt32> _fld1; public Vector128<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<Vector128<UInt32>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualUInt32 testClass) { var result = Sse2.CompareEqual(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__CompareEqualUInt32 testClass) { fixed (Vector128<UInt32>* pFld1 = &_fld1) fixed (Vector128<UInt32>* pFld2 = &_fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(pFld1)), Sse2.LoadVector128((UInt32*)(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<UInt32>>() / sizeof(UInt32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static UInt32[] _data1 = new UInt32[Op1ElementCount]; private static UInt32[] _data2 = new UInt32[Op2ElementCount]; private static Vector128<UInt32> _clsVar1; private static Vector128<UInt32> _clsVar2; private Vector128<UInt32> _fld1; private Vector128<UInt32> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__CompareEqualUInt32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); } public SimpleBinaryOpTest__CompareEqualUInt32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<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 IsSupported => Sse2.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Sse2.CompareEqual( Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt32>>(_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 = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((UInt32*)(_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 = Sse2.CompareEqual( Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((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 result = typeof(Sse2).GetMethod(nameof(Sse2.CompareEqual), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Sse2).GetMethod(nameof(Sse2.CompareEqual), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Sse2).GetMethod(nameof(Sse2.CompareEqual), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Sse2.CompareEqual( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<UInt32>* pClsVar1 = &_clsVar1) fixed (Vector128<UInt32>* pClsVar2 = &_clsVar2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(pClsVar1)), Sse2.LoadVector128((UInt32*)(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<UInt32>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr); var result = Sse2.CompareEqual(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); var result = Sse2.CompareEqual(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var op1 = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); var result = Sse2.CompareEqual(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__CompareEqualUInt32(); var result = Sse2.CompareEqual(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__CompareEqualUInt32(); fixed (Vector128<UInt32>* pFld1 = &test._fld1) fixed (Vector128<UInt32>* pFld2 = &test._fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(pFld1)), Sse2.LoadVector128((UInt32*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Sse2.CompareEqual(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<UInt32>* pFld1 = &_fld1) fixed (Vector128<UInt32>* pFld2 = &_fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(pFld1)), Sse2.LoadVector128((UInt32*)(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 = Sse2.CompareEqual(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 = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(&test._fld1)), Sse2.LoadVector128((UInt32*)(&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<UInt32> op1, Vector128<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<Vector128<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<Vector128<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<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]) ? unchecked((uint)(-1)) : 0)) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt32>(Vector128<UInt32>, Vector128<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; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void CompareEqualUInt32() { var test = new SimpleBinaryOpTest__CompareEqualUInt32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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 (Sse2.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__CompareEqualUInt32 { 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 * 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 Vector128<UInt32> _fld1; public Vector128<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<Vector128<UInt32>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualUInt32 testClass) { var result = Sse2.CompareEqual(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__CompareEqualUInt32 testClass) { fixed (Vector128<UInt32>* pFld1 = &_fld1) fixed (Vector128<UInt32>* pFld2 = &_fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(pFld1)), Sse2.LoadVector128((UInt32*)(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<UInt32>>() / sizeof(UInt32); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt32>>() / sizeof(UInt32); private static UInt32[] _data1 = new UInt32[Op1ElementCount]; private static UInt32[] _data2 = new UInt32[Op2ElementCount]; private static Vector128<UInt32> _clsVar1; private static Vector128<UInt32> _clsVar2; private Vector128<UInt32> _fld1; private Vector128<UInt32> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__CompareEqualUInt32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); } public SimpleBinaryOpTest__CompareEqualUInt32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<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 IsSupported => Sse2.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Sse2.CompareEqual( Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt32>>(_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 = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((UInt32*)(_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 = Sse2.CompareEqual( Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((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 result = typeof(Sse2).GetMethod(nameof(Sse2.CompareEqual), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Sse2).GetMethod(nameof(Sse2.CompareEqual), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Sse2).GetMethod(nameof(Sse2.CompareEqual), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Sse2.CompareEqual( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<UInt32>* pClsVar1 = &_clsVar1) fixed (Vector128<UInt32>* pClsVar2 = &_clsVar2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(pClsVar1)), Sse2.LoadVector128((UInt32*)(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<UInt32>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr); var result = Sse2.CompareEqual(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var op1 = Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); var result = Sse2.CompareEqual(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var op1 = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)); var op2 = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); var result = Sse2.CompareEqual(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__CompareEqualUInt32(); var result = Sse2.CompareEqual(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__CompareEqualUInt32(); fixed (Vector128<UInt32>* pFld1 = &test._fld1) fixed (Vector128<UInt32>* pFld2 = &test._fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(pFld1)), Sse2.LoadVector128((UInt32*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Sse2.CompareEqual(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<UInt32>* pFld1 = &_fld1) fixed (Vector128<UInt32>* pFld2 = &_fld2) { var result = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(pFld1)), Sse2.LoadVector128((UInt32*)(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 = Sse2.CompareEqual(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 = Sse2.CompareEqual( Sse2.LoadVector128((UInt32*)(&test._fld1)), Sse2.LoadVector128((UInt32*)(&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<UInt32> op1, Vector128<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<Vector128<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<Vector128<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<UInt32>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<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]) ? unchecked((uint)(-1)) : 0)) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt32>(Vector128<UInt32>, Vector128<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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Collections.Immutable/tests/ImmutableDictionaryBuilderTestBase.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.Collections.Immutable.Tests { public abstract partial class ImmutableDictionaryBuilderTestBase : ImmutablesTestBase { [Fact] public void Add() { var builder = this.GetBuilder<string, int>(); builder.Add("five", 5); builder.Add(new KeyValuePair<string, int>("six", 6)); Assert.Equal(5, builder["five"]); Assert.Equal(6, builder["six"]); Assert.False(builder.ContainsKey("four")); } /// <summary> /// Verifies that "adding" an entry to the dictionary that already exists /// with exactly the same key and value will *not* throw an exception. /// </summary> /// <remarks> /// The BCL Dictionary type would throw in this circumstance. /// But in an immutable world, not only do we not care so much since the result is the same. /// </remarks> [Fact] public void AddExactDuplicate() { var builder = this.GetBuilder<string, int>(); builder.Add("five", 5); builder.Add("five", 5); Assert.Equal(1, builder.Count); } [Fact] public void AddExistingKeyWithDifferentValue() { var builder = this.GetBuilder<string, int>(); builder.Add("five", 5); AssertExtensions.Throws<ArgumentException>(null, () => builder.Add("five", 6)); } [Fact] public void Indexer() { var builder = this.GetBuilder<string, int>(); // Set and set again. builder["five"] = 5; Assert.Equal(5, builder["five"]); builder["five"] = 5; Assert.Equal(5, builder["five"]); // Set to a new value. builder["five"] = 50; Assert.Equal(50, builder["five"]); // Retrieve an invalid value. Assert.Throws<KeyNotFoundException>(() => builder["foo"]); } [Fact] public void ContainsPair() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5); var builder = this.GetBuilder(map); Assert.True(builder.Contains(new KeyValuePair<string, int>("five", 5))); } [Fact] public void RemovePair() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); Assert.True(builder.Remove(new KeyValuePair<string, int>("five", 5))); Assert.False(builder.Remove(new KeyValuePair<string, int>("foo", 1))); Assert.Equal(1, builder.Count); Assert.Equal(6, builder["six"]); } [Fact] public void RemoveKey() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); builder.Remove("five"); Assert.Equal(1, builder.Count); Assert.Equal(6, builder["six"]); } [Fact] public void CopyTo() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5); var builder = this.GetBuilder(map); var array = new KeyValuePair<string, int>[2]; // intentionally larger than source. builder.CopyTo(array, 1); Assert.Equal(new KeyValuePair<string, int>(), array[0]); Assert.Equal(new KeyValuePair<string, int>("five", 5), array[1]); AssertExtensions.Throws<ArgumentNullException>("array", () => builder.CopyTo(null, 0)); } [Fact] public void IsReadOnly() { var builder = this.GetBuilder<string, int>(); Assert.False(builder.IsReadOnly); } [Fact] public void Keys() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); CollectionAssertAreEquivalent(new[] { "five", "six" }, builder.Keys); CollectionAssertAreEquivalent(new[] { "five", "six" }, ((IReadOnlyDictionary<string, int>)builder).Keys.ToArray()); } [Fact] public void Values() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); CollectionAssertAreEquivalent(new[] { 5, 6 }, builder.Values); CollectionAssertAreEquivalent(new[] { 5, 6 }, ((IReadOnlyDictionary<string, int>)builder).Values.ToArray()); } [Fact] public void TryGetValue() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); int value; Assert.True(builder.TryGetValue("five", out value) && value == 5); Assert.True(builder.TryGetValue("six", out value) && value == 6); Assert.False(builder.TryGetValue("four", out value)); Assert.Equal(0, value); } [Fact] public void EnumerateTest() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); using (var enumerator = builder.GetEnumerator()) { Assert.True(enumerator.MoveNext()); Assert.True(enumerator.MoveNext()); Assert.False(enumerator.MoveNext()); } var manualEnum = builder.GetEnumerator(); Assert.Throws<InvalidOperationException>(() => manualEnum.Current); while (manualEnum.MoveNext()) { } Assert.False(manualEnum.MoveNext()); Assert.Throws<InvalidOperationException>(() => manualEnum.Current); } [Fact] public void IDictionaryMembers() { var builder = this.GetBuilder<string, int>(); var dictionary = (IDictionary)builder; dictionary.Add("a", 1); Assert.True(dictionary.Contains("a")); Assert.Equal(1, dictionary["a"]); Assert.Equal(new[] { "a" }, dictionary.Keys.Cast<string>().ToArray()); Assert.Equal(new[] { 1 }, dictionary.Values.Cast<int>().ToArray()); dictionary["a"] = 2; Assert.Equal(2, dictionary["a"]); dictionary.Remove("a"); Assert.False(dictionary.Contains("a")); Assert.False(dictionary.IsFixedSize); Assert.False(dictionary.IsReadOnly); } [Fact] public void IDictionaryEnumerator() { var builder = this.GetBuilder<string, int>(); var dictionary = (IDictionary)builder; dictionary.Add("a", 1); var enumerator = dictionary.GetEnumerator(); Assert.Throws<InvalidOperationException>(() => enumerator.Current); Assert.Throws<InvalidOperationException>(() => enumerator.Key); Assert.Throws<InvalidOperationException>(() => enumerator.Value); Assert.Throws<InvalidOperationException>(() => enumerator.Entry); Assert.True(enumerator.MoveNext()); Assert.Equal(enumerator.Entry, enumerator.Current); Assert.Equal(enumerator.Key, enumerator.Entry.Key); Assert.Equal(enumerator.Value, enumerator.Entry.Value); Assert.Equal("a", enumerator.Key); Assert.Equal(1, enumerator.Value); Assert.False(enumerator.MoveNext()); Assert.Throws<InvalidOperationException>(() => enumerator.Current); Assert.Throws<InvalidOperationException>(() => enumerator.Key); Assert.Throws<InvalidOperationException>(() => enumerator.Value); Assert.Throws<InvalidOperationException>(() => enumerator.Entry); Assert.False(enumerator.MoveNext()); enumerator.Reset(); Assert.Throws<InvalidOperationException>(() => enumerator.Current); Assert.Throws<InvalidOperationException>(() => enumerator.Key); Assert.Throws<InvalidOperationException>(() => enumerator.Value); Assert.Throws<InvalidOperationException>(() => enumerator.Entry); Assert.True(enumerator.MoveNext()); Assert.Equal(enumerator.Key, ((DictionaryEntry)enumerator.Current).Key); Assert.Equal(enumerator.Value, ((DictionaryEntry)enumerator.Current).Value); Assert.Equal("a", enumerator.Key); Assert.Equal(1, enumerator.Value); Assert.False(enumerator.MoveNext()); Assert.Throws<InvalidOperationException>(() => enumerator.Current); Assert.Throws<InvalidOperationException>(() => enumerator.Key); Assert.Throws<InvalidOperationException>(() => enumerator.Value); Assert.Throws<InvalidOperationException>(() => enumerator.Entry); Assert.False(enumerator.MoveNext()); } [Fact] public void ICollectionMembers() { var builder = this.GetBuilder<string, int>(); var collection = (ICollection)builder; collection.CopyTo(new object[0], 0); builder.Add("b", 2); Assert.True(builder.ContainsKey("b")); var array = new object[builder.Count + 1]; collection.CopyTo(array, 1); Assert.Null(array[0]); Assert.Equal(new object[] { null, new DictionaryEntry("b", 2), }, array); Assert.False(collection.IsSynchronized); Assert.NotNull(collection.SyncRoot); Assert.Same(collection.SyncRoot, collection.SyncRoot); } protected abstract bool TryGetKeyHelper<TKey, TValue>(IDictionary<TKey, TValue> dictionary, TKey equalKey, out TKey actualKey); /// <summary> /// Gets the Builder for a given dictionary instance. /// </summary> /// <typeparam name="TKey">The type of key.</typeparam> /// <typeparam name="TValue">The type of value.</typeparam> /// <returns>The builder.</returns> protected abstract IDictionary<TKey, TValue> GetBuilder<TKey, TValue>(IImmutableDictionary<TKey, TValue> basis = null); /// <summary> /// Gets an empty immutable dictionary. /// </summary> /// <typeparam name="TKey">The type of key.</typeparam> /// <typeparam name="TValue">The type of value.</typeparam> /// <returns>The immutable dictionary.</returns> protected abstract IImmutableDictionary<TKey, TValue> GetEmptyImmutableDictionary<TKey, TValue>(); protected abstract IImmutableDictionary<string, TValue> Empty<TValue>(StringComparer comparer); } }
// 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.Collections.Immutable.Tests { public abstract partial class ImmutableDictionaryBuilderTestBase : ImmutablesTestBase { [Fact] public void Add() { var builder = this.GetBuilder<string, int>(); builder.Add("five", 5); builder.Add(new KeyValuePair<string, int>("six", 6)); Assert.Equal(5, builder["five"]); Assert.Equal(6, builder["six"]); Assert.False(builder.ContainsKey("four")); } /// <summary> /// Verifies that "adding" an entry to the dictionary that already exists /// with exactly the same key and value will *not* throw an exception. /// </summary> /// <remarks> /// The BCL Dictionary type would throw in this circumstance. /// But in an immutable world, not only do we not care so much since the result is the same. /// </remarks> [Fact] public void AddExactDuplicate() { var builder = this.GetBuilder<string, int>(); builder.Add("five", 5); builder.Add("five", 5); Assert.Equal(1, builder.Count); } [Fact] public void AddExistingKeyWithDifferentValue() { var builder = this.GetBuilder<string, int>(); builder.Add("five", 5); AssertExtensions.Throws<ArgumentException>(null, () => builder.Add("five", 6)); } [Fact] public void Indexer() { var builder = this.GetBuilder<string, int>(); // Set and set again. builder["five"] = 5; Assert.Equal(5, builder["five"]); builder["five"] = 5; Assert.Equal(5, builder["five"]); // Set to a new value. builder["five"] = 50; Assert.Equal(50, builder["five"]); // Retrieve an invalid value. Assert.Throws<KeyNotFoundException>(() => builder["foo"]); } [Fact] public void ContainsPair() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5); var builder = this.GetBuilder(map); Assert.True(builder.Contains(new KeyValuePair<string, int>("five", 5))); } [Fact] public void RemovePair() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); Assert.True(builder.Remove(new KeyValuePair<string, int>("five", 5))); Assert.False(builder.Remove(new KeyValuePair<string, int>("foo", 1))); Assert.Equal(1, builder.Count); Assert.Equal(6, builder["six"]); } [Fact] public void RemoveKey() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); builder.Remove("five"); Assert.Equal(1, builder.Count); Assert.Equal(6, builder["six"]); } [Fact] public void CopyTo() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5); var builder = this.GetBuilder(map); var array = new KeyValuePair<string, int>[2]; // intentionally larger than source. builder.CopyTo(array, 1); Assert.Equal(new KeyValuePair<string, int>(), array[0]); Assert.Equal(new KeyValuePair<string, int>("five", 5), array[1]); AssertExtensions.Throws<ArgumentNullException>("array", () => builder.CopyTo(null, 0)); } [Fact] public void IsReadOnly() { var builder = this.GetBuilder<string, int>(); Assert.False(builder.IsReadOnly); } [Fact] public void Keys() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); CollectionAssertAreEquivalent(new[] { "five", "six" }, builder.Keys); CollectionAssertAreEquivalent(new[] { "five", "six" }, ((IReadOnlyDictionary<string, int>)builder).Keys.ToArray()); } [Fact] public void Values() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); CollectionAssertAreEquivalent(new[] { 5, 6 }, builder.Values); CollectionAssertAreEquivalent(new[] { 5, 6 }, ((IReadOnlyDictionary<string, int>)builder).Values.ToArray()); } [Fact] public void TryGetValue() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); int value; Assert.True(builder.TryGetValue("five", out value) && value == 5); Assert.True(builder.TryGetValue("six", out value) && value == 6); Assert.False(builder.TryGetValue("four", out value)); Assert.Equal(0, value); } [Fact] public void EnumerateTest() { var map = this.GetEmptyImmutableDictionary<string, int>().Add("five", 5).Add("six", 6); var builder = this.GetBuilder(map); using (var enumerator = builder.GetEnumerator()) { Assert.True(enumerator.MoveNext()); Assert.True(enumerator.MoveNext()); Assert.False(enumerator.MoveNext()); } var manualEnum = builder.GetEnumerator(); Assert.Throws<InvalidOperationException>(() => manualEnum.Current); while (manualEnum.MoveNext()) { } Assert.False(manualEnum.MoveNext()); Assert.Throws<InvalidOperationException>(() => manualEnum.Current); } [Fact] public void IDictionaryMembers() { var builder = this.GetBuilder<string, int>(); var dictionary = (IDictionary)builder; dictionary.Add("a", 1); Assert.True(dictionary.Contains("a")); Assert.Equal(1, dictionary["a"]); Assert.Equal(new[] { "a" }, dictionary.Keys.Cast<string>().ToArray()); Assert.Equal(new[] { 1 }, dictionary.Values.Cast<int>().ToArray()); dictionary["a"] = 2; Assert.Equal(2, dictionary["a"]); dictionary.Remove("a"); Assert.False(dictionary.Contains("a")); Assert.False(dictionary.IsFixedSize); Assert.False(dictionary.IsReadOnly); } [Fact] public void IDictionaryEnumerator() { var builder = this.GetBuilder<string, int>(); var dictionary = (IDictionary)builder; dictionary.Add("a", 1); var enumerator = dictionary.GetEnumerator(); Assert.Throws<InvalidOperationException>(() => enumerator.Current); Assert.Throws<InvalidOperationException>(() => enumerator.Key); Assert.Throws<InvalidOperationException>(() => enumerator.Value); Assert.Throws<InvalidOperationException>(() => enumerator.Entry); Assert.True(enumerator.MoveNext()); Assert.Equal(enumerator.Entry, enumerator.Current); Assert.Equal(enumerator.Key, enumerator.Entry.Key); Assert.Equal(enumerator.Value, enumerator.Entry.Value); Assert.Equal("a", enumerator.Key); Assert.Equal(1, enumerator.Value); Assert.False(enumerator.MoveNext()); Assert.Throws<InvalidOperationException>(() => enumerator.Current); Assert.Throws<InvalidOperationException>(() => enumerator.Key); Assert.Throws<InvalidOperationException>(() => enumerator.Value); Assert.Throws<InvalidOperationException>(() => enumerator.Entry); Assert.False(enumerator.MoveNext()); enumerator.Reset(); Assert.Throws<InvalidOperationException>(() => enumerator.Current); Assert.Throws<InvalidOperationException>(() => enumerator.Key); Assert.Throws<InvalidOperationException>(() => enumerator.Value); Assert.Throws<InvalidOperationException>(() => enumerator.Entry); Assert.True(enumerator.MoveNext()); Assert.Equal(enumerator.Key, ((DictionaryEntry)enumerator.Current).Key); Assert.Equal(enumerator.Value, ((DictionaryEntry)enumerator.Current).Value); Assert.Equal("a", enumerator.Key); Assert.Equal(1, enumerator.Value); Assert.False(enumerator.MoveNext()); Assert.Throws<InvalidOperationException>(() => enumerator.Current); Assert.Throws<InvalidOperationException>(() => enumerator.Key); Assert.Throws<InvalidOperationException>(() => enumerator.Value); Assert.Throws<InvalidOperationException>(() => enumerator.Entry); Assert.False(enumerator.MoveNext()); } [Fact] public void ICollectionMembers() { var builder = this.GetBuilder<string, int>(); var collection = (ICollection)builder; collection.CopyTo(new object[0], 0); builder.Add("b", 2); Assert.True(builder.ContainsKey("b")); var array = new object[builder.Count + 1]; collection.CopyTo(array, 1); Assert.Null(array[0]); Assert.Equal(new object[] { null, new DictionaryEntry("b", 2), }, array); Assert.False(collection.IsSynchronized); Assert.NotNull(collection.SyncRoot); Assert.Same(collection.SyncRoot, collection.SyncRoot); } protected abstract bool TryGetKeyHelper<TKey, TValue>(IDictionary<TKey, TValue> dictionary, TKey equalKey, out TKey actualKey); /// <summary> /// Gets the Builder for a given dictionary instance. /// </summary> /// <typeparam name="TKey">The type of key.</typeparam> /// <typeparam name="TValue">The type of value.</typeparam> /// <returns>The builder.</returns> protected abstract IDictionary<TKey, TValue> GetBuilder<TKey, TValue>(IImmutableDictionary<TKey, TValue> basis = null); /// <summary> /// Gets an empty immutable dictionary. /// </summary> /// <typeparam name="TKey">The type of key.</typeparam> /// <typeparam name="TValue">The type of value.</typeparam> /// <returns>The immutable dictionary.</returns> protected abstract IImmutableDictionary<TKey, TValue> GetEmptyImmutableDictionary<TKey, TValue>(); protected abstract IImmutableDictionary<string, TValue> Empty<TValue>(StringComparer comparer); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Private.Xml/src/System/Xml/Schema/Chameleonkey.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; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Xml.Serialization; namespace System.Xml.Schema { // Case insensitive file name key for use in a hashtable. internal sealed class ChameleonKey { internal string targetNS; internal Uri chameleonLocation; // Original schema (used for reference equality only) // stored only when the chameleonLocation is an empty URI in which case the location // is not a good enough identification of the schema internal XmlSchema? originalSchema; private int _hashCode; /// <summary> /// Creates a new chameleon key - an identification for a chameleon schema instance /// </summary> /// <param name="ns">The target namespace of the instance of the chameleon schema</param> /// <param name="originalSchema">The original (chameleon) schema (the one without the target namespace). /// This is used to get the location (base uri) and to identify the schema.</param> public ChameleonKey(string ns, XmlSchema originalSchema) { targetNS = ns; chameleonLocation = originalSchema.BaseUri!; if (chameleonLocation.OriginalString.Length == 0) { // Only store the original schema when the location is empty URI // by doing this we effectively allow multiple chameleon schemas for the same target namespace // and URI, but that only makes sense for empty URI (not specified) this.originalSchema = originalSchema; } } public override int GetHashCode() { if (_hashCode == 0) { _hashCode = unchecked(targetNS.GetHashCode() + chameleonLocation.GetHashCode() + (originalSchema == null ? 0 : originalSchema.GetHashCode())); } return _hashCode; } public override bool Equals([NotNullWhen(true)] object? obj) { if (Ref.ReferenceEquals(this, obj)) { return true; } ChameleonKey? cKey = obj as ChameleonKey; if (cKey != null) { // We want to compare the target NS and the schema location. // If the location is empty (but only then) we also want to compare the original schema instance. // As noted above the originalSchema is null if the chameleonLocation is non-empty. As a result we // can simply compare the reference to the original schema always (regardless of the schemalocation). Debug.Assert((chameleonLocation.OriginalString.Length == 0 && originalSchema != null) || (chameleonLocation.OriginalString.Length != 0 && originalSchema == null)); return this.targetNS.Equals(cKey.targetNS) && this.chameleonLocation.Equals(cKey.chameleonLocation) && Ref.ReferenceEquals(originalSchema, cKey.originalSchema); } return false; } } }
// 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; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Xml.Serialization; namespace System.Xml.Schema { // Case insensitive file name key for use in a hashtable. internal sealed class ChameleonKey { internal string targetNS; internal Uri chameleonLocation; // Original schema (used for reference equality only) // stored only when the chameleonLocation is an empty URI in which case the location // is not a good enough identification of the schema internal XmlSchema? originalSchema; private int _hashCode; /// <summary> /// Creates a new chameleon key - an identification for a chameleon schema instance /// </summary> /// <param name="ns">The target namespace of the instance of the chameleon schema</param> /// <param name="originalSchema">The original (chameleon) schema (the one without the target namespace). /// This is used to get the location (base uri) and to identify the schema.</param> public ChameleonKey(string ns, XmlSchema originalSchema) { targetNS = ns; chameleonLocation = originalSchema.BaseUri!; if (chameleonLocation.OriginalString.Length == 0) { // Only store the original schema when the location is empty URI // by doing this we effectively allow multiple chameleon schemas for the same target namespace // and URI, but that only makes sense for empty URI (not specified) this.originalSchema = originalSchema; } } public override int GetHashCode() { if (_hashCode == 0) { _hashCode = unchecked(targetNS.GetHashCode() + chameleonLocation.GetHashCode() + (originalSchema == null ? 0 : originalSchema.GetHashCode())); } return _hashCode; } public override bool Equals([NotNullWhen(true)] object? obj) { if (Ref.ReferenceEquals(this, obj)) { return true; } ChameleonKey? cKey = obj as ChameleonKey; if (cKey != null) { // We want to compare the target NS and the schema location. // If the location is empty (but only then) we also want to compare the original schema instance. // As noted above the originalSchema is null if the chameleonLocation is non-empty. As a result we // can simply compare the reference to the original schema always (regardless of the schemalocation). Debug.Assert((chameleonLocation.OriginalString.Length == 0 && originalSchema != null) || (chameleonLocation.OriginalString.Length != 0 && originalSchema == null)); return this.targetNS.Equals(cKey.targetNS) && this.chameleonLocation.Equals(cKey.chameleonLocation) && Ref.ReferenceEquals(originalSchema, cKey.originalSchema); } return false; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/Loader/classloader/regressions/245191/nullenum1000.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; using System.Collections.Generic; using System.IO; using System.Runtime.CompilerServices; using System.Threading; public enum T0 { } public enum T1 { } public enum T2 { } public enum T3 { } public enum T4 { } public enum T5 { } public enum T6 { } public enum T7 { } public enum T8 { } public enum T9 { } public enum T10 { } public enum T11 { } public enum T12 { } public enum T13 { } public enum T14 { } public enum T15 { } public enum T16 { } public enum T17 { } public enum T18 { } public enum T19 { } public enum T20 { } public enum T21 { } public enum T22 { } public enum T23 { } public enum T24 { } public enum T25 { } public enum T26 { } public enum T27 { } public enum T28 { } public enum T29 { } public enum T30 { } public enum T31 { } public enum T32 { } public enum T33 { } public enum T34 { } public enum T35 { } public enum T36 { } public enum T37 { } public enum T38 { } public enum T39 { } public enum T40 { } public enum T41 { } public enum T42 { } public enum T43 { } public enum T44 { } public enum T45 { } public enum T46 { } public enum T47 { } public enum T48 { } public enum T49 { } public enum T50 { } public enum T51 { } public enum T52 { } public enum T53 { } public enum T54 { } public enum T55 { } public enum T56 { } public enum T57 { } public enum T58 { } public enum T59 { } public enum T60 { } public enum T61 { } public enum T62 { } public enum T63 { } public enum T64 { } public enum T65 { } public enum T66 { } public enum T67 { } public enum T68 { } public enum T69 { } public enum T70 { } public enum T71 { } public enum T72 { } public enum T73 { } public enum T74 { } public enum T75 { } public enum T76 { } public enum T77 { } public enum T78 { } public enum T79 { } public enum T80 { } public enum T81 { } public enum T82 { } public enum T83 { } public enum T84 { } public enum T85 { } public enum T86 { } public enum T87 { } public enum T88 { } public enum T89 { } public enum T90 { } public enum T91 { } public enum T92 { } public enum T93 { } public enum T94 { } public enum T95 { } public enum T96 { } public enum T97 { } public enum T98 { } public enum T99 { } public enum T100 { } public enum T101 { } public enum T102 { } public enum T103 { } public enum T104 { } public enum T105 { } public enum T106 { } public enum T107 { } public enum T108 { } public enum T109 { } public enum T110 { } public enum T111 { } public enum T112 { } public enum T113 { } public enum T114 { } public enum T115 { } public enum T116 { } public enum T117 { } public enum T118 { } public enum T119 { } public enum T120 { } public enum T121 { } public enum T122 { } public enum T123 { } public enum T124 { } public enum T125 { } public enum T126 { } public enum T127 { } public enum T128 { } public enum T129 { } public enum T130 { } public enum T131 { } public enum T132 { } public enum T133 { } public enum T134 { } public enum T135 { } public enum T136 { } public enum T137 { } public enum T138 { } public enum T139 { } public enum T140 { } public enum T141 { } public enum T142 { } public enum T143 { } public enum T144 { } public enum T145 { } public enum T146 { } public enum T147 { } public enum T148 { } public enum T149 { } public enum T150 { } public enum T151 { } public enum T152 { } public enum T153 { } public enum T154 { } public enum T155 { } public enum T156 { } public enum T157 { } public enum T158 { } public enum T159 { } public enum T160 { } public enum T161 { } public enum T162 { } public enum T163 { } public enum T164 { } public enum T165 { } public enum T166 { } public enum T167 { } public enum T168 { } public enum T169 { } public enum T170 { } public enum T171 { } public enum T172 { } public enum T173 { } public enum T174 { } public enum T175 { } public enum T176 { } public enum T177 { } public enum T178 { } public enum T179 { } public enum T180 { } public enum T181 { } public enum T182 { } public enum T183 { } public enum T184 { } public enum T185 { } public enum T186 { } public enum T187 { } public enum T188 { } public enum T189 { } public enum T190 { } public enum T191 { } public enum T192 { } public enum T193 { } public enum T194 { } public enum T195 { } public enum T196 { } public enum T197 { } public enum T198 { } public enum T199 { } public enum T200 { } public enum T201 { } public enum T202 { } public enum T203 { } public enum T204 { } public enum T205 { } public enum T206 { } public enum T207 { } public enum T208 { } public enum T209 { } public enum T210 { } public enum T211 { } public enum T212 { } public enum T213 { } public enum T214 { } public enum T215 { } public enum T216 { } public enum T217 { } public enum T218 { } public enum T219 { } public enum T220 { } public enum T221 { } public enum T222 { } public enum T223 { } public enum T224 { } public enum T225 { } public enum T226 { } public enum T227 { } public enum T228 { } public enum T229 { } public enum T230 { } public enum T231 { } public enum T232 { } public enum T233 { } public enum T234 { } public enum T235 { } public enum T236 { } public enum T237 { } public enum T238 { } public enum T239 { } public enum T240 { } public enum T241 { } public enum T242 { } public enum T243 { } public enum T244 { } public enum T245 { } public enum T246 { } public enum T247 { } public enum T248 { } public enum T249 { } public enum T250 { } public enum T251 { } public enum T252 { } public enum T253 { } public enum T254 { } public enum T255 { } public enum T256 { } public enum T257 { } public enum T258 { } public enum T259 { } public enum T260 { } public enum T261 { } public enum T262 { } public enum T263 { } public enum T264 { } public enum T265 { } public enum T266 { } public enum T267 { } public enum T268 { } public enum T269 { } public enum T270 { } public enum T271 { } public enum T272 { } public enum T273 { } public enum T274 { } public enum T275 { } public enum T276 { } public enum T277 { } public enum T278 { } public enum T279 { } public enum T280 { } public enum T281 { } public enum T282 { } public enum T283 { } public enum T284 { } public enum T285 { } public enum T286 { } public enum T287 { } public enum T288 { } public enum T289 { } public enum T290 { } public enum T291 { } public enum T292 { } public enum T293 { } public enum T294 { } public enum T295 { } public enum T296 { } public enum T297 { } public enum T298 { } public enum T299 { } public enum T300 { } public enum T301 { } public enum T302 { } public enum T303 { } public enum T304 { } public enum T305 { } public enum T306 { } public enum T307 { } public enum T308 { } public enum T309 { } public enum T310 { } public enum T311 { } public enum T312 { } public enum T313 { } public enum T314 { } public enum T315 { } public enum T316 { } public enum T317 { } public enum T318 { } public enum T319 { } public enum T320 { } public enum T321 { } public enum T322 { } public enum T323 { } public enum T324 { } public enum T325 { } public enum T326 { } public enum T327 { } public enum T328 { } public enum T329 { } public enum T330 { } public enum T331 { } public enum T332 { } public enum T333 { } public enum T334 { } public enum T335 { } public enum T336 { } public enum T337 { } public enum T338 { } public enum T339 { } public enum T340 { } public enum T341 { } public enum T342 { } public enum T343 { } public enum T344 { } public enum T345 { } public enum T346 { } public enum T347 { } public enum T348 { } public enum T349 { } public enum T350 { } public enum T351 { } public enum T352 { } public enum T353 { } public enum T354 { } public enum T355 { } public enum T356 { } public enum T357 { } public enum T358 { } public enum T359 { } public enum T360 { } public enum T361 { } public enum T362 { } public enum T363 { } public enum T364 { } public enum T365 { } public enum T366 { } public enum T367 { } public enum T368 { } public enum T369 { } public enum T370 { } public enum T371 { } public enum T372 { } public enum T373 { } public enum T374 { } public enum T375 { } public enum T376 { } public enum T377 { } public enum T378 { } public enum T379 { } public enum T380 { } public enum T381 { } public enum T382 { } public enum T383 { } public enum T384 { } public enum T385 { } public enum T386 { } public enum T387 { } public enum T388 { } public enum T389 { } public enum T390 { } public enum T391 { } public enum T392 { } public enum T393 { } public enum T394 { } public enum T395 { } public enum T396 { } public enum T397 { } public enum T398 { } public enum T399 { } public enum T400 { } public enum T401 { } public enum T402 { } public enum T403 { } public enum T404 { } public enum T405 { } public enum T406 { } public enum T407 { } public enum T408 { } public enum T409 { } public enum T410 { } public enum T411 { } public enum T412 { } public enum T413 { } public enum T414 { } public enum T415 { } public enum T416 { } public enum T417 { } public enum T418 { } public enum T419 { } public enum T420 { } public enum T421 { } public enum T422 { } public enum T423 { } public enum T424 { } public enum T425 { } public enum T426 { } public enum T427 { } public enum T428 { } public enum T429 { } public enum T430 { } public enum T431 { } public enum T432 { } public enum T433 { } public enum T434 { } public enum T435 { } public enum T436 { } public enum T437 { } public enum T438 { } public enum T439 { } public enum T440 { } public enum T441 { } public enum T442 { } public enum T443 { } public enum T444 { } public enum T445 { } public enum T446 { } public enum T447 { } public enum T448 { } public enum T449 { } public enum T450 { } public enum T451 { } public enum T452 { } public enum T453 { } public enum T454 { } public enum T455 { } public enum T456 { } public enum T457 { } public enum T458 { } public enum T459 { } public enum T460 { } public enum T461 { } public enum T462 { } public enum T463 { } public enum T464 { } public enum T465 { } public enum T466 { } public enum T467 { } public enum T468 { } public enum T469 { } public enum T470 { } public enum T471 { } public enum T472 { } public enum T473 { } public enum T474 { } public enum T475 { } public enum T476 { } public enum T477 { } public enum T478 { } public enum T479 { } public enum T480 { } public enum T481 { } public enum T482 { } public enum T483 { } public enum T484 { } public enum T485 { } public enum T486 { } public enum T487 { } public enum T488 { } public enum T489 { } public enum T490 { } public enum T491 { } public enum T492 { } public enum T493 { } public enum T494 { } public enum T495 { } public enum T496 { } public enum T497 { } public enum T498 { } public enum T499 { } public enum T500 { } public enum T501 { } public enum T502 { } public enum T503 { } public enum T504 { } public enum T505 { } public enum T506 { } public enum T507 { } public enum T508 { } public enum T509 { } public enum T510 { } public enum T511 { } public enum T512 { } public enum T513 { } public enum T514 { } public enum T515 { } public enum T516 { } public enum T517 { } public enum T518 { } public enum T519 { } public enum T520 { } public enum T521 { } public enum T522 { } public enum T523 { } public enum T524 { } public enum T525 { } public enum T526 { } public enum T527 { } public enum T528 { } public enum T529 { } public enum T530 { } public enum T531 { } public enum T532 { } public enum T533 { } public enum T534 { } public enum T535 { } public enum T536 { } public enum T537 { } public enum T538 { } public enum T539 { } public enum T540 { } public enum T541 { } public enum T542 { } public enum T543 { } public enum T544 { } public enum T545 { } public enum T546 { } public enum T547 { } public enum T548 { } public enum T549 { } public enum T550 { } public enum T551 { } public enum T552 { } public enum T553 { } public enum T554 { } public enum T555 { } public enum T556 { } public enum T557 { } public enum T558 { } public enum T559 { } public enum T560 { } public enum T561 { } public enum T562 { } public enum T563 { } public enum T564 { } public enum T565 { } public enum T566 { } public enum T567 { } public enum T568 { } public enum T569 { } public enum T570 { } public enum T571 { } public enum T572 { } public enum T573 { } public enum T574 { } public enum T575 { } public enum T576 { } public enum T577 { } public enum T578 { } public enum T579 { } public enum T580 { } public enum T581 { } public enum T582 { } public enum T583 { } public enum T584 { } public enum T585 { } public enum T586 { } public enum T587 { } public enum T588 { } public enum T589 { } public enum T590 { } public enum T591 { } public enum T592 { } public enum T593 { } public enum T594 { } public enum T595 { } public enum T596 { } public enum T597 { } public enum T598 { } public enum T599 { } public enum T600 { } public enum T601 { } public enum T602 { } public enum T603 { } public enum T604 { } public enum T605 { } public enum T606 { } public enum T607 { } public enum T608 { } public enum T609 { } public enum T610 { } public enum T611 { } public enum T612 { } public enum T613 { } public enum T614 { } public enum T615 { } public enum T616 { } public enum T617 { } public enum T618 { } public enum T619 { } public enum T620 { } public enum T621 { } public enum T622 { } public enum T623 { } public enum T624 { } public enum T625 { } public enum T626 { } public enum T627 { } public enum T628 { } public enum T629 { } public enum T630 { } public enum T631 { } public enum T632 { } public enum T633 { } public enum T634 { } public enum T635 { } public enum T636 { } public enum T637 { } public enum T638 { } public enum T639 { } public enum T640 { } public enum T641 { } public enum T642 { } public enum T643 { } public enum T644 { } public enum T645 { } public enum T646 { } public enum T647 { } public enum T648 { } public enum T649 { } public enum T650 { } public enum T651 { } public enum T652 { } public enum T653 { } public enum T654 { } public enum T655 { } public enum T656 { } public enum T657 { } public enum T658 { } public enum T659 { } public enum T660 { } public enum T661 { } public enum T662 { } public enum T663 { } public enum T664 { } public enum T665 { } public enum T666 { } public enum T667 { } public enum T668 { } public enum T669 { } public enum T670 { } public enum T671 { } public enum T672 { } public enum T673 { } public enum T674 { } public enum T675 { } public enum T676 { } public enum T677 { } public enum T678 { } public enum T679 { } public enum T680 { } public enum T681 { } public enum T682 { } public enum T683 { } public enum T684 { } public enum T685 { } public enum T686 { } public enum T687 { } public enum T688 { } public enum T689 { } public enum T690 { } public enum T691 { } public enum T692 { } public enum T693 { } public enum T694 { } public enum T695 { } public enum T696 { } public enum T697 { } public enum T698 { } public enum T699 { } public enum T700 { } public enum T701 { } public enum T702 { } public enum T703 { } public enum T704 { } public enum T705 { } public enum T706 { } public enum T707 { } public enum T708 { } public enum T709 { } public enum T710 { } public enum T711 { } public enum T712 { } public enum T713 { } public enum T714 { } public enum T715 { } public enum T716 { } public enum T717 { } public enum T718 { } public enum T719 { } public enum T720 { } public enum T721 { } public enum T722 { } public enum T723 { } public enum T724 { } public enum T725 { } public enum T726 { } public enum T727 { } public enum T728 { } public enum T729 { } public enum T730 { } public enum T731 { } public enum T732 { } public enum T733 { } public enum T734 { } public enum T735 { } public enum T736 { } public enum T737 { } public enum T738 { } public enum T739 { } public enum T740 { } public enum T741 { } public enum T742 { } public enum T743 { } public enum T744 { } public enum T745 { } public enum T746 { } public enum T747 { } public enum T748 { } public enum T749 { } public enum T750 { } public enum T751 { } public enum T752 { } public enum T753 { } public enum T754 { } public enum T755 { } public enum T756 { } public enum T757 { } public enum T758 { } public enum T759 { } public enum T760 { } public enum T761 { } public enum T762 { } public enum T763 { } public enum T764 { } public enum T765 { } public enum T766 { } public enum T767 { } public enum T768 { } public enum T769 { } public enum T770 { } public enum T771 { } public enum T772 { } public enum T773 { } public enum T774 { } public enum T775 { } public enum T776 { } public enum T777 { } public enum T778 { } public enum T779 { } public enum T780 { } public enum T781 { } public enum T782 { } public enum T783 { } public enum T784 { } public enum T785 { } public enum T786 { } public enum T787 { } public enum T788 { } public enum T789 { } public enum T790 { } public enum T791 { } public enum T792 { } public enum T793 { } public enum T794 { } public enum T795 { } public enum T796 { } public enum T797 { } public enum T798 { } public enum T799 { } public enum T800 { } public enum T801 { } public enum T802 { } public enum T803 { } public enum T804 { } public enum T805 { } public enum T806 { } public enum T807 { } public enum T808 { } public enum T809 { } public enum T810 { } public enum T811 { } public enum T812 { } public enum T813 { } public enum T814 { } public enum T815 { } public enum T816 { } public enum T817 { } public enum T818 { } public enum T819 { } public enum T820 { } public enum T821 { } public enum T822 { } public enum T823 { } public enum T824 { } public enum T825 { } public enum T826 { } public enum T827 { } public enum T828 { } public enum T829 { } public enum T830 { } public enum T831 { } public enum T832 { } public enum T833 { } public enum T834 { } public enum T835 { } public enum T836 { } public enum T837 { } public enum T838 { } public enum T839 { } public enum T840 { } public enum T841 { } public enum T842 { } public enum T843 { } public enum T844 { } public enum T845 { } public enum T846 { } public enum T847 { } public enum T848 { } public enum T849 { } public enum T850 { } public enum T851 { } public enum T852 { } public enum T853 { } public enum T854 { } public enum T855 { } public enum T856 { } public enum T857 { } public enum T858 { } public enum T859 { } public enum T860 { } public enum T861 { } public enum T862 { } public enum T863 { } public enum T864 { } public enum T865 { } public enum T866 { } public enum T867 { } public enum T868 { } public enum T869 { } public enum T870 { } public enum T871 { } public enum T872 { } public enum T873 { } public enum T874 { } public enum T875 { } public enum T876 { } public enum T877 { } public enum T878 { } public enum T879 { } public enum T880 { } public enum T881 { } public enum T882 { } public enum T883 { } public enum T884 { } public enum T885 { } public enum T886 { } public enum T887 { } public enum T888 { } public enum T889 { } public enum T890 { } public enum T891 { } public enum T892 { } public enum T893 { } public enum T894 { } public enum T895 { } public enum T896 { } public enum T897 { } public enum T898 { } public enum T899 { } public enum T900 { } public enum T901 { } public enum T902 { } public enum T903 { } public enum T904 { } public enum T905 { } public enum T906 { } public enum T907 { } public enum T908 { } public enum T909 { } public enum T910 { } public enum T911 { } public enum T912 { } public enum T913 { } public enum T914 { } public enum T915 { } public enum T916 { } public enum T917 { } public enum T918 { } public enum T919 { } public enum T920 { } public enum T921 { } public enum T922 { } public enum T923 { } public enum T924 { } public enum T925 { } public enum T926 { } public enum T927 { } public enum T928 { } public enum T929 { } public enum T930 { } public enum T931 { } public enum T932 { } public enum T933 { } public enum T934 { } public enum T935 { } public enum T936 { } public enum T937 { } public enum T938 { } public enum T939 { } public enum T940 { } public enum T941 { } public enum T942 { } public enum T943 { } public enum T944 { } public enum T945 { } public enum T946 { } public enum T947 { } public enum T948 { } public enum T949 { } public enum T950 { } public enum T951 { } public enum T952 { } public enum T953 { } public enum T954 { } public enum T955 { } public enum T956 { } public enum T957 { } public enum T958 { } public enum T959 { } public enum T960 { } public enum T961 { } public enum T962 { } public enum T963 { } public enum T964 { } public enum T965 { } public enum T966 { } public enum T967 { } public enum T968 { } public enum T969 { } public enum T970 { } public enum T971 { } public enum T972 { } public enum T973 { } public enum T974 { } public enum T975 { } public enum T976 { } public enum T977 { } public enum T978 { } public enum T979 { } public enum T980 { } public enum T981 { } public enum T982 { } public enum T983 { } public enum T984 { } public enum T985 { } public enum T986 { } public enum T987 { } public enum T988 { } public enum T989 { } public enum T990 { } public enum T991 { } public enum T992 { } public enum T993 { } public enum T994 { } public enum T995 { } public enum T996 { } public enum T997 { } public enum T998 { } public enum T999 { } public class Test_nullenum1000 { public static int Main() { try { Do0(new T0()); Do1(new T1()); Do2(new T2()); Do3(new T3()); Do4(new T4()); Do5(new T5()); Do6(new T6()); Do7(new T7()); Do8(new T8()); Do9(new T9()); Do10(new T10()); Do11(new T11()); Do12(new T12()); Do13(new T13()); Do14(new T14()); Do15(new T15()); Do16(new T16()); Do17(new T17()); Do18(new T18()); Do19(new T19()); Do20(new T20()); Do21(new T21()); Do22(new T22()); Do23(new T23()); Do24(new T24()); Do25(new T25()); Do26(new T26()); Do27(new T27()); Do28(new T28()); Do29(new T29()); Do30(new T30()); Do31(new T31()); Do32(new T32()); Do33(new T33()); Do34(new T34()); Do35(new T35()); Do36(new T36()); Do37(new T37()); Do38(new T38()); Do39(new T39()); Do40(new T40()); Do41(new T41()); Do42(new T42()); Do43(new T43()); Do44(new T44()); Do45(new T45()); Do46(new T46()); Do47(new T47()); Do48(new T48()); Do49(new T49()); Do50(new T50()); Do51(new T51()); Do52(new T52()); Do53(new T53()); Do54(new T54()); Do55(new T55()); Do56(new T56()); Do57(new T57()); Do58(new T58()); Do59(new T59()); Do60(new T60()); Do61(new T61()); Do62(new T62()); Do63(new T63()); Do64(new T64()); Do65(new T65()); Do66(new T66()); Do67(new T67()); Do68(new T68()); Do69(new T69()); Do70(new T70()); Do71(new T71()); Do72(new T72()); Do73(new T73()); Do74(new T74()); Do75(new T75()); Do76(new T76()); Do77(new T77()); Do78(new T78()); Do79(new T79()); Do80(new T80()); Do81(new T81()); Do82(new T82()); Do83(new T83()); Do84(new T84()); Do85(new T85()); Do86(new T86()); Do87(new T87()); Do88(new T88()); Do89(new T89()); Do90(new T90()); Do91(new T91()); Do92(new T92()); Do93(new T93()); Do94(new T94()); Do95(new T95()); Do96(new T96()); Do97(new T97()); Do98(new T98()); Do99(new T99()); Do100(new T100()); Do101(new T101()); Do102(new T102()); Do103(new T103()); Do104(new T104()); Do105(new T105()); Do106(new T106()); Do107(new T107()); Do108(new T108()); Do109(new T109()); Do110(new T110()); Do111(new T111()); Do112(new T112()); Do113(new T113()); Do114(new T114()); Do115(new T115()); Do116(new T116()); Do117(new T117()); Do118(new T118()); Do119(new T119()); Do120(new T120()); Do121(new T121()); Do122(new T122()); Do123(new T123()); Do124(new T124()); Do125(new T125()); Do126(new T126()); Do127(new T127()); Do128(new T128()); Do129(new T129()); Do130(new T130()); Do131(new T131()); Do132(new T132()); Do133(new T133()); Do134(new T134()); Do135(new T135()); Do136(new T136()); Do137(new T137()); Do138(new T138()); Do139(new T139()); Do140(new T140()); Do141(new T141()); Do142(new T142()); Do143(new T143()); Do144(new T144()); Do145(new T145()); Do146(new T146()); Do147(new T147()); Do148(new T148()); Do149(new T149()); Do150(new T150()); Do151(new T151()); Do152(new T152()); Do153(new T153()); Do154(new T154()); Do155(new T155()); Do156(new T156()); Do157(new T157()); Do158(new T158()); Do159(new T159()); Do160(new T160()); Do161(new T161()); Do162(new T162()); Do163(new T163()); Do164(new T164()); Do165(new T165()); Do166(new T166()); Do167(new T167()); Do168(new T168()); Do169(new T169()); Do170(new T170()); Do171(new T171()); Do172(new T172()); Do173(new T173()); Do174(new T174()); Do175(new T175()); Do176(new T176()); Do177(new T177()); Do178(new T178()); Do179(new T179()); Do180(new T180()); Do181(new T181()); Do182(new T182()); Do183(new T183()); Do184(new T184()); Do185(new T185()); Do186(new T186()); Do187(new T187()); Do188(new T188()); Do189(new T189()); Do190(new T190()); Do191(new T191()); Do192(new T192()); Do193(new T193()); Do194(new T194()); Do195(new T195()); Do196(new T196()); Do197(new T197()); Do198(new T198()); Do199(new T199()); Do200(new T200()); Do201(new T201()); Do202(new T202()); Do203(new T203()); Do204(new T204()); Do205(new T205()); Do206(new T206()); Do207(new T207()); Do208(new T208()); Do209(new T209()); Do210(new T210()); Do211(new T211()); Do212(new T212()); Do213(new T213()); Do214(new T214()); Do215(new T215()); Do216(new T216()); Do217(new T217()); Do218(new T218()); Do219(new T219()); Do220(new T220()); Do221(new T221()); Do222(new T222()); Do223(new T223()); Do224(new T224()); Do225(new T225()); Do226(new T226()); Do227(new T227()); Do228(new T228()); Do229(new T229()); Do230(new T230()); Do231(new T231()); Do232(new T232()); Do233(new T233()); Do234(new T234()); Do235(new T235()); Do236(new T236()); Do237(new T237()); Do238(new T238()); Do239(new T239()); Do240(new T240()); Do241(new T241()); Do242(new T242()); Do243(new T243()); Do244(new T244()); Do245(new T245()); Do246(new T246()); Do247(new T247()); Do248(new T248()); Do249(new T249()); Do250(new T250()); Do251(new T251()); Do252(new T252()); Do253(new T253()); Do254(new T254()); Do255(new T255()); Do256(new T256()); Do257(new T257()); Do258(new T258()); Do259(new T259()); Do260(new T260()); Do261(new T261()); Do262(new T262()); Do263(new T263()); Do264(new T264()); Do265(new T265()); Do266(new T266()); Do267(new T267()); Do268(new T268()); Do269(new T269()); Do270(new T270()); Do271(new T271()); Do272(new T272()); Do273(new T273()); Do274(new T274()); Do275(new T275()); Do276(new T276()); Do277(new T277()); Do278(new T278()); Do279(new T279()); Do280(new T280()); Do281(new T281()); Do282(new T282()); Do283(new T283()); Do284(new T284()); Do285(new T285()); Do286(new T286()); Do287(new T287()); Do288(new T288()); Do289(new T289()); Do290(new T290()); Do291(new T291()); Do292(new T292()); Do293(new T293()); Do294(new T294()); Do295(new T295()); Do296(new T296()); Do297(new T297()); Do298(new T298()); Do299(new T299()); Do300(new T300()); Do301(new T301()); Do302(new T302()); Do303(new T303()); Do304(new T304()); Do305(new T305()); Do306(new T306()); Do307(new T307()); Do308(new T308()); Do309(new T309()); Do310(new T310()); Do311(new T311()); Do312(new T312()); Do313(new T313()); Do314(new T314()); Do315(new T315()); Do316(new T316()); Do317(new T317()); Do318(new T318()); Do319(new T319()); Do320(new T320()); Do321(new T321()); Do322(new T322()); Do323(new T323()); Do324(new T324()); Do325(new T325()); Do326(new T326()); Do327(new T327()); Do328(new T328()); Do329(new T329()); Do330(new T330()); Do331(new T331()); Do332(new T332()); Do333(new T333()); Do334(new T334()); Do335(new T335()); Do336(new T336()); Do337(new T337()); Do338(new T338()); Do339(new T339()); Do340(new T340()); Do341(new T341()); Do342(new T342()); Do343(new T343()); Do344(new T344()); Do345(new T345()); Do346(new T346()); Do347(new T347()); Do348(new T348()); Do349(new T349()); Do350(new T350()); Do351(new T351()); Do352(new T352()); Do353(new T353()); Do354(new T354()); Do355(new T355()); Do356(new T356()); Do357(new T357()); Do358(new T358()); Do359(new T359()); Do360(new T360()); Do361(new T361()); Do362(new T362()); Do363(new T363()); Do364(new T364()); Do365(new T365()); Do366(new T366()); Do367(new T367()); Do368(new T368()); Do369(new T369()); Do370(new T370()); Do371(new T371()); Do372(new T372()); Do373(new T373()); Do374(new T374()); Do375(new T375()); Do376(new T376()); Do377(new T377()); Do378(new T378()); Do379(new T379()); Do380(new T380()); Do381(new T381()); Do382(new T382()); Do383(new T383()); Do384(new T384()); Do385(new T385()); Do386(new T386()); Do387(new T387()); Do388(new T388()); Do389(new T389()); Do390(new T390()); Do391(new T391()); Do392(new T392()); Do393(new T393()); Do394(new T394()); Do395(new T395()); Do396(new T396()); Do397(new T397()); Do398(new T398()); Do399(new T399()); Do400(new T400()); Do401(new T401()); Do402(new T402()); Do403(new T403()); Do404(new T404()); Do405(new T405()); Do406(new T406()); Do407(new T407()); Do408(new T408()); Do409(new T409()); Do410(new T410()); Do411(new T411()); Do412(new T412()); Do413(new T413()); Do414(new T414()); Do415(new T415()); Do416(new T416()); Do417(new T417()); Do418(new T418()); Do419(new T419()); Do420(new T420()); Do421(new T421()); Do422(new T422()); Do423(new T423()); Do424(new T424()); Do425(new T425()); Do426(new T426()); Do427(new T427()); Do428(new T428()); Do429(new T429()); Do430(new T430()); Do431(new T431()); Do432(new T432()); Do433(new T433()); Do434(new T434()); Do435(new T435()); Do436(new T436()); Do437(new T437()); Do438(new T438()); Do439(new T439()); Do440(new T440()); Do441(new T441()); Do442(new T442()); Do443(new T443()); Do444(new T444()); Do445(new T445()); Do446(new T446()); Do447(new T447()); Do448(new T448()); Do449(new T449()); Do450(new T450()); Do451(new T451()); Do452(new T452()); Do453(new T453()); Do454(new T454()); Do455(new T455()); Do456(new T456()); Do457(new T457()); Do458(new T458()); Do459(new T459()); Do460(new T460()); Do461(new T461()); Do462(new T462()); Do463(new T463()); Do464(new T464()); Do465(new T465()); Do466(new T466()); Do467(new T467()); Do468(new T468()); Do469(new T469()); Do470(new T470()); Do471(new T471()); Do472(new T472()); Do473(new T473()); Do474(new T474()); Do475(new T475()); Do476(new T476()); Do477(new T477()); Do478(new T478()); Do479(new T479()); Do480(new T480()); Do481(new T481()); Do482(new T482()); Do483(new T483()); Do484(new T484()); Do485(new T485()); Do486(new T486()); Do487(new T487()); Do488(new T488()); Do489(new T489()); Do490(new T490()); Do491(new T491()); Do492(new T492()); Do493(new T493()); Do494(new T494()); Do495(new T495()); Do496(new T496()); Do497(new T497()); Do498(new T498()); Do499(new T499()); Do500(new T500()); Do501(new T501()); Do502(new T502()); Do503(new T503()); Do504(new T504()); Do505(new T505()); Do506(new T506()); Do507(new T507()); Do508(new T508()); Do509(new T509()); Do510(new T510()); Do511(new T511()); Do512(new T512()); Do513(new T513()); Do514(new T514()); Do515(new T515()); Do516(new T516()); Do517(new T517()); Do518(new T518()); Do519(new T519()); Do520(new T520()); Do521(new T521()); Do522(new T522()); Do523(new T523()); Do524(new T524()); Do525(new T525()); Do526(new T526()); Do527(new T527()); Do528(new T528()); Do529(new T529()); Do530(new T530()); Do531(new T531()); Do532(new T532()); Do533(new T533()); Do534(new T534()); Do535(new T535()); Do536(new T536()); Do537(new T537()); Do538(new T538()); Do539(new T539()); Do540(new T540()); Do541(new T541()); Do542(new T542()); Do543(new T543()); Do544(new T544()); Do545(new T545()); Do546(new T546()); Do547(new T547()); Do548(new T548()); Do549(new T549()); Do550(new T550()); Do551(new T551()); Do552(new T552()); Do553(new T553()); Do554(new T554()); Do555(new T555()); Do556(new T556()); Do557(new T557()); Do558(new T558()); Do559(new T559()); Do560(new T560()); Do561(new T561()); Do562(new T562()); Do563(new T563()); Do564(new T564()); Do565(new T565()); Do566(new T566()); Do567(new T567()); Do568(new T568()); Do569(new T569()); Do570(new T570()); Do571(new T571()); Do572(new T572()); Do573(new T573()); Do574(new T574()); Do575(new T575()); Do576(new T576()); Do577(new T577()); Do578(new T578()); Do579(new T579()); Do580(new T580()); Do581(new T581()); Do582(new T582()); Do583(new T583()); Do584(new T584()); Do585(new T585()); Do586(new T586()); Do587(new T587()); Do588(new T588()); Do589(new T589()); Do590(new T590()); Do591(new T591()); Do592(new T592()); Do593(new T593()); Do594(new T594()); Do595(new T595()); Do596(new T596()); Do597(new T597()); Do598(new T598()); Do599(new T599()); Do600(new T600()); Do601(new T601()); Do602(new T602()); Do603(new T603()); Do604(new T604()); Do605(new T605()); Do606(new T606()); Do607(new T607()); Do608(new T608()); Do609(new T609()); Do610(new T610()); Do611(new T611()); Do612(new T612()); Do613(new T613()); Do614(new T614()); Do615(new T615()); Do616(new T616()); Do617(new T617()); Do618(new T618()); Do619(new T619()); Do620(new T620()); Do621(new T621()); Do622(new T622()); Do623(new T623()); Do624(new T624()); Do625(new T625()); Do626(new T626()); Do627(new T627()); Do628(new T628()); Do629(new T629()); Do630(new T630()); Do631(new T631()); Do632(new T632()); Do633(new T633()); Do634(new T634()); Do635(new T635()); Do636(new T636()); Do637(new T637()); Do638(new T638()); Do639(new T639()); Do640(new T640()); Do641(new T641()); Do642(new T642()); Do643(new T643()); Do644(new T644()); Do645(new T645()); Do646(new T646()); Do647(new T647()); Do648(new T648()); Do649(new T649()); Do650(new T650()); Do651(new T651()); Do652(new T652()); Do653(new T653()); Do654(new T654()); Do655(new T655()); Do656(new T656()); Do657(new T657()); Do658(new T658()); Do659(new T659()); Do660(new T660()); Do661(new T661()); Do662(new T662()); Do663(new T663()); Do664(new T664()); Do665(new T665()); Do666(new T666()); Do667(new T667()); Do668(new T668()); Do669(new T669()); Do670(new T670()); Do671(new T671()); Do672(new T672()); Do673(new T673()); Do674(new T674()); Do675(new T675()); Do676(new T676()); Do677(new T677()); Do678(new T678()); Do679(new T679()); Do680(new T680()); Do681(new T681()); Do682(new T682()); Do683(new T683()); Do684(new T684()); Do685(new T685()); Do686(new T686()); Do687(new T687()); Do688(new T688()); Do689(new T689()); Do690(new T690()); Do691(new T691()); Do692(new T692()); Do693(new T693()); Do694(new T694()); Do695(new T695()); Do696(new T696()); Do697(new T697()); Do698(new T698()); Do699(new T699()); Do700(new T700()); Do701(new T701()); Do702(new T702()); Do703(new T703()); Do704(new T704()); Do705(new T705()); Do706(new T706()); Do707(new T707()); Do708(new T708()); Do709(new T709()); Do710(new T710()); Do711(new T711()); Do712(new T712()); Do713(new T713()); Do714(new T714()); Do715(new T715()); Do716(new T716()); Do717(new T717()); Do718(new T718()); Do719(new T719()); Do720(new T720()); Do721(new T721()); Do722(new T722()); Do723(new T723()); Do724(new T724()); Do725(new T725()); Do726(new T726()); Do727(new T727()); Do728(new T728()); Do729(new T729()); Do730(new T730()); Do731(new T731()); Do732(new T732()); Do733(new T733()); Do734(new T734()); Do735(new T735()); Do736(new T736()); Do737(new T737()); Do738(new T738()); Do739(new T739()); Do740(new T740()); Do741(new T741()); Do742(new T742()); Do743(new T743()); Do744(new T744()); Do745(new T745()); Do746(new T746()); Do747(new T747()); Do748(new T748()); Do749(new T749()); Do750(new T750()); Do751(new T751()); Do752(new T752()); Do753(new T753()); Do754(new T754()); Do755(new T755()); Do756(new T756()); Do757(new T757()); Do758(new T758()); Do759(new T759()); Do760(new T760()); Do761(new T761()); Do762(new T762()); Do763(new T763()); Do764(new T764()); Do765(new T765()); Do766(new T766()); Do767(new T767()); Do768(new T768()); Do769(new T769()); Do770(new T770()); Do771(new T771()); Do772(new T772()); Do773(new T773()); Do774(new T774()); Do775(new T775()); Do776(new T776()); Do777(new T777()); Do778(new T778()); Do779(new T779()); Do780(new T780()); Do781(new T781()); Do782(new T782()); Do783(new T783()); Do784(new T784()); Do785(new T785()); Do786(new T786()); Do787(new T787()); Do788(new T788()); Do789(new T789()); Do790(new T790()); Do791(new T791()); Do792(new T792()); Do793(new T793()); Do794(new T794()); Do795(new T795()); Do796(new T796()); Do797(new T797()); Do798(new T798()); Do799(new T799()); Do800(new T800()); Do801(new T801()); Do802(new T802()); Do803(new T803()); Do804(new T804()); Do805(new T805()); Do806(new T806()); Do807(new T807()); Do808(new T808()); Do809(new T809()); Do810(new T810()); Do811(new T811()); Do812(new T812()); Do813(new T813()); Do814(new T814()); Do815(new T815()); Do816(new T816()); Do817(new T817()); Do818(new T818()); Do819(new T819()); Do820(new T820()); Do821(new T821()); Do822(new T822()); Do823(new T823()); Do824(new T824()); Do825(new T825()); Do826(new T826()); Do827(new T827()); Do828(new T828()); Do829(new T829()); Do830(new T830()); Do831(new T831()); Do832(new T832()); Do833(new T833()); Do834(new T834()); Do835(new T835()); Do836(new T836()); Do837(new T837()); Do838(new T838()); Do839(new T839()); Do840(new T840()); Do841(new T841()); Do842(new T842()); Do843(new T843()); Do844(new T844()); Do845(new T845()); Do846(new T846()); Do847(new T847()); Do848(new T848()); Do849(new T849()); Do850(new T850()); Do851(new T851()); Do852(new T852()); Do853(new T853()); Do854(new T854()); Do855(new T855()); Do856(new T856()); Do857(new T857()); Do858(new T858()); Do859(new T859()); Do860(new T860()); Do861(new T861()); Do862(new T862()); Do863(new T863()); Do864(new T864()); Do865(new T865()); Do866(new T866()); Do867(new T867()); Do868(new T868()); Do869(new T869()); Do870(new T870()); Do871(new T871()); Do872(new T872()); Do873(new T873()); Do874(new T874()); Do875(new T875()); Do876(new T876()); Do877(new T877()); Do878(new T878()); Do879(new T879()); Do880(new T880()); Do881(new T881()); Do882(new T882()); Do883(new T883()); Do884(new T884()); Do885(new T885()); Do886(new T886()); Do887(new T887()); Do888(new T888()); Do889(new T889()); Do890(new T890()); Do891(new T891()); Do892(new T892()); Do893(new T893()); Do894(new T894()); Do895(new T895()); Do896(new T896()); Do897(new T897()); Do898(new T898()); Do899(new T899()); Do900(new T900()); Do901(new T901()); Do902(new T902()); Do903(new T903()); Do904(new T904()); Do905(new T905()); Do906(new T906()); Do907(new T907()); Do908(new T908()); Do909(new T909()); Do910(new T910()); Do911(new T911()); Do912(new T912()); Do913(new T913()); Do914(new T914()); Do915(new T915()); Do916(new T916()); Do917(new T917()); Do918(new T918()); Do919(new T919()); Do920(new T920()); Do921(new T921()); Do922(new T922()); Do923(new T923()); Do924(new T924()); Do925(new T925()); Do926(new T926()); Do927(new T927()); Do928(new T928()); Do929(new T929()); Do930(new T930()); Do931(new T931()); Do932(new T932()); Do933(new T933()); Do934(new T934()); Do935(new T935()); Do936(new T936()); Do937(new T937()); Do938(new T938()); Do939(new T939()); Do940(new T940()); Do941(new T941()); Do942(new T942()); Do943(new T943()); Do944(new T944()); Do945(new T945()); Do946(new T946()); Do947(new T947()); Do948(new T948()); Do949(new T949()); Do950(new T950()); Do951(new T951()); Do952(new T952()); Do953(new T953()); Do954(new T954()); Do955(new T955()); Do956(new T956()); Do957(new T957()); Do958(new T958()); Do959(new T959()); Do960(new T960()); Do961(new T961()); Do962(new T962()); Do963(new T963()); Do964(new T964()); Do965(new T965()); Do966(new T966()); Do967(new T967()); Do968(new T968()); Do969(new T969()); Do970(new T970()); Do971(new T971()); Do972(new T972()); Do973(new T973()); Do974(new T974()); Do975(new T975()); Do976(new T976()); Do977(new T977()); Do978(new T978()); Do979(new T979()); Do980(new T980()); Do981(new T981()); Do982(new T982()); Do983(new T983()); Do984(new T984()); Do985(new T985()); Do986(new T986()); Do987(new T987()); Do988(new T988()); Do989(new T989()); Do990(new T990()); Do991(new T991()); Do992(new T992()); Do993(new T993()); Do994(new T994()); Do995(new T995()); Do996(new T996()); Do997(new T997()); Do998(new T998()); Do999(new T999()); Console.WriteLine("PASS"); return 100; } catch (TypeLoadException e) { Console.WriteLine("FAIL: Caught unexpected TypeLoadException" + e.Message); return 101; } catch (Exception e) { Console.WriteLine("FAIL: Caught unexpected exception:" + e.Message); return 101; } } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do0(T0 t) { Nullable<T0> n = new Nullable<T0>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do1(T1 t) { Nullable<T1> n = new Nullable<T1>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do2(T2 t) { Nullable<T2> n = new Nullable<T2>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do3(T3 t) { Nullable<T3> n = new Nullable<T3>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do4(T4 t) { Nullable<T4> n = new Nullable<T4>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do5(T5 t) { Nullable<T5> n = new Nullable<T5>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do6(T6 t) { Nullable<T6> n = new Nullable<T6>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do7(T7 t) { Nullable<T7> n = new Nullable<T7>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do8(T8 t) { Nullable<T8> n = new Nullable<T8>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do9(T9 t) { Nullable<T9> n = new Nullable<T9>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do10(T10 t) { Nullable<T10> n = new Nullable<T10>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do11(T11 t) { Nullable<T11> n = new Nullable<T11>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do12(T12 t) { Nullable<T12> n = new Nullable<T12>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do13(T13 t) { Nullable<T13> n = new Nullable<T13>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do14(T14 t) { Nullable<T14> n = new Nullable<T14>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do15(T15 t) { Nullable<T15> n = new Nullable<T15>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do16(T16 t) { Nullable<T16> n = new Nullable<T16>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do17(T17 t) { Nullable<T17> n = new Nullable<T17>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do18(T18 t) { Nullable<T18> n = new Nullable<T18>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do19(T19 t) { Nullable<T19> n = new Nullable<T19>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do20(T20 t) { Nullable<T20> n = new Nullable<T20>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do21(T21 t) { Nullable<T21> n = new Nullable<T21>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do22(T22 t) { Nullable<T22> n = new Nullable<T22>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do23(T23 t) { Nullable<T23> n = new Nullable<T23>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do24(T24 t) { Nullable<T24> n = new Nullable<T24>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do25(T25 t) { Nullable<T25> n = new Nullable<T25>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do26(T26 t) { Nullable<T26> n = new Nullable<T26>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do27(T27 t) { Nullable<T27> n = new Nullable<T27>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do28(T28 t) { Nullable<T28> n = new Nullable<T28>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do29(T29 t) { Nullable<T29> n = new Nullable<T29>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do30(T30 t) { Nullable<T30> n = new Nullable<T30>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do31(T31 t) { Nullable<T31> n = new Nullable<T31>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do32(T32 t) { Nullable<T32> n = new Nullable<T32>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do33(T33 t) { Nullable<T33> n = new Nullable<T33>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do34(T34 t) { Nullable<T34> n = new Nullable<T34>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do35(T35 t) { Nullable<T35> n = new Nullable<T35>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do36(T36 t) { Nullable<T36> n = new Nullable<T36>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do37(T37 t) { Nullable<T37> n = new Nullable<T37>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do38(T38 t) { Nullable<T38> n = new Nullable<T38>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do39(T39 t) { Nullable<T39> n = new Nullable<T39>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do40(T40 t) { Nullable<T40> n = new Nullable<T40>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do41(T41 t) { Nullable<T41> n = new Nullable<T41>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do42(T42 t) { Nullable<T42> n = new Nullable<T42>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do43(T43 t) { Nullable<T43> n = new Nullable<T43>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do44(T44 t) { Nullable<T44> n = new Nullable<T44>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do45(T45 t) { Nullable<T45> n = new Nullable<T45>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do46(T46 t) { Nullable<T46> n = new Nullable<T46>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do47(T47 t) { Nullable<T47> n = new Nullable<T47>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do48(T48 t) { Nullable<T48> n = new Nullable<T48>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do49(T49 t) { Nullable<T49> n = new Nullable<T49>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do50(T50 t) { Nullable<T50> n = new Nullable<T50>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do51(T51 t) { Nullable<T51> n = new Nullable<T51>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do52(T52 t) { Nullable<T52> n = new Nullable<T52>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do53(T53 t) { Nullable<T53> n = new Nullable<T53>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do54(T54 t) { Nullable<T54> n = new Nullable<T54>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do55(T55 t) { Nullable<T55> n = new Nullable<T55>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do56(T56 t) { Nullable<T56> n = new Nullable<T56>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do57(T57 t) { Nullable<T57> n = new Nullable<T57>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do58(T58 t) { Nullable<T58> n = new Nullable<T58>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do59(T59 t) { Nullable<T59> n = new Nullable<T59>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do60(T60 t) { Nullable<T60> n = new Nullable<T60>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do61(T61 t) { Nullable<T61> n = new Nullable<T61>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do62(T62 t) { Nullable<T62> n = new Nullable<T62>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do63(T63 t) { Nullable<T63> n = new Nullable<T63>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do64(T64 t) { Nullable<T64> n = new Nullable<T64>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do65(T65 t) { Nullable<T65> n = new Nullable<T65>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do66(T66 t) { Nullable<T66> n = new Nullable<T66>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do67(T67 t) { Nullable<T67> n = new Nullable<T67>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do68(T68 t) { Nullable<T68> n = new Nullable<T68>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do69(T69 t) { Nullable<T69> n = new Nullable<T69>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do70(T70 t) { Nullable<T70> n = new Nullable<T70>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do71(T71 t) { Nullable<T71> n = new Nullable<T71>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do72(T72 t) { Nullable<T72> n = new Nullable<T72>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do73(T73 t) { Nullable<T73> n = new Nullable<T73>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do74(T74 t) { Nullable<T74> n = new Nullable<T74>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do75(T75 t) { Nullable<T75> n = new Nullable<T75>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do76(T76 t) { Nullable<T76> n = new Nullable<T76>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do77(T77 t) { Nullable<T77> n = new Nullable<T77>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do78(T78 t) { Nullable<T78> n = new Nullable<T78>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do79(T79 t) { Nullable<T79> n = new Nullable<T79>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do80(T80 t) { Nullable<T80> n = new Nullable<T80>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do81(T81 t) { Nullable<T81> n = new Nullable<T81>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do82(T82 t) { Nullable<T82> n = new Nullable<T82>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do83(T83 t) { Nullable<T83> n = new Nullable<T83>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do84(T84 t) { Nullable<T84> n = new Nullable<T84>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do85(T85 t) { Nullable<T85> n = new Nullable<T85>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do86(T86 t) { Nullable<T86> n = new Nullable<T86>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do87(T87 t) { Nullable<T87> n = new Nullable<T87>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do88(T88 t) { Nullable<T88> n = new Nullable<T88>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do89(T89 t) { Nullable<T89> n = new Nullable<T89>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do90(T90 t) { Nullable<T90> n = new Nullable<T90>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do91(T91 t) { Nullable<T91> n = new Nullable<T91>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do92(T92 t) { Nullable<T92> n = new Nullable<T92>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do93(T93 t) { Nullable<T93> n = new Nullable<T93>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do94(T94 t) { Nullable<T94> n = new Nullable<T94>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do95(T95 t) { Nullable<T95> n = new Nullable<T95>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do96(T96 t) { Nullable<T96> n = new Nullable<T96>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do97(T97 t) { Nullable<T97> n = new Nullable<T97>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do98(T98 t) { Nullable<T98> n = new Nullable<T98>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do99(T99 t) { Nullable<T99> n = new Nullable<T99>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do100(T100 t) { Nullable<T100> n = new Nullable<T100>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do101(T101 t) { Nullable<T101> n = new Nullable<T101>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do102(T102 t) { Nullable<T102> n = new Nullable<T102>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do103(T103 t) { Nullable<T103> n = new Nullable<T103>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do104(T104 t) { Nullable<T104> n = new Nullable<T104>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do105(T105 t) { Nullable<T105> n = new Nullable<T105>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do106(T106 t) { Nullable<T106> n = new Nullable<T106>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do107(T107 t) { Nullable<T107> n = new Nullable<T107>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do108(T108 t) { Nullable<T108> n = new Nullable<T108>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do109(T109 t) { Nullable<T109> n = new Nullable<T109>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do110(T110 t) { Nullable<T110> n = new Nullable<T110>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do111(T111 t) { Nullable<T111> n = new Nullable<T111>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do112(T112 t) { Nullable<T112> n = new Nullable<T112>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do113(T113 t) { Nullable<T113> n = new Nullable<T113>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do114(T114 t) { Nullable<T114> n = new Nullable<T114>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do115(T115 t) { Nullable<T115> n = new Nullable<T115>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do116(T116 t) { Nullable<T116> n = new Nullable<T116>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do117(T117 t) { Nullable<T117> n = new Nullable<T117>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do118(T118 t) { Nullable<T118> n = new Nullable<T118>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do119(T119 t) { Nullable<T119> n = new Nullable<T119>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do120(T120 t) { Nullable<T120> n = new Nullable<T120>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do121(T121 t) { Nullable<T121> n = new Nullable<T121>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do122(T122 t) { Nullable<T122> n = new Nullable<T122>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do123(T123 t) { Nullable<T123> n = new Nullable<T123>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do124(T124 t) { Nullable<T124> n = new Nullable<T124>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do125(T125 t) { Nullable<T125> n = new Nullable<T125>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do126(T126 t) { Nullable<T126> n = new Nullable<T126>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do127(T127 t) { Nullable<T127> n = new Nullable<T127>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do128(T128 t) { Nullable<T128> n = new Nullable<T128>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do129(T129 t) { Nullable<T129> n = new Nullable<T129>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do130(T130 t) { Nullable<T130> n = new Nullable<T130>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do131(T131 t) { Nullable<T131> n = new Nullable<T131>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do132(T132 t) { Nullable<T132> n = new Nullable<T132>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do133(T133 t) { Nullable<T133> n = new Nullable<T133>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do134(T134 t) { Nullable<T134> n = new Nullable<T134>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do135(T135 t) { Nullable<T135> n = new Nullable<T135>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do136(T136 t) { Nullable<T136> n = new Nullable<T136>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do137(T137 t) { Nullable<T137> n = new Nullable<T137>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do138(T138 t) { Nullable<T138> n = new Nullable<T138>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do139(T139 t) { Nullable<T139> n = new Nullable<T139>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do140(T140 t) { Nullable<T140> n = new Nullable<T140>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do141(T141 t) { Nullable<T141> n = new Nullable<T141>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do142(T142 t) { Nullable<T142> n = new Nullable<T142>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do143(T143 t) { Nullable<T143> n = new Nullable<T143>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do144(T144 t) { Nullable<T144> n = new Nullable<T144>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do145(T145 t) { Nullable<T145> n = new Nullable<T145>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do146(T146 t) { Nullable<T146> n = new Nullable<T146>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do147(T147 t) { Nullable<T147> n = new Nullable<T147>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do148(T148 t) { Nullable<T148> n = new Nullable<T148>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do149(T149 t) { Nullable<T149> n = new Nullable<T149>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do150(T150 t) { Nullable<T150> n = new Nullable<T150>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do151(T151 t) { Nullable<T151> n = new Nullable<T151>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do152(T152 t) { Nullable<T152> n = new Nullable<T152>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do153(T153 t) { Nullable<T153> n = new Nullable<T153>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do154(T154 t) { Nullable<T154> n = new Nullable<T154>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do155(T155 t) { Nullable<T155> n = new Nullable<T155>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do156(T156 t) { Nullable<T156> n = new Nullable<T156>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do157(T157 t) { Nullable<T157> n = new Nullable<T157>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do158(T158 t) { Nullable<T158> n = new Nullable<T158>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do159(T159 t) { Nullable<T159> n = new Nullable<T159>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do160(T160 t) { Nullable<T160> n = new Nullable<T160>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do161(T161 t) { Nullable<T161> n = new Nullable<T161>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do162(T162 t) { Nullable<T162> n = new Nullable<T162>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do163(T163 t) { Nullable<T163> n = new Nullable<T163>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do164(T164 t) { Nullable<T164> n = new Nullable<T164>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do165(T165 t) { Nullable<T165> n = new Nullable<T165>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do166(T166 t) { Nullable<T166> n = new Nullable<T166>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do167(T167 t) { Nullable<T167> n = new Nullable<T167>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do168(T168 t) { Nullable<T168> n = new Nullable<T168>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do169(T169 t) { Nullable<T169> n = new Nullable<T169>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do170(T170 t) { Nullable<T170> n = new Nullable<T170>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do171(T171 t) { Nullable<T171> n = new Nullable<T171>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do172(T172 t) { Nullable<T172> n = new Nullable<T172>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do173(T173 t) { Nullable<T173> n = new Nullable<T173>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do174(T174 t) { Nullable<T174> n = new Nullable<T174>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do175(T175 t) { Nullable<T175> n = new Nullable<T175>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do176(T176 t) { Nullable<T176> n = new Nullable<T176>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do177(T177 t) { Nullable<T177> n = new Nullable<T177>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do178(T178 t) { Nullable<T178> n = new Nullable<T178>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do179(T179 t) { Nullable<T179> n = new Nullable<T179>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do180(T180 t) { Nullable<T180> n = new Nullable<T180>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do181(T181 t) { Nullable<T181> n = new Nullable<T181>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do182(T182 t) { Nullable<T182> n = new Nullable<T182>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do183(T183 t) { Nullable<T183> n = new Nullable<T183>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do184(T184 t) { Nullable<T184> n = new Nullable<T184>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do185(T185 t) { Nullable<T185> n = new Nullable<T185>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do186(T186 t) { Nullable<T186> n = new Nullable<T186>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do187(T187 t) { Nullable<T187> n = new Nullable<T187>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do188(T188 t) { Nullable<T188> n = new Nullable<T188>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do189(T189 t) { Nullable<T189> n = new Nullable<T189>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do190(T190 t) { Nullable<T190> n = new Nullable<T190>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do191(T191 t) { Nullable<T191> n = new Nullable<T191>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do192(T192 t) { Nullable<T192> n = new Nullable<T192>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do193(T193 t) { Nullable<T193> n = new Nullable<T193>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do194(T194 t) { Nullable<T194> n = new Nullable<T194>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do195(T195 t) { Nullable<T195> n = new Nullable<T195>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do196(T196 t) { Nullable<T196> n = new Nullable<T196>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do197(T197 t) { Nullable<T197> n = new Nullable<T197>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do198(T198 t) { Nullable<T198> n = new Nullable<T198>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do199(T199 t) { Nullable<T199> n = new Nullable<T199>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do200(T200 t) { Nullable<T200> n = new Nullable<T200>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do201(T201 t) { Nullable<T201> n = new Nullable<T201>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do202(T202 t) { Nullable<T202> n = new Nullable<T202>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do203(T203 t) { Nullable<T203> n = new Nullable<T203>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do204(T204 t) { Nullable<T204> n = new Nullable<T204>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do205(T205 t) { Nullable<T205> n = new Nullable<T205>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do206(T206 t) { Nullable<T206> n = new Nullable<T206>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do207(T207 t) { Nullable<T207> n = new Nullable<T207>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do208(T208 t) { Nullable<T208> n = new Nullable<T208>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do209(T209 t) { Nullable<T209> n = new Nullable<T209>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do210(T210 t) { Nullable<T210> n = new Nullable<T210>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do211(T211 t) { Nullable<T211> n = new Nullable<T211>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do212(T212 t) { Nullable<T212> n = new Nullable<T212>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do213(T213 t) { Nullable<T213> n = new Nullable<T213>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do214(T214 t) { Nullable<T214> n = new Nullable<T214>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do215(T215 t) { Nullable<T215> n = new Nullable<T215>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do216(T216 t) { Nullable<T216> n = new Nullable<T216>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do217(T217 t) { Nullable<T217> n = new Nullable<T217>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do218(T218 t) { Nullable<T218> n = new Nullable<T218>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do219(T219 t) { Nullable<T219> n = new Nullable<T219>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do220(T220 t) { Nullable<T220> n = new Nullable<T220>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do221(T221 t) { Nullable<T221> n = new Nullable<T221>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do222(T222 t) { Nullable<T222> n = new Nullable<T222>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do223(T223 t) { Nullable<T223> n = new Nullable<T223>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do224(T224 t) { Nullable<T224> n = new Nullable<T224>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do225(T225 t) { Nullable<T225> n = new Nullable<T225>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do226(T226 t) { Nullable<T226> n = new Nullable<T226>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do227(T227 t) { Nullable<T227> n = new Nullable<T227>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do228(T228 t) { Nullable<T228> n = new Nullable<T228>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do229(T229 t) { Nullable<T229> n = new Nullable<T229>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do230(T230 t) { Nullable<T230> n = new Nullable<T230>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do231(T231 t) { Nullable<T231> n = new Nullable<T231>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do232(T232 t) { Nullable<T232> n = new Nullable<T232>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do233(T233 t) { Nullable<T233> n = new Nullable<T233>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do234(T234 t) { Nullable<T234> n = new Nullable<T234>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do235(T235 t) { Nullable<T235> n = new Nullable<T235>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do236(T236 t) { Nullable<T236> n = new Nullable<T236>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do237(T237 t) { Nullable<T237> n = new Nullable<T237>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do238(T238 t) { Nullable<T238> n = new Nullable<T238>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do239(T239 t) { Nullable<T239> n = new Nullable<T239>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do240(T240 t) { Nullable<T240> n = new Nullable<T240>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do241(T241 t) { Nullable<T241> n = new Nullable<T241>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do242(T242 t) { Nullable<T242> n = new Nullable<T242>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do243(T243 t) { Nullable<T243> n = new Nullable<T243>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do244(T244 t) { Nullable<T244> n = new Nullable<T244>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do245(T245 t) { Nullable<T245> n = new Nullable<T245>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do246(T246 t) { Nullable<T246> n = new Nullable<T246>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do247(T247 t) { Nullable<T247> n = new Nullable<T247>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do248(T248 t) { Nullable<T248> n = new Nullable<T248>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do249(T249 t) { Nullable<T249> n = new Nullable<T249>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do250(T250 t) { Nullable<T250> n = new Nullable<T250>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do251(T251 t) { Nullable<T251> n = new Nullable<T251>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do252(T252 t) { Nullable<T252> n = new Nullable<T252>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do253(T253 t) { Nullable<T253> n = new Nullable<T253>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do254(T254 t) { Nullable<T254> n = new Nullable<T254>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do255(T255 t) { Nullable<T255> n = new Nullable<T255>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do256(T256 t) { Nullable<T256> n = new Nullable<T256>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do257(T257 t) { Nullable<T257> n = new Nullable<T257>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do258(T258 t) { Nullable<T258> n = new Nullable<T258>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do259(T259 t) { Nullable<T259> n = new Nullable<T259>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do260(T260 t) { Nullable<T260> n = new Nullable<T260>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do261(T261 t) { Nullable<T261> n = new Nullable<T261>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do262(T262 t) { Nullable<T262> n = new Nullable<T262>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do263(T263 t) { Nullable<T263> n = new Nullable<T263>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do264(T264 t) { Nullable<T264> n = new Nullable<T264>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do265(T265 t) { Nullable<T265> n = new Nullable<T265>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do266(T266 t) { Nullable<T266> n = new Nullable<T266>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do267(T267 t) { Nullable<T267> n = new Nullable<T267>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do268(T268 t) { Nullable<T268> n = new Nullable<T268>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do269(T269 t) { Nullable<T269> n = new Nullable<T269>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do270(T270 t) { Nullable<T270> n = new Nullable<T270>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do271(T271 t) { Nullable<T271> n = new Nullable<T271>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do272(T272 t) { Nullable<T272> n = new Nullable<T272>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do273(T273 t) { Nullable<T273> n = new Nullable<T273>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do274(T274 t) { Nullable<T274> n = new Nullable<T274>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do275(T275 t) { Nullable<T275> n = new Nullable<T275>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do276(T276 t) { Nullable<T276> n = new Nullable<T276>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do277(T277 t) { Nullable<T277> n = new Nullable<T277>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do278(T278 t) { Nullable<T278> n = new Nullable<T278>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do279(T279 t) { Nullable<T279> n = new Nullable<T279>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do280(T280 t) { Nullable<T280> n = new Nullable<T280>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do281(T281 t) { Nullable<T281> n = new Nullable<T281>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do282(T282 t) { Nullable<T282> n = new Nullable<T282>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do283(T283 t) { Nullable<T283> n = new Nullable<T283>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do284(T284 t) { Nullable<T284> n = new Nullable<T284>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do285(T285 t) { Nullable<T285> n = new Nullable<T285>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do286(T286 t) { Nullable<T286> n = new Nullable<T286>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do287(T287 t) { Nullable<T287> n = new Nullable<T287>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do288(T288 t) { Nullable<T288> n = new Nullable<T288>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do289(T289 t) { Nullable<T289> n = new Nullable<T289>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do290(T290 t) { Nullable<T290> n = new Nullable<T290>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do291(T291 t) { Nullable<T291> n = new Nullable<T291>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do292(T292 t) { Nullable<T292> n = new Nullable<T292>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do293(T293 t) { Nullable<T293> n = new Nullable<T293>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do294(T294 t) { Nullable<T294> n = new Nullable<T294>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do295(T295 t) { Nullable<T295> n = new Nullable<T295>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do296(T296 t) { Nullable<T296> n = new Nullable<T296>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do297(T297 t) { Nullable<T297> n = new Nullable<T297>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do298(T298 t) { Nullable<T298> n = new Nullable<T298>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do299(T299 t) { Nullable<T299> n = new Nullable<T299>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do300(T300 t) { Nullable<T300> n = new Nullable<T300>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do301(T301 t) { Nullable<T301> n = new Nullable<T301>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do302(T302 t) { Nullable<T302> n = new Nullable<T302>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do303(T303 t) { Nullable<T303> n = new Nullable<T303>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do304(T304 t) { Nullable<T304> n = new Nullable<T304>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do305(T305 t) { Nullable<T305> n = new Nullable<T305>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do306(T306 t) { Nullable<T306> n = new Nullable<T306>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do307(T307 t) { Nullable<T307> n = new Nullable<T307>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do308(T308 t) { Nullable<T308> n = new Nullable<T308>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do309(T309 t) { Nullable<T309> n = new Nullable<T309>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do310(T310 t) { Nullable<T310> n = new Nullable<T310>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do311(T311 t) { Nullable<T311> n = new Nullable<T311>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do312(T312 t) { Nullable<T312> n = new Nullable<T312>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do313(T313 t) { Nullable<T313> n = new Nullable<T313>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do314(T314 t) { Nullable<T314> n = new Nullable<T314>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do315(T315 t) { Nullable<T315> n = new Nullable<T315>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do316(T316 t) { Nullable<T316> n = new Nullable<T316>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do317(T317 t) { Nullable<T317> n = new Nullable<T317>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do318(T318 t) { Nullable<T318> n = new Nullable<T318>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do319(T319 t) { Nullable<T319> n = new Nullable<T319>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do320(T320 t) { Nullable<T320> n = new Nullable<T320>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do321(T321 t) { Nullable<T321> n = new Nullable<T321>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do322(T322 t) { Nullable<T322> n = new Nullable<T322>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do323(T323 t) { Nullable<T323> n = new Nullable<T323>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do324(T324 t) { Nullable<T324> n = new Nullable<T324>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do325(T325 t) { Nullable<T325> n = new Nullable<T325>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do326(T326 t) { Nullable<T326> n = new Nullable<T326>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do327(T327 t) { Nullable<T327> n = new Nullable<T327>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do328(T328 t) { Nullable<T328> n = new Nullable<T328>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do329(T329 t) { Nullable<T329> n = new Nullable<T329>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do330(T330 t) { Nullable<T330> n = new Nullable<T330>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do331(T331 t) { Nullable<T331> n = new Nullable<T331>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do332(T332 t) { Nullable<T332> n = new Nullable<T332>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do333(T333 t) { Nullable<T333> n = new Nullable<T333>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do334(T334 t) { Nullable<T334> n = new Nullable<T334>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do335(T335 t) { Nullable<T335> n = new Nullable<T335>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do336(T336 t) { Nullable<T336> n = new Nullable<T336>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do337(T337 t) { Nullable<T337> n = new Nullable<T337>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do338(T338 t) { Nullable<T338> n = new Nullable<T338>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do339(T339 t) { Nullable<T339> n = new Nullable<T339>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do340(T340 t) { Nullable<T340> n = new Nullable<T340>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do341(T341 t) { Nullable<T341> n = new Nullable<T341>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do342(T342 t) { Nullable<T342> n = new Nullable<T342>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do343(T343 t) { Nullable<T343> n = new Nullable<T343>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do344(T344 t) { Nullable<T344> n = new Nullable<T344>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do345(T345 t) { Nullable<T345> n = new Nullable<T345>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do346(T346 t) { Nullable<T346> n = new Nullable<T346>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do347(T347 t) { Nullable<T347> n = new Nullable<T347>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do348(T348 t) { Nullable<T348> n = new Nullable<T348>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do349(T349 t) { Nullable<T349> n = new Nullable<T349>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do350(T350 t) { Nullable<T350> n = new Nullable<T350>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do351(T351 t) { Nullable<T351> n = new Nullable<T351>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do352(T352 t) { Nullable<T352> n = new Nullable<T352>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do353(T353 t) { Nullable<T353> n = new Nullable<T353>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do354(T354 t) { Nullable<T354> n = new Nullable<T354>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do355(T355 t) { Nullable<T355> n = new Nullable<T355>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do356(T356 t) { Nullable<T356> n = new Nullable<T356>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do357(T357 t) { Nullable<T357> n = new Nullable<T357>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do358(T358 t) { Nullable<T358> n = new Nullable<T358>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do359(T359 t) { Nullable<T359> n = new Nullable<T359>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do360(T360 t) { Nullable<T360> n = new Nullable<T360>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do361(T361 t) { Nullable<T361> n = new Nullable<T361>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do362(T362 t) { Nullable<T362> n = new Nullable<T362>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do363(T363 t) { Nullable<T363> n = new Nullable<T363>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do364(T364 t) { Nullable<T364> n = new Nullable<T364>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do365(T365 t) { Nullable<T365> n = new Nullable<T365>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do366(T366 t) { Nullable<T366> n = new Nullable<T366>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do367(T367 t) { Nullable<T367> n = new Nullable<T367>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do368(T368 t) { Nullable<T368> n = new Nullable<T368>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do369(T369 t) { Nullable<T369> n = new Nullable<T369>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do370(T370 t) { Nullable<T370> n = new Nullable<T370>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do371(T371 t) { Nullable<T371> n = new Nullable<T371>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do372(T372 t) { Nullable<T372> n = new Nullable<T372>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do373(T373 t) { Nullable<T373> n = new Nullable<T373>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do374(T374 t) { Nullable<T374> n = new Nullable<T374>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do375(T375 t) { Nullable<T375> n = new Nullable<T375>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do376(T376 t) { Nullable<T376> n = new Nullable<T376>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do377(T377 t) { Nullable<T377> n = new Nullable<T377>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do378(T378 t) { Nullable<T378> n = new Nullable<T378>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do379(T379 t) { Nullable<T379> n = new Nullable<T379>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do380(T380 t) { Nullable<T380> n = new Nullable<T380>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do381(T381 t) { Nullable<T381> n = new Nullable<T381>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do382(T382 t) { Nullable<T382> n = new Nullable<T382>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do383(T383 t) { Nullable<T383> n = new Nullable<T383>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do384(T384 t) { Nullable<T384> n = new Nullable<T384>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do385(T385 t) { Nullable<T385> n = new Nullable<T385>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do386(T386 t) { Nullable<T386> n = new Nullable<T386>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do387(T387 t) { Nullable<T387> n = new Nullable<T387>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do388(T388 t) { Nullable<T388> n = new Nullable<T388>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do389(T389 t) { Nullable<T389> n = new Nullable<T389>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do390(T390 t) { Nullable<T390> n = new Nullable<T390>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do391(T391 t) { Nullable<T391> n = new Nullable<T391>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do392(T392 t) { Nullable<T392> n = new Nullable<T392>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do393(T393 t) { Nullable<T393> n = new Nullable<T393>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do394(T394 t) { Nullable<T394> n = new Nullable<T394>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do395(T395 t) { Nullable<T395> n = new Nullable<T395>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do396(T396 t) { Nullable<T396> n = new Nullable<T396>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do397(T397 t) { Nullable<T397> n = new Nullable<T397>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do398(T398 t) { Nullable<T398> n = new Nullable<T398>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do399(T399 t) { Nullable<T399> n = new Nullable<T399>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do400(T400 t) { Nullable<T400> n = new Nullable<T400>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do401(T401 t) { Nullable<T401> n = new Nullable<T401>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do402(T402 t) { Nullable<T402> n = new Nullable<T402>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do403(T403 t) { Nullable<T403> n = new Nullable<T403>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do404(T404 t) { Nullable<T404> n = new Nullable<T404>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do405(T405 t) { Nullable<T405> n = new Nullable<T405>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do406(T406 t) { Nullable<T406> n = new Nullable<T406>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do407(T407 t) { Nullable<T407> n = new Nullable<T407>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do408(T408 t) { Nullable<T408> n = new Nullable<T408>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do409(T409 t) { Nullable<T409> n = new Nullable<T409>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do410(T410 t) { Nullable<T410> n = new Nullable<T410>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do411(T411 t) { Nullable<T411> n = new Nullable<T411>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do412(T412 t) { Nullable<T412> n = new Nullable<T412>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do413(T413 t) { Nullable<T413> n = new Nullable<T413>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do414(T414 t) { Nullable<T414> n = new Nullable<T414>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do415(T415 t) { Nullable<T415> n = new Nullable<T415>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do416(T416 t) { Nullable<T416> n = new Nullable<T416>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do417(T417 t) { Nullable<T417> n = new Nullable<T417>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do418(T418 t) { Nullable<T418> n = new Nullable<T418>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do419(T419 t) { Nullable<T419> n = new Nullable<T419>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do420(T420 t) { Nullable<T420> n = new Nullable<T420>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do421(T421 t) { Nullable<T421> n = new Nullable<T421>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do422(T422 t) { Nullable<T422> n = new Nullable<T422>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do423(T423 t) { Nullable<T423> n = new Nullable<T423>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do424(T424 t) { Nullable<T424> n = new Nullable<T424>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do425(T425 t) { Nullable<T425> n = new Nullable<T425>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do426(T426 t) { Nullable<T426> n = new Nullable<T426>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do427(T427 t) { Nullable<T427> n = new Nullable<T427>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do428(T428 t) { Nullable<T428> n = new Nullable<T428>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do429(T429 t) { Nullable<T429> n = new Nullable<T429>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do430(T430 t) { Nullable<T430> n = new Nullable<T430>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do431(T431 t) { Nullable<T431> n = new Nullable<T431>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do432(T432 t) { Nullable<T432> n = new Nullable<T432>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do433(T433 t) { Nullable<T433> n = new Nullable<T433>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do434(T434 t) { Nullable<T434> n = new Nullable<T434>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do435(T435 t) { Nullable<T435> n = new Nullable<T435>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do436(T436 t) { Nullable<T436> n = new Nullable<T436>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do437(T437 t) { Nullable<T437> n = new Nullable<T437>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do438(T438 t) { Nullable<T438> n = new Nullable<T438>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do439(T439 t) { Nullable<T439> n = new Nullable<T439>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do440(T440 t) { Nullable<T440> n = new Nullable<T440>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do441(T441 t) { Nullable<T441> n = new Nullable<T441>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do442(T442 t) { Nullable<T442> n = new Nullable<T442>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do443(T443 t) { Nullable<T443> n = new Nullable<T443>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do444(T444 t) { Nullable<T444> n = new Nullable<T444>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do445(T445 t) { Nullable<T445> n = new Nullable<T445>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do446(T446 t) { Nullable<T446> n = new Nullable<T446>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do447(T447 t) { Nullable<T447> n = new Nullable<T447>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do448(T448 t) { Nullable<T448> n = new Nullable<T448>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do449(T449 t) { Nullable<T449> n = new Nullable<T449>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do450(T450 t) { Nullable<T450> n = new Nullable<T450>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do451(T451 t) { Nullable<T451> n = new Nullable<T451>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do452(T452 t) { Nullable<T452> n = new Nullable<T452>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do453(T453 t) { Nullable<T453> n = new Nullable<T453>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do454(T454 t) { Nullable<T454> n = new Nullable<T454>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do455(T455 t) { Nullable<T455> n = new Nullable<T455>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do456(T456 t) { Nullable<T456> n = new Nullable<T456>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do457(T457 t) { Nullable<T457> n = new Nullable<T457>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do458(T458 t) { Nullable<T458> n = new Nullable<T458>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do459(T459 t) { Nullable<T459> n = new Nullable<T459>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do460(T460 t) { Nullable<T460> n = new Nullable<T460>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do461(T461 t) { Nullable<T461> n = new Nullable<T461>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do462(T462 t) { Nullable<T462> n = new Nullable<T462>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do463(T463 t) { Nullable<T463> n = new Nullable<T463>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do464(T464 t) { Nullable<T464> n = new Nullable<T464>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do465(T465 t) { Nullable<T465> n = new Nullable<T465>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do466(T466 t) { Nullable<T466> n = new Nullable<T466>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do467(T467 t) { Nullable<T467> n = new Nullable<T467>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do468(T468 t) { Nullable<T468> n = new Nullable<T468>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do469(T469 t) { Nullable<T469> n = new Nullable<T469>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do470(T470 t) { Nullable<T470> n = new Nullable<T470>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do471(T471 t) { Nullable<T471> n = new Nullable<T471>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do472(T472 t) { Nullable<T472> n = new Nullable<T472>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do473(T473 t) { Nullable<T473> n = new Nullable<T473>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do474(T474 t) { Nullable<T474> n = new Nullable<T474>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do475(T475 t) { Nullable<T475> n = new Nullable<T475>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do476(T476 t) { Nullable<T476> n = new Nullable<T476>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do477(T477 t) { Nullable<T477> n = new Nullable<T477>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do478(T478 t) { Nullable<T478> n = new Nullable<T478>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do479(T479 t) { Nullable<T479> n = new Nullable<T479>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do480(T480 t) { Nullable<T480> n = new Nullable<T480>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do481(T481 t) { Nullable<T481> n = new Nullable<T481>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do482(T482 t) { Nullable<T482> n = new Nullable<T482>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do483(T483 t) { Nullable<T483> n = new Nullable<T483>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do484(T484 t) { Nullable<T484> n = new Nullable<T484>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do485(T485 t) { Nullable<T485> n = new Nullable<T485>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do486(T486 t) { Nullable<T486> n = new Nullable<T486>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do487(T487 t) { Nullable<T487> n = new Nullable<T487>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do488(T488 t) { Nullable<T488> n = new Nullable<T488>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do489(T489 t) { Nullable<T489> n = new Nullable<T489>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do490(T490 t) { Nullable<T490> n = new Nullable<T490>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do491(T491 t) { Nullable<T491> n = new Nullable<T491>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do492(T492 t) { Nullable<T492> n = new Nullable<T492>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do493(T493 t) { Nullable<T493> n = new Nullable<T493>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do494(T494 t) { Nullable<T494> n = new Nullable<T494>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do495(T495 t) { Nullable<T495> n = new Nullable<T495>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do496(T496 t) { Nullable<T496> n = new Nullable<T496>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do497(T497 t) { Nullable<T497> n = new Nullable<T497>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do498(T498 t) { Nullable<T498> n = new Nullable<T498>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do499(T499 t) { Nullable<T499> n = new Nullable<T499>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do500(T500 t) { Nullable<T500> n = new Nullable<T500>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do501(T501 t) { Nullable<T501> n = new Nullable<T501>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do502(T502 t) { Nullable<T502> n = new Nullable<T502>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do503(T503 t) { Nullable<T503> n = new Nullable<T503>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do504(T504 t) { Nullable<T504> n = new Nullable<T504>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do505(T505 t) { Nullable<T505> n = new Nullable<T505>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do506(T506 t) { Nullable<T506> n = new Nullable<T506>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do507(T507 t) { Nullable<T507> n = new Nullable<T507>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do508(T508 t) { Nullable<T508> n = new Nullable<T508>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do509(T509 t) { Nullable<T509> n = new Nullable<T509>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do510(T510 t) { Nullable<T510> n = new Nullable<T510>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do511(T511 t) { Nullable<T511> n = new Nullable<T511>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do512(T512 t) { Nullable<T512> n = new Nullable<T512>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do513(T513 t) { Nullable<T513> n = new Nullable<T513>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do514(T514 t) { Nullable<T514> n = new Nullable<T514>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do515(T515 t) { Nullable<T515> n = new Nullable<T515>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do516(T516 t) { Nullable<T516> n = new Nullable<T516>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do517(T517 t) { Nullable<T517> n = new Nullable<T517>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do518(T518 t) { Nullable<T518> n = new Nullable<T518>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do519(T519 t) { Nullable<T519> n = new Nullable<T519>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do520(T520 t) { Nullable<T520> n = new Nullable<T520>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do521(T521 t) { Nullable<T521> n = new Nullable<T521>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do522(T522 t) { Nullable<T522> n = new Nullable<T522>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do523(T523 t) { Nullable<T523> n = new Nullable<T523>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do524(T524 t) { Nullable<T524> n = new Nullable<T524>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do525(T525 t) { Nullable<T525> n = new Nullable<T525>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do526(T526 t) { Nullable<T526> n = new Nullable<T526>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do527(T527 t) { Nullable<T527> n = new Nullable<T527>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do528(T528 t) { Nullable<T528> n = new Nullable<T528>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do529(T529 t) { Nullable<T529> n = new Nullable<T529>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do530(T530 t) { Nullable<T530> n = new Nullable<T530>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do531(T531 t) { Nullable<T531> n = new Nullable<T531>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do532(T532 t) { Nullable<T532> n = new Nullable<T532>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do533(T533 t) { Nullable<T533> n = new Nullable<T533>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do534(T534 t) { Nullable<T534> n = new Nullable<T534>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do535(T535 t) { Nullable<T535> n = new Nullable<T535>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do536(T536 t) { Nullable<T536> n = new Nullable<T536>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do537(T537 t) { Nullable<T537> n = new Nullable<T537>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do538(T538 t) { Nullable<T538> n = new Nullable<T538>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do539(T539 t) { Nullable<T539> n = new Nullable<T539>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do540(T540 t) { Nullable<T540> n = new Nullable<T540>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do541(T541 t) { Nullable<T541> n = new Nullable<T541>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do542(T542 t) { Nullable<T542> n = new Nullable<T542>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do543(T543 t) { Nullable<T543> n = new Nullable<T543>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do544(T544 t) { Nullable<T544> n = new Nullable<T544>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do545(T545 t) { Nullable<T545> n = new Nullable<T545>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do546(T546 t) { Nullable<T546> n = new Nullable<T546>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do547(T547 t) { Nullable<T547> n = new Nullable<T547>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do548(T548 t) { Nullable<T548> n = new Nullable<T548>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do549(T549 t) { Nullable<T549> n = new Nullable<T549>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do550(T550 t) { Nullable<T550> n = new Nullable<T550>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do551(T551 t) { Nullable<T551> n = new Nullable<T551>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do552(T552 t) { Nullable<T552> n = new Nullable<T552>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do553(T553 t) { Nullable<T553> n = new Nullable<T553>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do554(T554 t) { Nullable<T554> n = new Nullable<T554>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do555(T555 t) { Nullable<T555> n = new Nullable<T555>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do556(T556 t) { Nullable<T556> n = new Nullable<T556>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do557(T557 t) { Nullable<T557> n = new Nullable<T557>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do558(T558 t) { Nullable<T558> n = new Nullable<T558>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do559(T559 t) { Nullable<T559> n = new Nullable<T559>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do560(T560 t) { Nullable<T560> n = new Nullable<T560>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do561(T561 t) { Nullable<T561> n = new Nullable<T561>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do562(T562 t) { Nullable<T562> n = new Nullable<T562>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do563(T563 t) { Nullable<T563> n = new Nullable<T563>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do564(T564 t) { Nullable<T564> n = new Nullable<T564>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do565(T565 t) { Nullable<T565> n = new Nullable<T565>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do566(T566 t) { Nullable<T566> n = new Nullable<T566>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do567(T567 t) { Nullable<T567> n = new Nullable<T567>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do568(T568 t) { Nullable<T568> n = new Nullable<T568>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do569(T569 t) { Nullable<T569> n = new Nullable<T569>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do570(T570 t) { Nullable<T570> n = new Nullable<T570>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do571(T571 t) { Nullable<T571> n = new Nullable<T571>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do572(T572 t) { Nullable<T572> n = new Nullable<T572>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do573(T573 t) { Nullable<T573> n = new Nullable<T573>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do574(T574 t) { Nullable<T574> n = new Nullable<T574>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do575(T575 t) { Nullable<T575> n = new Nullable<T575>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do576(T576 t) { Nullable<T576> n = new Nullable<T576>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do577(T577 t) { Nullable<T577> n = new Nullable<T577>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do578(T578 t) { Nullable<T578> n = new Nullable<T578>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do579(T579 t) { Nullable<T579> n = new Nullable<T579>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do580(T580 t) { Nullable<T580> n = new Nullable<T580>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do581(T581 t) { Nullable<T581> n = new Nullable<T581>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do582(T582 t) { Nullable<T582> n = new Nullable<T582>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do583(T583 t) { Nullable<T583> n = new Nullable<T583>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do584(T584 t) { Nullable<T584> n = new Nullable<T584>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do585(T585 t) { Nullable<T585> n = new Nullable<T585>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do586(T586 t) { Nullable<T586> n = new Nullable<T586>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do587(T587 t) { Nullable<T587> n = new Nullable<T587>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do588(T588 t) { Nullable<T588> n = new Nullable<T588>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do589(T589 t) { Nullable<T589> n = new Nullable<T589>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do590(T590 t) { Nullable<T590> n = new Nullable<T590>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do591(T591 t) { Nullable<T591> n = new Nullable<T591>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do592(T592 t) { Nullable<T592> n = new Nullable<T592>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do593(T593 t) { Nullable<T593> n = new Nullable<T593>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do594(T594 t) { Nullable<T594> n = new Nullable<T594>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do595(T595 t) { Nullable<T595> n = new Nullable<T595>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do596(T596 t) { Nullable<T596> n = new Nullable<T596>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do597(T597 t) { Nullable<T597> n = new Nullable<T597>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do598(T598 t) { Nullable<T598> n = new Nullable<T598>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do599(T599 t) { Nullable<T599> n = new Nullable<T599>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do600(T600 t) { Nullable<T600> n = new Nullable<T600>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do601(T601 t) { Nullable<T601> n = new Nullable<T601>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do602(T602 t) { Nullable<T602> n = new Nullable<T602>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do603(T603 t) { Nullable<T603> n = new Nullable<T603>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do604(T604 t) { Nullable<T604> n = new Nullable<T604>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do605(T605 t) { Nullable<T605> n = new Nullable<T605>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do606(T606 t) { Nullable<T606> n = new Nullable<T606>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do607(T607 t) { Nullable<T607> n = new Nullable<T607>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do608(T608 t) { Nullable<T608> n = new Nullable<T608>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do609(T609 t) { Nullable<T609> n = new Nullable<T609>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do610(T610 t) { Nullable<T610> n = new Nullable<T610>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do611(T611 t) { Nullable<T611> n = new Nullable<T611>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do612(T612 t) { Nullable<T612> n = new Nullable<T612>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do613(T613 t) { Nullable<T613> n = new Nullable<T613>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do614(T614 t) { Nullable<T614> n = new Nullable<T614>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do615(T615 t) { Nullable<T615> n = new Nullable<T615>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do616(T616 t) { Nullable<T616> n = new Nullable<T616>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do617(T617 t) { Nullable<T617> n = new Nullable<T617>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do618(T618 t) { Nullable<T618> n = new Nullable<T618>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do619(T619 t) { Nullable<T619> n = new Nullable<T619>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do620(T620 t) { Nullable<T620> n = new Nullable<T620>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do621(T621 t) { Nullable<T621> n = new Nullable<T621>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do622(T622 t) { Nullable<T622> n = new Nullable<T622>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do623(T623 t) { Nullable<T623> n = new Nullable<T623>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do624(T624 t) { Nullable<T624> n = new Nullable<T624>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do625(T625 t) { Nullable<T625> n = new Nullable<T625>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do626(T626 t) { Nullable<T626> n = new Nullable<T626>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do627(T627 t) { Nullable<T627> n = new Nullable<T627>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do628(T628 t) { Nullable<T628> n = new Nullable<T628>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do629(T629 t) { Nullable<T629> n = new Nullable<T629>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do630(T630 t) { Nullable<T630> n = new Nullable<T630>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do631(T631 t) { Nullable<T631> n = new Nullable<T631>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do632(T632 t) { Nullable<T632> n = new Nullable<T632>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do633(T633 t) { Nullable<T633> n = new Nullable<T633>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do634(T634 t) { Nullable<T634> n = new Nullable<T634>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do635(T635 t) { Nullable<T635> n = new Nullable<T635>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do636(T636 t) { Nullable<T636> n = new Nullable<T636>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do637(T637 t) { Nullable<T637> n = new Nullable<T637>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do638(T638 t) { Nullable<T638> n = new Nullable<T638>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do639(T639 t) { Nullable<T639> n = new Nullable<T639>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do640(T640 t) { Nullable<T640> n = new Nullable<T640>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do641(T641 t) { Nullable<T641> n = new Nullable<T641>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do642(T642 t) { Nullable<T642> n = new Nullable<T642>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do643(T643 t) { Nullable<T643> n = new Nullable<T643>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do644(T644 t) { Nullable<T644> n = new Nullable<T644>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do645(T645 t) { Nullable<T645> n = new Nullable<T645>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do646(T646 t) { Nullable<T646> n = new Nullable<T646>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do647(T647 t) { Nullable<T647> n = new Nullable<T647>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do648(T648 t) { Nullable<T648> n = new Nullable<T648>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do649(T649 t) { Nullable<T649> n = new Nullable<T649>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do650(T650 t) { Nullable<T650> n = new Nullable<T650>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do651(T651 t) { Nullable<T651> n = new Nullable<T651>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do652(T652 t) { Nullable<T652> n = new Nullable<T652>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do653(T653 t) { Nullable<T653> n = new Nullable<T653>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do654(T654 t) { Nullable<T654> n = new Nullable<T654>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do655(T655 t) { Nullable<T655> n = new Nullable<T655>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do656(T656 t) { Nullable<T656> n = new Nullable<T656>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do657(T657 t) { Nullable<T657> n = new Nullable<T657>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do658(T658 t) { Nullable<T658> n = new Nullable<T658>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do659(T659 t) { Nullable<T659> n = new Nullable<T659>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do660(T660 t) { Nullable<T660> n = new Nullable<T660>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do661(T661 t) { Nullable<T661> n = new Nullable<T661>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do662(T662 t) { Nullable<T662> n = new Nullable<T662>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do663(T663 t) { Nullable<T663> n = new Nullable<T663>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do664(T664 t) { Nullable<T664> n = new Nullable<T664>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do665(T665 t) { Nullable<T665> n = new Nullable<T665>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do666(T666 t) { Nullable<T666> n = new Nullable<T666>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do667(T667 t) { Nullable<T667> n = new Nullable<T667>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do668(T668 t) { Nullable<T668> n = new Nullable<T668>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do669(T669 t) { Nullable<T669> n = new Nullable<T669>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do670(T670 t) { Nullable<T670> n = new Nullable<T670>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do671(T671 t) { Nullable<T671> n = new Nullable<T671>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do672(T672 t) { Nullable<T672> n = new Nullable<T672>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do673(T673 t) { Nullable<T673> n = new Nullable<T673>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do674(T674 t) { Nullable<T674> n = new Nullable<T674>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do675(T675 t) { Nullable<T675> n = new Nullable<T675>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do676(T676 t) { Nullable<T676> n = new Nullable<T676>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do677(T677 t) { Nullable<T677> n = new Nullable<T677>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do678(T678 t) { Nullable<T678> n = new Nullable<T678>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do679(T679 t) { Nullable<T679> n = new Nullable<T679>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do680(T680 t) { Nullable<T680> n = new Nullable<T680>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do681(T681 t) { Nullable<T681> n = new Nullable<T681>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do682(T682 t) { Nullable<T682> n = new Nullable<T682>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do683(T683 t) { Nullable<T683> n = new Nullable<T683>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do684(T684 t) { Nullable<T684> n = new Nullable<T684>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do685(T685 t) { Nullable<T685> n = new Nullable<T685>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do686(T686 t) { Nullable<T686> n = new Nullable<T686>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do687(T687 t) { Nullable<T687> n = new Nullable<T687>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do688(T688 t) { Nullable<T688> n = new Nullable<T688>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do689(T689 t) { Nullable<T689> n = new Nullable<T689>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do690(T690 t) { Nullable<T690> n = new Nullable<T690>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do691(T691 t) { Nullable<T691> n = new Nullable<T691>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do692(T692 t) { Nullable<T692> n = new Nullable<T692>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do693(T693 t) { Nullable<T693> n = new Nullable<T693>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do694(T694 t) { Nullable<T694> n = new Nullable<T694>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do695(T695 t) { Nullable<T695> n = new Nullable<T695>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do696(T696 t) { Nullable<T696> n = new Nullable<T696>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do697(T697 t) { Nullable<T697> n = new Nullable<T697>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do698(T698 t) { Nullable<T698> n = new Nullable<T698>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do699(T699 t) { Nullable<T699> n = new Nullable<T699>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do700(T700 t) { Nullable<T700> n = new Nullable<T700>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do701(T701 t) { Nullable<T701> n = new Nullable<T701>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do702(T702 t) { Nullable<T702> n = new Nullable<T702>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do703(T703 t) { Nullable<T703> n = new Nullable<T703>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do704(T704 t) { Nullable<T704> n = new Nullable<T704>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do705(T705 t) { Nullable<T705> n = new Nullable<T705>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do706(T706 t) { Nullable<T706> n = new Nullable<T706>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do707(T707 t) { Nullable<T707> n = new Nullable<T707>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do708(T708 t) { Nullable<T708> n = new Nullable<T708>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do709(T709 t) { Nullable<T709> n = new Nullable<T709>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do710(T710 t) { Nullable<T710> n = new Nullable<T710>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do711(T711 t) { Nullable<T711> n = new Nullable<T711>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do712(T712 t) { Nullable<T712> n = new Nullable<T712>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do713(T713 t) { Nullable<T713> n = new Nullable<T713>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do714(T714 t) { Nullable<T714> n = new Nullable<T714>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do715(T715 t) { Nullable<T715> n = new Nullable<T715>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do716(T716 t) { Nullable<T716> n = new Nullable<T716>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do717(T717 t) { Nullable<T717> n = new Nullable<T717>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do718(T718 t) { Nullable<T718> n = new Nullable<T718>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do719(T719 t) { Nullable<T719> n = new Nullable<T719>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do720(T720 t) { Nullable<T720> n = new Nullable<T720>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do721(T721 t) { Nullable<T721> n = new Nullable<T721>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do722(T722 t) { Nullable<T722> n = new Nullable<T722>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do723(T723 t) { Nullable<T723> n = new Nullable<T723>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do724(T724 t) { Nullable<T724> n = new Nullable<T724>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do725(T725 t) { Nullable<T725> n = new Nullable<T725>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do726(T726 t) { Nullable<T726> n = new Nullable<T726>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do727(T727 t) { Nullable<T727> n = new Nullable<T727>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do728(T728 t) { Nullable<T728> n = new Nullable<T728>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do729(T729 t) { Nullable<T729> n = new Nullable<T729>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do730(T730 t) { Nullable<T730> n = new Nullable<T730>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do731(T731 t) { Nullable<T731> n = new Nullable<T731>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do732(T732 t) { Nullable<T732> n = new Nullable<T732>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do733(T733 t) { Nullable<T733> n = new Nullable<T733>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do734(T734 t) { Nullable<T734> n = new Nullable<T734>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do735(T735 t) { Nullable<T735> n = new Nullable<T735>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do736(T736 t) { Nullable<T736> n = new Nullable<T736>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do737(T737 t) { Nullable<T737> n = new Nullable<T737>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do738(T738 t) { Nullable<T738> n = new Nullable<T738>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do739(T739 t) { Nullable<T739> n = new Nullable<T739>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do740(T740 t) { Nullable<T740> n = new Nullable<T740>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do741(T741 t) { Nullable<T741> n = new Nullable<T741>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do742(T742 t) { Nullable<T742> n = new Nullable<T742>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do743(T743 t) { Nullable<T743> n = new Nullable<T743>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do744(T744 t) { Nullable<T744> n = new Nullable<T744>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do745(T745 t) { Nullable<T745> n = new Nullable<T745>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do746(T746 t) { Nullable<T746> n = new Nullable<T746>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do747(T747 t) { Nullable<T747> n = new Nullable<T747>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do748(T748 t) { Nullable<T748> n = new Nullable<T748>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do749(T749 t) { Nullable<T749> n = new Nullable<T749>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do750(T750 t) { Nullable<T750> n = new Nullable<T750>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do751(T751 t) { Nullable<T751> n = new Nullable<T751>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do752(T752 t) { Nullable<T752> n = new Nullable<T752>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do753(T753 t) { Nullable<T753> n = new Nullable<T753>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do754(T754 t) { Nullable<T754> n = new Nullable<T754>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do755(T755 t) { Nullable<T755> n = new Nullable<T755>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do756(T756 t) { Nullable<T756> n = new Nullable<T756>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do757(T757 t) { Nullable<T757> n = new Nullable<T757>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do758(T758 t) { Nullable<T758> n = new Nullable<T758>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do759(T759 t) { Nullable<T759> n = new Nullable<T759>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do760(T760 t) { Nullable<T760> n = new Nullable<T760>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do761(T761 t) { Nullable<T761> n = new Nullable<T761>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do762(T762 t) { Nullable<T762> n = new Nullable<T762>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do763(T763 t) { Nullable<T763> n = new Nullable<T763>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do764(T764 t) { Nullable<T764> n = new Nullable<T764>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do765(T765 t) { Nullable<T765> n = new Nullable<T765>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do766(T766 t) { Nullable<T766> n = new Nullable<T766>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do767(T767 t) { Nullable<T767> n = new Nullable<T767>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do768(T768 t) { Nullable<T768> n = new Nullable<T768>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do769(T769 t) { Nullable<T769> n = new Nullable<T769>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do770(T770 t) { Nullable<T770> n = new Nullable<T770>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do771(T771 t) { Nullable<T771> n = new Nullable<T771>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do772(T772 t) { Nullable<T772> n = new Nullable<T772>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do773(T773 t) { Nullable<T773> n = new Nullable<T773>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do774(T774 t) { Nullable<T774> n = new Nullable<T774>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do775(T775 t) { Nullable<T775> n = new Nullable<T775>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do776(T776 t) { Nullable<T776> n = new Nullable<T776>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do777(T777 t) { Nullable<T777> n = new Nullable<T777>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do778(T778 t) { Nullable<T778> n = new Nullable<T778>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do779(T779 t) { Nullable<T779> n = new Nullable<T779>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do780(T780 t) { Nullable<T780> n = new Nullable<T780>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do781(T781 t) { Nullable<T781> n = new Nullable<T781>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do782(T782 t) { Nullable<T782> n = new Nullable<T782>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do783(T783 t) { Nullable<T783> n = new Nullable<T783>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do784(T784 t) { Nullable<T784> n = new Nullable<T784>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do785(T785 t) { Nullable<T785> n = new Nullable<T785>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do786(T786 t) { Nullable<T786> n = new Nullable<T786>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do787(T787 t) { Nullable<T787> n = new Nullable<T787>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do788(T788 t) { Nullable<T788> n = new Nullable<T788>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do789(T789 t) { Nullable<T789> n = new Nullable<T789>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do790(T790 t) { Nullable<T790> n = new Nullable<T790>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do791(T791 t) { Nullable<T791> n = new Nullable<T791>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do792(T792 t) { Nullable<T792> n = new Nullable<T792>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do793(T793 t) { Nullable<T793> n = new Nullable<T793>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do794(T794 t) { Nullable<T794> n = new Nullable<T794>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do795(T795 t) { Nullable<T795> n = new Nullable<T795>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do796(T796 t) { Nullable<T796> n = new Nullable<T796>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do797(T797 t) { Nullable<T797> n = new Nullable<T797>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do798(T798 t) { Nullable<T798> n = new Nullable<T798>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do799(T799 t) { Nullable<T799> n = new Nullable<T799>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do800(T800 t) { Nullable<T800> n = new Nullable<T800>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do801(T801 t) { Nullable<T801> n = new Nullable<T801>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do802(T802 t) { Nullable<T802> n = new Nullable<T802>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do803(T803 t) { Nullable<T803> n = new Nullable<T803>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do804(T804 t) { Nullable<T804> n = new Nullable<T804>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do805(T805 t) { Nullable<T805> n = new Nullable<T805>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do806(T806 t) { Nullable<T806> n = new Nullable<T806>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do807(T807 t) { Nullable<T807> n = new Nullable<T807>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do808(T808 t) { Nullable<T808> n = new Nullable<T808>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do809(T809 t) { Nullable<T809> n = new Nullable<T809>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do810(T810 t) { Nullable<T810> n = new Nullable<T810>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do811(T811 t) { Nullable<T811> n = new Nullable<T811>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do812(T812 t) { Nullable<T812> n = new Nullable<T812>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do813(T813 t) { Nullable<T813> n = new Nullable<T813>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do814(T814 t) { Nullable<T814> n = new Nullable<T814>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do815(T815 t) { Nullable<T815> n = new Nullable<T815>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do816(T816 t) { Nullable<T816> n = new Nullable<T816>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do817(T817 t) { Nullable<T817> n = new Nullable<T817>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do818(T818 t) { Nullable<T818> n = new Nullable<T818>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do819(T819 t) { Nullable<T819> n = new Nullable<T819>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do820(T820 t) { Nullable<T820> n = new Nullable<T820>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do821(T821 t) { Nullable<T821> n = new Nullable<T821>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do822(T822 t) { Nullable<T822> n = new Nullable<T822>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do823(T823 t) { Nullable<T823> n = new Nullable<T823>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do824(T824 t) { Nullable<T824> n = new Nullable<T824>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do825(T825 t) { Nullable<T825> n = new Nullable<T825>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do826(T826 t) { Nullable<T826> n = new Nullable<T826>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do827(T827 t) { Nullable<T827> n = new Nullable<T827>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do828(T828 t) { Nullable<T828> n = new Nullable<T828>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do829(T829 t) { Nullable<T829> n = new Nullable<T829>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do830(T830 t) { Nullable<T830> n = new Nullable<T830>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do831(T831 t) { Nullable<T831> n = new Nullable<T831>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do832(T832 t) { Nullable<T832> n = new Nullable<T832>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do833(T833 t) { Nullable<T833> n = new Nullable<T833>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do834(T834 t) { Nullable<T834> n = new Nullable<T834>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do835(T835 t) { Nullable<T835> n = new Nullable<T835>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do836(T836 t) { Nullable<T836> n = new Nullable<T836>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do837(T837 t) { Nullable<T837> n = new Nullable<T837>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do838(T838 t) { Nullable<T838> n = new Nullable<T838>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do839(T839 t) { Nullable<T839> n = new Nullable<T839>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do840(T840 t) { Nullable<T840> n = new Nullable<T840>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do841(T841 t) { Nullable<T841> n = new Nullable<T841>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do842(T842 t) { Nullable<T842> n = new Nullable<T842>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do843(T843 t) { Nullable<T843> n = new Nullable<T843>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do844(T844 t) { Nullable<T844> n = new Nullable<T844>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do845(T845 t) { Nullable<T845> n = new Nullable<T845>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do846(T846 t) { Nullable<T846> n = new Nullable<T846>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do847(T847 t) { Nullable<T847> n = new Nullable<T847>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do848(T848 t) { Nullable<T848> n = new Nullable<T848>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do849(T849 t) { Nullable<T849> n = new Nullable<T849>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do850(T850 t) { Nullable<T850> n = new Nullable<T850>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do851(T851 t) { Nullable<T851> n = new Nullable<T851>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do852(T852 t) { Nullable<T852> n = new Nullable<T852>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do853(T853 t) { Nullable<T853> n = new Nullable<T853>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do854(T854 t) { Nullable<T854> n = new Nullable<T854>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do855(T855 t) { Nullable<T855> n = new Nullable<T855>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do856(T856 t) { Nullable<T856> n = new Nullable<T856>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do857(T857 t) { Nullable<T857> n = new Nullable<T857>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do858(T858 t) { Nullable<T858> n = new Nullable<T858>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do859(T859 t) { Nullable<T859> n = new Nullable<T859>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do860(T860 t) { Nullable<T860> n = new Nullable<T860>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do861(T861 t) { Nullable<T861> n = new Nullable<T861>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do862(T862 t) { Nullable<T862> n = new Nullable<T862>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do863(T863 t) { Nullable<T863> n = new Nullable<T863>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do864(T864 t) { Nullable<T864> n = new Nullable<T864>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do865(T865 t) { Nullable<T865> n = new Nullable<T865>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do866(T866 t) { Nullable<T866> n = new Nullable<T866>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do867(T867 t) { Nullable<T867> n = new Nullable<T867>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do868(T868 t) { Nullable<T868> n = new Nullable<T868>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do869(T869 t) { Nullable<T869> n = new Nullable<T869>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do870(T870 t) { Nullable<T870> n = new Nullable<T870>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do871(T871 t) { Nullable<T871> n = new Nullable<T871>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do872(T872 t) { Nullable<T872> n = new Nullable<T872>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do873(T873 t) { Nullable<T873> n = new Nullable<T873>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do874(T874 t) { Nullable<T874> n = new Nullable<T874>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do875(T875 t) { Nullable<T875> n = new Nullable<T875>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do876(T876 t) { Nullable<T876> n = new Nullable<T876>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do877(T877 t) { Nullable<T877> n = new Nullable<T877>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do878(T878 t) { Nullable<T878> n = new Nullable<T878>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do879(T879 t) { Nullable<T879> n = new Nullable<T879>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do880(T880 t) { Nullable<T880> n = new Nullable<T880>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do881(T881 t) { Nullable<T881> n = new Nullable<T881>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do882(T882 t) { Nullable<T882> n = new Nullable<T882>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do883(T883 t) { Nullable<T883> n = new Nullable<T883>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do884(T884 t) { Nullable<T884> n = new Nullable<T884>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do885(T885 t) { Nullable<T885> n = new Nullable<T885>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do886(T886 t) { Nullable<T886> n = new Nullable<T886>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do887(T887 t) { Nullable<T887> n = new Nullable<T887>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do888(T888 t) { Nullable<T888> n = new Nullable<T888>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do889(T889 t) { Nullable<T889> n = new Nullable<T889>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do890(T890 t) { Nullable<T890> n = new Nullable<T890>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do891(T891 t) { Nullable<T891> n = new Nullable<T891>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do892(T892 t) { Nullable<T892> n = new Nullable<T892>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do893(T893 t) { Nullable<T893> n = new Nullable<T893>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do894(T894 t) { Nullable<T894> n = new Nullable<T894>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do895(T895 t) { Nullable<T895> n = new Nullable<T895>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do896(T896 t) { Nullable<T896> n = new Nullable<T896>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do897(T897 t) { Nullable<T897> n = new Nullable<T897>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do898(T898 t) { Nullable<T898> n = new Nullable<T898>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do899(T899 t) { Nullable<T899> n = new Nullable<T899>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do900(T900 t) { Nullable<T900> n = new Nullable<T900>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do901(T901 t) { Nullable<T901> n = new Nullable<T901>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do902(T902 t) { Nullable<T902> n = new Nullable<T902>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do903(T903 t) { Nullable<T903> n = new Nullable<T903>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do904(T904 t) { Nullable<T904> n = new Nullable<T904>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do905(T905 t) { Nullable<T905> n = new Nullable<T905>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do906(T906 t) { Nullable<T906> n = new Nullable<T906>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do907(T907 t) { Nullable<T907> n = new Nullable<T907>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do908(T908 t) { Nullable<T908> n = new Nullable<T908>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do909(T909 t) { Nullable<T909> n = new Nullable<T909>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do910(T910 t) { Nullable<T910> n = new Nullable<T910>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do911(T911 t) { Nullable<T911> n = new Nullable<T911>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do912(T912 t) { Nullable<T912> n = new Nullable<T912>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do913(T913 t) { Nullable<T913> n = new Nullable<T913>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do914(T914 t) { Nullable<T914> n = new Nullable<T914>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do915(T915 t) { Nullable<T915> n = new Nullable<T915>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do916(T916 t) { Nullable<T916> n = new Nullable<T916>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do917(T917 t) { Nullable<T917> n = new Nullable<T917>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do918(T918 t) { Nullable<T918> n = new Nullable<T918>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do919(T919 t) { Nullable<T919> n = new Nullable<T919>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do920(T920 t) { Nullable<T920> n = new Nullable<T920>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do921(T921 t) { Nullable<T921> n = new Nullable<T921>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do922(T922 t) { Nullable<T922> n = new Nullable<T922>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do923(T923 t) { Nullable<T923> n = new Nullable<T923>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do924(T924 t) { Nullable<T924> n = new Nullable<T924>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do925(T925 t) { Nullable<T925> n = new Nullable<T925>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do926(T926 t) { Nullable<T926> n = new Nullable<T926>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do927(T927 t) { Nullable<T927> n = new Nullable<T927>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do928(T928 t) { Nullable<T928> n = new Nullable<T928>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do929(T929 t) { Nullable<T929> n = new Nullable<T929>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do930(T930 t) { Nullable<T930> n = new Nullable<T930>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do931(T931 t) { Nullable<T931> n = new Nullable<T931>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do932(T932 t) { Nullable<T932> n = new Nullable<T932>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do933(T933 t) { Nullable<T933> n = new Nullable<T933>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do934(T934 t) { Nullable<T934> n = new Nullable<T934>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do935(T935 t) { Nullable<T935> n = new Nullable<T935>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do936(T936 t) { Nullable<T936> n = new Nullable<T936>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do937(T937 t) { Nullable<T937> n = new Nullable<T937>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do938(T938 t) { Nullable<T938> n = new Nullable<T938>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do939(T939 t) { Nullable<T939> n = new Nullable<T939>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do940(T940 t) { Nullable<T940> n = new Nullable<T940>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do941(T941 t) { Nullable<T941> n = new Nullable<T941>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do942(T942 t) { Nullable<T942> n = new Nullable<T942>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do943(T943 t) { Nullable<T943> n = new Nullable<T943>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do944(T944 t) { Nullable<T944> n = new Nullable<T944>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do945(T945 t) { Nullable<T945> n = new Nullable<T945>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do946(T946 t) { Nullable<T946> n = new Nullable<T946>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do947(T947 t) { Nullable<T947> n = new Nullable<T947>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do948(T948 t) { Nullable<T948> n = new Nullable<T948>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do949(T949 t) { Nullable<T949> n = new Nullable<T949>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do950(T950 t) { Nullable<T950> n = new Nullable<T950>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do951(T951 t) { Nullable<T951> n = new Nullable<T951>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do952(T952 t) { Nullable<T952> n = new Nullable<T952>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do953(T953 t) { Nullable<T953> n = new Nullable<T953>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do954(T954 t) { Nullable<T954> n = new Nullable<T954>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do955(T955 t) { Nullable<T955> n = new Nullable<T955>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do956(T956 t) { Nullable<T956> n = new Nullable<T956>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do957(T957 t) { Nullable<T957> n = new Nullable<T957>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do958(T958 t) { Nullable<T958> n = new Nullable<T958>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do959(T959 t) { Nullable<T959> n = new Nullable<T959>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do960(T960 t) { Nullable<T960> n = new Nullable<T960>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do961(T961 t) { Nullable<T961> n = new Nullable<T961>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do962(T962 t) { Nullable<T962> n = new Nullable<T962>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do963(T963 t) { Nullable<T963> n = new Nullable<T963>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do964(T964 t) { Nullable<T964> n = new Nullable<T964>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do965(T965 t) { Nullable<T965> n = new Nullable<T965>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do966(T966 t) { Nullable<T966> n = new Nullable<T966>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do967(T967 t) { Nullable<T967> n = new Nullable<T967>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do968(T968 t) { Nullable<T968> n = new Nullable<T968>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do969(T969 t) { Nullable<T969> n = new Nullable<T969>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do970(T970 t) { Nullable<T970> n = new Nullable<T970>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do971(T971 t) { Nullable<T971> n = new Nullable<T971>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do972(T972 t) { Nullable<T972> n = new Nullable<T972>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do973(T973 t) { Nullable<T973> n = new Nullable<T973>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do974(T974 t) { Nullable<T974> n = new Nullable<T974>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do975(T975 t) { Nullable<T975> n = new Nullable<T975>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do976(T976 t) { Nullable<T976> n = new Nullable<T976>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do977(T977 t) { Nullable<T977> n = new Nullable<T977>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do978(T978 t) { Nullable<T978> n = new Nullable<T978>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do979(T979 t) { Nullable<T979> n = new Nullable<T979>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do980(T980 t) { Nullable<T980> n = new Nullable<T980>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do981(T981 t) { Nullable<T981> n = new Nullable<T981>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do982(T982 t) { Nullable<T982> n = new Nullable<T982>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do983(T983 t) { Nullable<T983> n = new Nullable<T983>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do984(T984 t) { Nullable<T984> n = new Nullable<T984>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do985(T985 t) { Nullable<T985> n = new Nullable<T985>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do986(T986 t) { Nullable<T986> n = new Nullable<T986>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do987(T987 t) { Nullable<T987> n = new Nullable<T987>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do988(T988 t) { Nullable<T988> n = new Nullable<T988>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do989(T989 t) { Nullable<T989> n = new Nullable<T989>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do990(T990 t) { Nullable<T990> n = new Nullable<T990>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do991(T991 t) { Nullable<T991> n = new Nullable<T991>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do992(T992 t) { Nullable<T992> n = new Nullable<T992>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do993(T993 t) { Nullable<T993> n = new Nullable<T993>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do994(T994 t) { Nullable<T994> n = new Nullable<T994>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do995(T995 t) { Nullable<T995> n = new Nullable<T995>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do996(T996 t) { Nullable<T996> n = new Nullable<T996>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do997(T997 t) { Nullable<T997> n = new Nullable<T997>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do998(T998 t) { Nullable<T998> n = new Nullable<T998>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do999(T999 t) { Nullable<T999> n = new Nullable<T999>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Ensure(bool pred) { if (!pred) throw new Exception("Ensure fails"); return pred; } }
// 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; using System.Collections.Generic; using System.IO; using System.Runtime.CompilerServices; using System.Threading; public enum T0 { } public enum T1 { } public enum T2 { } public enum T3 { } public enum T4 { } public enum T5 { } public enum T6 { } public enum T7 { } public enum T8 { } public enum T9 { } public enum T10 { } public enum T11 { } public enum T12 { } public enum T13 { } public enum T14 { } public enum T15 { } public enum T16 { } public enum T17 { } public enum T18 { } public enum T19 { } public enum T20 { } public enum T21 { } public enum T22 { } public enum T23 { } public enum T24 { } public enum T25 { } public enum T26 { } public enum T27 { } public enum T28 { } public enum T29 { } public enum T30 { } public enum T31 { } public enum T32 { } public enum T33 { } public enum T34 { } public enum T35 { } public enum T36 { } public enum T37 { } public enum T38 { } public enum T39 { } public enum T40 { } public enum T41 { } public enum T42 { } public enum T43 { } public enum T44 { } public enum T45 { } public enum T46 { } public enum T47 { } public enum T48 { } public enum T49 { } public enum T50 { } public enum T51 { } public enum T52 { } public enum T53 { } public enum T54 { } public enum T55 { } public enum T56 { } public enum T57 { } public enum T58 { } public enum T59 { } public enum T60 { } public enum T61 { } public enum T62 { } public enum T63 { } public enum T64 { } public enum T65 { } public enum T66 { } public enum T67 { } public enum T68 { } public enum T69 { } public enum T70 { } public enum T71 { } public enum T72 { } public enum T73 { } public enum T74 { } public enum T75 { } public enum T76 { } public enum T77 { } public enum T78 { } public enum T79 { } public enum T80 { } public enum T81 { } public enum T82 { } public enum T83 { } public enum T84 { } public enum T85 { } public enum T86 { } public enum T87 { } public enum T88 { } public enum T89 { } public enum T90 { } public enum T91 { } public enum T92 { } public enum T93 { } public enum T94 { } public enum T95 { } public enum T96 { } public enum T97 { } public enum T98 { } public enum T99 { } public enum T100 { } public enum T101 { } public enum T102 { } public enum T103 { } public enum T104 { } public enum T105 { } public enum T106 { } public enum T107 { } public enum T108 { } public enum T109 { } public enum T110 { } public enum T111 { } public enum T112 { } public enum T113 { } public enum T114 { } public enum T115 { } public enum T116 { } public enum T117 { } public enum T118 { } public enum T119 { } public enum T120 { } public enum T121 { } public enum T122 { } public enum T123 { } public enum T124 { } public enum T125 { } public enum T126 { } public enum T127 { } public enum T128 { } public enum T129 { } public enum T130 { } public enum T131 { } public enum T132 { } public enum T133 { } public enum T134 { } public enum T135 { } public enum T136 { } public enum T137 { } public enum T138 { } public enum T139 { } public enum T140 { } public enum T141 { } public enum T142 { } public enum T143 { } public enum T144 { } public enum T145 { } public enum T146 { } public enum T147 { } public enum T148 { } public enum T149 { } public enum T150 { } public enum T151 { } public enum T152 { } public enum T153 { } public enum T154 { } public enum T155 { } public enum T156 { } public enum T157 { } public enum T158 { } public enum T159 { } public enum T160 { } public enum T161 { } public enum T162 { } public enum T163 { } public enum T164 { } public enum T165 { } public enum T166 { } public enum T167 { } public enum T168 { } public enum T169 { } public enum T170 { } public enum T171 { } public enum T172 { } public enum T173 { } public enum T174 { } public enum T175 { } public enum T176 { } public enum T177 { } public enum T178 { } public enum T179 { } public enum T180 { } public enum T181 { } public enum T182 { } public enum T183 { } public enum T184 { } public enum T185 { } public enum T186 { } public enum T187 { } public enum T188 { } public enum T189 { } public enum T190 { } public enum T191 { } public enum T192 { } public enum T193 { } public enum T194 { } public enum T195 { } public enum T196 { } public enum T197 { } public enum T198 { } public enum T199 { } public enum T200 { } public enum T201 { } public enum T202 { } public enum T203 { } public enum T204 { } public enum T205 { } public enum T206 { } public enum T207 { } public enum T208 { } public enum T209 { } public enum T210 { } public enum T211 { } public enum T212 { } public enum T213 { } public enum T214 { } public enum T215 { } public enum T216 { } public enum T217 { } public enum T218 { } public enum T219 { } public enum T220 { } public enum T221 { } public enum T222 { } public enum T223 { } public enum T224 { } public enum T225 { } public enum T226 { } public enum T227 { } public enum T228 { } public enum T229 { } public enum T230 { } public enum T231 { } public enum T232 { } public enum T233 { } public enum T234 { } public enum T235 { } public enum T236 { } public enum T237 { } public enum T238 { } public enum T239 { } public enum T240 { } public enum T241 { } public enum T242 { } public enum T243 { } public enum T244 { } public enum T245 { } public enum T246 { } public enum T247 { } public enum T248 { } public enum T249 { } public enum T250 { } public enum T251 { } public enum T252 { } public enum T253 { } public enum T254 { } public enum T255 { } public enum T256 { } public enum T257 { } public enum T258 { } public enum T259 { } public enum T260 { } public enum T261 { } public enum T262 { } public enum T263 { } public enum T264 { } public enum T265 { } public enum T266 { } public enum T267 { } public enum T268 { } public enum T269 { } public enum T270 { } public enum T271 { } public enum T272 { } public enum T273 { } public enum T274 { } public enum T275 { } public enum T276 { } public enum T277 { } public enum T278 { } public enum T279 { } public enum T280 { } public enum T281 { } public enum T282 { } public enum T283 { } public enum T284 { } public enum T285 { } public enum T286 { } public enum T287 { } public enum T288 { } public enum T289 { } public enum T290 { } public enum T291 { } public enum T292 { } public enum T293 { } public enum T294 { } public enum T295 { } public enum T296 { } public enum T297 { } public enum T298 { } public enum T299 { } public enum T300 { } public enum T301 { } public enum T302 { } public enum T303 { } public enum T304 { } public enum T305 { } public enum T306 { } public enum T307 { } public enum T308 { } public enum T309 { } public enum T310 { } public enum T311 { } public enum T312 { } public enum T313 { } public enum T314 { } public enum T315 { } public enum T316 { } public enum T317 { } public enum T318 { } public enum T319 { } public enum T320 { } public enum T321 { } public enum T322 { } public enum T323 { } public enum T324 { } public enum T325 { } public enum T326 { } public enum T327 { } public enum T328 { } public enum T329 { } public enum T330 { } public enum T331 { } public enum T332 { } public enum T333 { } public enum T334 { } public enum T335 { } public enum T336 { } public enum T337 { } public enum T338 { } public enum T339 { } public enum T340 { } public enum T341 { } public enum T342 { } public enum T343 { } public enum T344 { } public enum T345 { } public enum T346 { } public enum T347 { } public enum T348 { } public enum T349 { } public enum T350 { } public enum T351 { } public enum T352 { } public enum T353 { } public enum T354 { } public enum T355 { } public enum T356 { } public enum T357 { } public enum T358 { } public enum T359 { } public enum T360 { } public enum T361 { } public enum T362 { } public enum T363 { } public enum T364 { } public enum T365 { } public enum T366 { } public enum T367 { } public enum T368 { } public enum T369 { } public enum T370 { } public enum T371 { } public enum T372 { } public enum T373 { } public enum T374 { } public enum T375 { } public enum T376 { } public enum T377 { } public enum T378 { } public enum T379 { } public enum T380 { } public enum T381 { } public enum T382 { } public enum T383 { } public enum T384 { } public enum T385 { } public enum T386 { } public enum T387 { } public enum T388 { } public enum T389 { } public enum T390 { } public enum T391 { } public enum T392 { } public enum T393 { } public enum T394 { } public enum T395 { } public enum T396 { } public enum T397 { } public enum T398 { } public enum T399 { } public enum T400 { } public enum T401 { } public enum T402 { } public enum T403 { } public enum T404 { } public enum T405 { } public enum T406 { } public enum T407 { } public enum T408 { } public enum T409 { } public enum T410 { } public enum T411 { } public enum T412 { } public enum T413 { } public enum T414 { } public enum T415 { } public enum T416 { } public enum T417 { } public enum T418 { } public enum T419 { } public enum T420 { } public enum T421 { } public enum T422 { } public enum T423 { } public enum T424 { } public enum T425 { } public enum T426 { } public enum T427 { } public enum T428 { } public enum T429 { } public enum T430 { } public enum T431 { } public enum T432 { } public enum T433 { } public enum T434 { } public enum T435 { } public enum T436 { } public enum T437 { } public enum T438 { } public enum T439 { } public enum T440 { } public enum T441 { } public enum T442 { } public enum T443 { } public enum T444 { } public enum T445 { } public enum T446 { } public enum T447 { } public enum T448 { } public enum T449 { } public enum T450 { } public enum T451 { } public enum T452 { } public enum T453 { } public enum T454 { } public enum T455 { } public enum T456 { } public enum T457 { } public enum T458 { } public enum T459 { } public enum T460 { } public enum T461 { } public enum T462 { } public enum T463 { } public enum T464 { } public enum T465 { } public enum T466 { } public enum T467 { } public enum T468 { } public enum T469 { } public enum T470 { } public enum T471 { } public enum T472 { } public enum T473 { } public enum T474 { } public enum T475 { } public enum T476 { } public enum T477 { } public enum T478 { } public enum T479 { } public enum T480 { } public enum T481 { } public enum T482 { } public enum T483 { } public enum T484 { } public enum T485 { } public enum T486 { } public enum T487 { } public enum T488 { } public enum T489 { } public enum T490 { } public enum T491 { } public enum T492 { } public enum T493 { } public enum T494 { } public enum T495 { } public enum T496 { } public enum T497 { } public enum T498 { } public enum T499 { } public enum T500 { } public enum T501 { } public enum T502 { } public enum T503 { } public enum T504 { } public enum T505 { } public enum T506 { } public enum T507 { } public enum T508 { } public enum T509 { } public enum T510 { } public enum T511 { } public enum T512 { } public enum T513 { } public enum T514 { } public enum T515 { } public enum T516 { } public enum T517 { } public enum T518 { } public enum T519 { } public enum T520 { } public enum T521 { } public enum T522 { } public enum T523 { } public enum T524 { } public enum T525 { } public enum T526 { } public enum T527 { } public enum T528 { } public enum T529 { } public enum T530 { } public enum T531 { } public enum T532 { } public enum T533 { } public enum T534 { } public enum T535 { } public enum T536 { } public enum T537 { } public enum T538 { } public enum T539 { } public enum T540 { } public enum T541 { } public enum T542 { } public enum T543 { } public enum T544 { } public enum T545 { } public enum T546 { } public enum T547 { } public enum T548 { } public enum T549 { } public enum T550 { } public enum T551 { } public enum T552 { } public enum T553 { } public enum T554 { } public enum T555 { } public enum T556 { } public enum T557 { } public enum T558 { } public enum T559 { } public enum T560 { } public enum T561 { } public enum T562 { } public enum T563 { } public enum T564 { } public enum T565 { } public enum T566 { } public enum T567 { } public enum T568 { } public enum T569 { } public enum T570 { } public enum T571 { } public enum T572 { } public enum T573 { } public enum T574 { } public enum T575 { } public enum T576 { } public enum T577 { } public enum T578 { } public enum T579 { } public enum T580 { } public enum T581 { } public enum T582 { } public enum T583 { } public enum T584 { } public enum T585 { } public enum T586 { } public enum T587 { } public enum T588 { } public enum T589 { } public enum T590 { } public enum T591 { } public enum T592 { } public enum T593 { } public enum T594 { } public enum T595 { } public enum T596 { } public enum T597 { } public enum T598 { } public enum T599 { } public enum T600 { } public enum T601 { } public enum T602 { } public enum T603 { } public enum T604 { } public enum T605 { } public enum T606 { } public enum T607 { } public enum T608 { } public enum T609 { } public enum T610 { } public enum T611 { } public enum T612 { } public enum T613 { } public enum T614 { } public enum T615 { } public enum T616 { } public enum T617 { } public enum T618 { } public enum T619 { } public enum T620 { } public enum T621 { } public enum T622 { } public enum T623 { } public enum T624 { } public enum T625 { } public enum T626 { } public enum T627 { } public enum T628 { } public enum T629 { } public enum T630 { } public enum T631 { } public enum T632 { } public enum T633 { } public enum T634 { } public enum T635 { } public enum T636 { } public enum T637 { } public enum T638 { } public enum T639 { } public enum T640 { } public enum T641 { } public enum T642 { } public enum T643 { } public enum T644 { } public enum T645 { } public enum T646 { } public enum T647 { } public enum T648 { } public enum T649 { } public enum T650 { } public enum T651 { } public enum T652 { } public enum T653 { } public enum T654 { } public enum T655 { } public enum T656 { } public enum T657 { } public enum T658 { } public enum T659 { } public enum T660 { } public enum T661 { } public enum T662 { } public enum T663 { } public enum T664 { } public enum T665 { } public enum T666 { } public enum T667 { } public enum T668 { } public enum T669 { } public enum T670 { } public enum T671 { } public enum T672 { } public enum T673 { } public enum T674 { } public enum T675 { } public enum T676 { } public enum T677 { } public enum T678 { } public enum T679 { } public enum T680 { } public enum T681 { } public enum T682 { } public enum T683 { } public enum T684 { } public enum T685 { } public enum T686 { } public enum T687 { } public enum T688 { } public enum T689 { } public enum T690 { } public enum T691 { } public enum T692 { } public enum T693 { } public enum T694 { } public enum T695 { } public enum T696 { } public enum T697 { } public enum T698 { } public enum T699 { } public enum T700 { } public enum T701 { } public enum T702 { } public enum T703 { } public enum T704 { } public enum T705 { } public enum T706 { } public enum T707 { } public enum T708 { } public enum T709 { } public enum T710 { } public enum T711 { } public enum T712 { } public enum T713 { } public enum T714 { } public enum T715 { } public enum T716 { } public enum T717 { } public enum T718 { } public enum T719 { } public enum T720 { } public enum T721 { } public enum T722 { } public enum T723 { } public enum T724 { } public enum T725 { } public enum T726 { } public enum T727 { } public enum T728 { } public enum T729 { } public enum T730 { } public enum T731 { } public enum T732 { } public enum T733 { } public enum T734 { } public enum T735 { } public enum T736 { } public enum T737 { } public enum T738 { } public enum T739 { } public enum T740 { } public enum T741 { } public enum T742 { } public enum T743 { } public enum T744 { } public enum T745 { } public enum T746 { } public enum T747 { } public enum T748 { } public enum T749 { } public enum T750 { } public enum T751 { } public enum T752 { } public enum T753 { } public enum T754 { } public enum T755 { } public enum T756 { } public enum T757 { } public enum T758 { } public enum T759 { } public enum T760 { } public enum T761 { } public enum T762 { } public enum T763 { } public enum T764 { } public enum T765 { } public enum T766 { } public enum T767 { } public enum T768 { } public enum T769 { } public enum T770 { } public enum T771 { } public enum T772 { } public enum T773 { } public enum T774 { } public enum T775 { } public enum T776 { } public enum T777 { } public enum T778 { } public enum T779 { } public enum T780 { } public enum T781 { } public enum T782 { } public enum T783 { } public enum T784 { } public enum T785 { } public enum T786 { } public enum T787 { } public enum T788 { } public enum T789 { } public enum T790 { } public enum T791 { } public enum T792 { } public enum T793 { } public enum T794 { } public enum T795 { } public enum T796 { } public enum T797 { } public enum T798 { } public enum T799 { } public enum T800 { } public enum T801 { } public enum T802 { } public enum T803 { } public enum T804 { } public enum T805 { } public enum T806 { } public enum T807 { } public enum T808 { } public enum T809 { } public enum T810 { } public enum T811 { } public enum T812 { } public enum T813 { } public enum T814 { } public enum T815 { } public enum T816 { } public enum T817 { } public enum T818 { } public enum T819 { } public enum T820 { } public enum T821 { } public enum T822 { } public enum T823 { } public enum T824 { } public enum T825 { } public enum T826 { } public enum T827 { } public enum T828 { } public enum T829 { } public enum T830 { } public enum T831 { } public enum T832 { } public enum T833 { } public enum T834 { } public enum T835 { } public enum T836 { } public enum T837 { } public enum T838 { } public enum T839 { } public enum T840 { } public enum T841 { } public enum T842 { } public enum T843 { } public enum T844 { } public enum T845 { } public enum T846 { } public enum T847 { } public enum T848 { } public enum T849 { } public enum T850 { } public enum T851 { } public enum T852 { } public enum T853 { } public enum T854 { } public enum T855 { } public enum T856 { } public enum T857 { } public enum T858 { } public enum T859 { } public enum T860 { } public enum T861 { } public enum T862 { } public enum T863 { } public enum T864 { } public enum T865 { } public enum T866 { } public enum T867 { } public enum T868 { } public enum T869 { } public enum T870 { } public enum T871 { } public enum T872 { } public enum T873 { } public enum T874 { } public enum T875 { } public enum T876 { } public enum T877 { } public enum T878 { } public enum T879 { } public enum T880 { } public enum T881 { } public enum T882 { } public enum T883 { } public enum T884 { } public enum T885 { } public enum T886 { } public enum T887 { } public enum T888 { } public enum T889 { } public enum T890 { } public enum T891 { } public enum T892 { } public enum T893 { } public enum T894 { } public enum T895 { } public enum T896 { } public enum T897 { } public enum T898 { } public enum T899 { } public enum T900 { } public enum T901 { } public enum T902 { } public enum T903 { } public enum T904 { } public enum T905 { } public enum T906 { } public enum T907 { } public enum T908 { } public enum T909 { } public enum T910 { } public enum T911 { } public enum T912 { } public enum T913 { } public enum T914 { } public enum T915 { } public enum T916 { } public enum T917 { } public enum T918 { } public enum T919 { } public enum T920 { } public enum T921 { } public enum T922 { } public enum T923 { } public enum T924 { } public enum T925 { } public enum T926 { } public enum T927 { } public enum T928 { } public enum T929 { } public enum T930 { } public enum T931 { } public enum T932 { } public enum T933 { } public enum T934 { } public enum T935 { } public enum T936 { } public enum T937 { } public enum T938 { } public enum T939 { } public enum T940 { } public enum T941 { } public enum T942 { } public enum T943 { } public enum T944 { } public enum T945 { } public enum T946 { } public enum T947 { } public enum T948 { } public enum T949 { } public enum T950 { } public enum T951 { } public enum T952 { } public enum T953 { } public enum T954 { } public enum T955 { } public enum T956 { } public enum T957 { } public enum T958 { } public enum T959 { } public enum T960 { } public enum T961 { } public enum T962 { } public enum T963 { } public enum T964 { } public enum T965 { } public enum T966 { } public enum T967 { } public enum T968 { } public enum T969 { } public enum T970 { } public enum T971 { } public enum T972 { } public enum T973 { } public enum T974 { } public enum T975 { } public enum T976 { } public enum T977 { } public enum T978 { } public enum T979 { } public enum T980 { } public enum T981 { } public enum T982 { } public enum T983 { } public enum T984 { } public enum T985 { } public enum T986 { } public enum T987 { } public enum T988 { } public enum T989 { } public enum T990 { } public enum T991 { } public enum T992 { } public enum T993 { } public enum T994 { } public enum T995 { } public enum T996 { } public enum T997 { } public enum T998 { } public enum T999 { } public class Test_nullenum1000 { public static int Main() { try { Do0(new T0()); Do1(new T1()); Do2(new T2()); Do3(new T3()); Do4(new T4()); Do5(new T5()); Do6(new T6()); Do7(new T7()); Do8(new T8()); Do9(new T9()); Do10(new T10()); Do11(new T11()); Do12(new T12()); Do13(new T13()); Do14(new T14()); Do15(new T15()); Do16(new T16()); Do17(new T17()); Do18(new T18()); Do19(new T19()); Do20(new T20()); Do21(new T21()); Do22(new T22()); Do23(new T23()); Do24(new T24()); Do25(new T25()); Do26(new T26()); Do27(new T27()); Do28(new T28()); Do29(new T29()); Do30(new T30()); Do31(new T31()); Do32(new T32()); Do33(new T33()); Do34(new T34()); Do35(new T35()); Do36(new T36()); Do37(new T37()); Do38(new T38()); Do39(new T39()); Do40(new T40()); Do41(new T41()); Do42(new T42()); Do43(new T43()); Do44(new T44()); Do45(new T45()); Do46(new T46()); Do47(new T47()); Do48(new T48()); Do49(new T49()); Do50(new T50()); Do51(new T51()); Do52(new T52()); Do53(new T53()); Do54(new T54()); Do55(new T55()); Do56(new T56()); Do57(new T57()); Do58(new T58()); Do59(new T59()); Do60(new T60()); Do61(new T61()); Do62(new T62()); Do63(new T63()); Do64(new T64()); Do65(new T65()); Do66(new T66()); Do67(new T67()); Do68(new T68()); Do69(new T69()); Do70(new T70()); Do71(new T71()); Do72(new T72()); Do73(new T73()); Do74(new T74()); Do75(new T75()); Do76(new T76()); Do77(new T77()); Do78(new T78()); Do79(new T79()); Do80(new T80()); Do81(new T81()); Do82(new T82()); Do83(new T83()); Do84(new T84()); Do85(new T85()); Do86(new T86()); Do87(new T87()); Do88(new T88()); Do89(new T89()); Do90(new T90()); Do91(new T91()); Do92(new T92()); Do93(new T93()); Do94(new T94()); Do95(new T95()); Do96(new T96()); Do97(new T97()); Do98(new T98()); Do99(new T99()); Do100(new T100()); Do101(new T101()); Do102(new T102()); Do103(new T103()); Do104(new T104()); Do105(new T105()); Do106(new T106()); Do107(new T107()); Do108(new T108()); Do109(new T109()); Do110(new T110()); Do111(new T111()); Do112(new T112()); Do113(new T113()); Do114(new T114()); Do115(new T115()); Do116(new T116()); Do117(new T117()); Do118(new T118()); Do119(new T119()); Do120(new T120()); Do121(new T121()); Do122(new T122()); Do123(new T123()); Do124(new T124()); Do125(new T125()); Do126(new T126()); Do127(new T127()); Do128(new T128()); Do129(new T129()); Do130(new T130()); Do131(new T131()); Do132(new T132()); Do133(new T133()); Do134(new T134()); Do135(new T135()); Do136(new T136()); Do137(new T137()); Do138(new T138()); Do139(new T139()); Do140(new T140()); Do141(new T141()); Do142(new T142()); Do143(new T143()); Do144(new T144()); Do145(new T145()); Do146(new T146()); Do147(new T147()); Do148(new T148()); Do149(new T149()); Do150(new T150()); Do151(new T151()); Do152(new T152()); Do153(new T153()); Do154(new T154()); Do155(new T155()); Do156(new T156()); Do157(new T157()); Do158(new T158()); Do159(new T159()); Do160(new T160()); Do161(new T161()); Do162(new T162()); Do163(new T163()); Do164(new T164()); Do165(new T165()); Do166(new T166()); Do167(new T167()); Do168(new T168()); Do169(new T169()); Do170(new T170()); Do171(new T171()); Do172(new T172()); Do173(new T173()); Do174(new T174()); Do175(new T175()); Do176(new T176()); Do177(new T177()); Do178(new T178()); Do179(new T179()); Do180(new T180()); Do181(new T181()); Do182(new T182()); Do183(new T183()); Do184(new T184()); Do185(new T185()); Do186(new T186()); Do187(new T187()); Do188(new T188()); Do189(new T189()); Do190(new T190()); Do191(new T191()); Do192(new T192()); Do193(new T193()); Do194(new T194()); Do195(new T195()); Do196(new T196()); Do197(new T197()); Do198(new T198()); Do199(new T199()); Do200(new T200()); Do201(new T201()); Do202(new T202()); Do203(new T203()); Do204(new T204()); Do205(new T205()); Do206(new T206()); Do207(new T207()); Do208(new T208()); Do209(new T209()); Do210(new T210()); Do211(new T211()); Do212(new T212()); Do213(new T213()); Do214(new T214()); Do215(new T215()); Do216(new T216()); Do217(new T217()); Do218(new T218()); Do219(new T219()); Do220(new T220()); Do221(new T221()); Do222(new T222()); Do223(new T223()); Do224(new T224()); Do225(new T225()); Do226(new T226()); Do227(new T227()); Do228(new T228()); Do229(new T229()); Do230(new T230()); Do231(new T231()); Do232(new T232()); Do233(new T233()); Do234(new T234()); Do235(new T235()); Do236(new T236()); Do237(new T237()); Do238(new T238()); Do239(new T239()); Do240(new T240()); Do241(new T241()); Do242(new T242()); Do243(new T243()); Do244(new T244()); Do245(new T245()); Do246(new T246()); Do247(new T247()); Do248(new T248()); Do249(new T249()); Do250(new T250()); Do251(new T251()); Do252(new T252()); Do253(new T253()); Do254(new T254()); Do255(new T255()); Do256(new T256()); Do257(new T257()); Do258(new T258()); Do259(new T259()); Do260(new T260()); Do261(new T261()); Do262(new T262()); Do263(new T263()); Do264(new T264()); Do265(new T265()); Do266(new T266()); Do267(new T267()); Do268(new T268()); Do269(new T269()); Do270(new T270()); Do271(new T271()); Do272(new T272()); Do273(new T273()); Do274(new T274()); Do275(new T275()); Do276(new T276()); Do277(new T277()); Do278(new T278()); Do279(new T279()); Do280(new T280()); Do281(new T281()); Do282(new T282()); Do283(new T283()); Do284(new T284()); Do285(new T285()); Do286(new T286()); Do287(new T287()); Do288(new T288()); Do289(new T289()); Do290(new T290()); Do291(new T291()); Do292(new T292()); Do293(new T293()); Do294(new T294()); Do295(new T295()); Do296(new T296()); Do297(new T297()); Do298(new T298()); Do299(new T299()); Do300(new T300()); Do301(new T301()); Do302(new T302()); Do303(new T303()); Do304(new T304()); Do305(new T305()); Do306(new T306()); Do307(new T307()); Do308(new T308()); Do309(new T309()); Do310(new T310()); Do311(new T311()); Do312(new T312()); Do313(new T313()); Do314(new T314()); Do315(new T315()); Do316(new T316()); Do317(new T317()); Do318(new T318()); Do319(new T319()); Do320(new T320()); Do321(new T321()); Do322(new T322()); Do323(new T323()); Do324(new T324()); Do325(new T325()); Do326(new T326()); Do327(new T327()); Do328(new T328()); Do329(new T329()); Do330(new T330()); Do331(new T331()); Do332(new T332()); Do333(new T333()); Do334(new T334()); Do335(new T335()); Do336(new T336()); Do337(new T337()); Do338(new T338()); Do339(new T339()); Do340(new T340()); Do341(new T341()); Do342(new T342()); Do343(new T343()); Do344(new T344()); Do345(new T345()); Do346(new T346()); Do347(new T347()); Do348(new T348()); Do349(new T349()); Do350(new T350()); Do351(new T351()); Do352(new T352()); Do353(new T353()); Do354(new T354()); Do355(new T355()); Do356(new T356()); Do357(new T357()); Do358(new T358()); Do359(new T359()); Do360(new T360()); Do361(new T361()); Do362(new T362()); Do363(new T363()); Do364(new T364()); Do365(new T365()); Do366(new T366()); Do367(new T367()); Do368(new T368()); Do369(new T369()); Do370(new T370()); Do371(new T371()); Do372(new T372()); Do373(new T373()); Do374(new T374()); Do375(new T375()); Do376(new T376()); Do377(new T377()); Do378(new T378()); Do379(new T379()); Do380(new T380()); Do381(new T381()); Do382(new T382()); Do383(new T383()); Do384(new T384()); Do385(new T385()); Do386(new T386()); Do387(new T387()); Do388(new T388()); Do389(new T389()); Do390(new T390()); Do391(new T391()); Do392(new T392()); Do393(new T393()); Do394(new T394()); Do395(new T395()); Do396(new T396()); Do397(new T397()); Do398(new T398()); Do399(new T399()); Do400(new T400()); Do401(new T401()); Do402(new T402()); Do403(new T403()); Do404(new T404()); Do405(new T405()); Do406(new T406()); Do407(new T407()); Do408(new T408()); Do409(new T409()); Do410(new T410()); Do411(new T411()); Do412(new T412()); Do413(new T413()); Do414(new T414()); Do415(new T415()); Do416(new T416()); Do417(new T417()); Do418(new T418()); Do419(new T419()); Do420(new T420()); Do421(new T421()); Do422(new T422()); Do423(new T423()); Do424(new T424()); Do425(new T425()); Do426(new T426()); Do427(new T427()); Do428(new T428()); Do429(new T429()); Do430(new T430()); Do431(new T431()); Do432(new T432()); Do433(new T433()); Do434(new T434()); Do435(new T435()); Do436(new T436()); Do437(new T437()); Do438(new T438()); Do439(new T439()); Do440(new T440()); Do441(new T441()); Do442(new T442()); Do443(new T443()); Do444(new T444()); Do445(new T445()); Do446(new T446()); Do447(new T447()); Do448(new T448()); Do449(new T449()); Do450(new T450()); Do451(new T451()); Do452(new T452()); Do453(new T453()); Do454(new T454()); Do455(new T455()); Do456(new T456()); Do457(new T457()); Do458(new T458()); Do459(new T459()); Do460(new T460()); Do461(new T461()); Do462(new T462()); Do463(new T463()); Do464(new T464()); Do465(new T465()); Do466(new T466()); Do467(new T467()); Do468(new T468()); Do469(new T469()); Do470(new T470()); Do471(new T471()); Do472(new T472()); Do473(new T473()); Do474(new T474()); Do475(new T475()); Do476(new T476()); Do477(new T477()); Do478(new T478()); Do479(new T479()); Do480(new T480()); Do481(new T481()); Do482(new T482()); Do483(new T483()); Do484(new T484()); Do485(new T485()); Do486(new T486()); Do487(new T487()); Do488(new T488()); Do489(new T489()); Do490(new T490()); Do491(new T491()); Do492(new T492()); Do493(new T493()); Do494(new T494()); Do495(new T495()); Do496(new T496()); Do497(new T497()); Do498(new T498()); Do499(new T499()); Do500(new T500()); Do501(new T501()); Do502(new T502()); Do503(new T503()); Do504(new T504()); Do505(new T505()); Do506(new T506()); Do507(new T507()); Do508(new T508()); Do509(new T509()); Do510(new T510()); Do511(new T511()); Do512(new T512()); Do513(new T513()); Do514(new T514()); Do515(new T515()); Do516(new T516()); Do517(new T517()); Do518(new T518()); Do519(new T519()); Do520(new T520()); Do521(new T521()); Do522(new T522()); Do523(new T523()); Do524(new T524()); Do525(new T525()); Do526(new T526()); Do527(new T527()); Do528(new T528()); Do529(new T529()); Do530(new T530()); Do531(new T531()); Do532(new T532()); Do533(new T533()); Do534(new T534()); Do535(new T535()); Do536(new T536()); Do537(new T537()); Do538(new T538()); Do539(new T539()); Do540(new T540()); Do541(new T541()); Do542(new T542()); Do543(new T543()); Do544(new T544()); Do545(new T545()); Do546(new T546()); Do547(new T547()); Do548(new T548()); Do549(new T549()); Do550(new T550()); Do551(new T551()); Do552(new T552()); Do553(new T553()); Do554(new T554()); Do555(new T555()); Do556(new T556()); Do557(new T557()); Do558(new T558()); Do559(new T559()); Do560(new T560()); Do561(new T561()); Do562(new T562()); Do563(new T563()); Do564(new T564()); Do565(new T565()); Do566(new T566()); Do567(new T567()); Do568(new T568()); Do569(new T569()); Do570(new T570()); Do571(new T571()); Do572(new T572()); Do573(new T573()); Do574(new T574()); Do575(new T575()); Do576(new T576()); Do577(new T577()); Do578(new T578()); Do579(new T579()); Do580(new T580()); Do581(new T581()); Do582(new T582()); Do583(new T583()); Do584(new T584()); Do585(new T585()); Do586(new T586()); Do587(new T587()); Do588(new T588()); Do589(new T589()); Do590(new T590()); Do591(new T591()); Do592(new T592()); Do593(new T593()); Do594(new T594()); Do595(new T595()); Do596(new T596()); Do597(new T597()); Do598(new T598()); Do599(new T599()); Do600(new T600()); Do601(new T601()); Do602(new T602()); Do603(new T603()); Do604(new T604()); Do605(new T605()); Do606(new T606()); Do607(new T607()); Do608(new T608()); Do609(new T609()); Do610(new T610()); Do611(new T611()); Do612(new T612()); Do613(new T613()); Do614(new T614()); Do615(new T615()); Do616(new T616()); Do617(new T617()); Do618(new T618()); Do619(new T619()); Do620(new T620()); Do621(new T621()); Do622(new T622()); Do623(new T623()); Do624(new T624()); Do625(new T625()); Do626(new T626()); Do627(new T627()); Do628(new T628()); Do629(new T629()); Do630(new T630()); Do631(new T631()); Do632(new T632()); Do633(new T633()); Do634(new T634()); Do635(new T635()); Do636(new T636()); Do637(new T637()); Do638(new T638()); Do639(new T639()); Do640(new T640()); Do641(new T641()); Do642(new T642()); Do643(new T643()); Do644(new T644()); Do645(new T645()); Do646(new T646()); Do647(new T647()); Do648(new T648()); Do649(new T649()); Do650(new T650()); Do651(new T651()); Do652(new T652()); Do653(new T653()); Do654(new T654()); Do655(new T655()); Do656(new T656()); Do657(new T657()); Do658(new T658()); Do659(new T659()); Do660(new T660()); Do661(new T661()); Do662(new T662()); Do663(new T663()); Do664(new T664()); Do665(new T665()); Do666(new T666()); Do667(new T667()); Do668(new T668()); Do669(new T669()); Do670(new T670()); Do671(new T671()); Do672(new T672()); Do673(new T673()); Do674(new T674()); Do675(new T675()); Do676(new T676()); Do677(new T677()); Do678(new T678()); Do679(new T679()); Do680(new T680()); Do681(new T681()); Do682(new T682()); Do683(new T683()); Do684(new T684()); Do685(new T685()); Do686(new T686()); Do687(new T687()); Do688(new T688()); Do689(new T689()); Do690(new T690()); Do691(new T691()); Do692(new T692()); Do693(new T693()); Do694(new T694()); Do695(new T695()); Do696(new T696()); Do697(new T697()); Do698(new T698()); Do699(new T699()); Do700(new T700()); Do701(new T701()); Do702(new T702()); Do703(new T703()); Do704(new T704()); Do705(new T705()); Do706(new T706()); Do707(new T707()); Do708(new T708()); Do709(new T709()); Do710(new T710()); Do711(new T711()); Do712(new T712()); Do713(new T713()); Do714(new T714()); Do715(new T715()); Do716(new T716()); Do717(new T717()); Do718(new T718()); Do719(new T719()); Do720(new T720()); Do721(new T721()); Do722(new T722()); Do723(new T723()); Do724(new T724()); Do725(new T725()); Do726(new T726()); Do727(new T727()); Do728(new T728()); Do729(new T729()); Do730(new T730()); Do731(new T731()); Do732(new T732()); Do733(new T733()); Do734(new T734()); Do735(new T735()); Do736(new T736()); Do737(new T737()); Do738(new T738()); Do739(new T739()); Do740(new T740()); Do741(new T741()); Do742(new T742()); Do743(new T743()); Do744(new T744()); Do745(new T745()); Do746(new T746()); Do747(new T747()); Do748(new T748()); Do749(new T749()); Do750(new T750()); Do751(new T751()); Do752(new T752()); Do753(new T753()); Do754(new T754()); Do755(new T755()); Do756(new T756()); Do757(new T757()); Do758(new T758()); Do759(new T759()); Do760(new T760()); Do761(new T761()); Do762(new T762()); Do763(new T763()); Do764(new T764()); Do765(new T765()); Do766(new T766()); Do767(new T767()); Do768(new T768()); Do769(new T769()); Do770(new T770()); Do771(new T771()); Do772(new T772()); Do773(new T773()); Do774(new T774()); Do775(new T775()); Do776(new T776()); Do777(new T777()); Do778(new T778()); Do779(new T779()); Do780(new T780()); Do781(new T781()); Do782(new T782()); Do783(new T783()); Do784(new T784()); Do785(new T785()); Do786(new T786()); Do787(new T787()); Do788(new T788()); Do789(new T789()); Do790(new T790()); Do791(new T791()); Do792(new T792()); Do793(new T793()); Do794(new T794()); Do795(new T795()); Do796(new T796()); Do797(new T797()); Do798(new T798()); Do799(new T799()); Do800(new T800()); Do801(new T801()); Do802(new T802()); Do803(new T803()); Do804(new T804()); Do805(new T805()); Do806(new T806()); Do807(new T807()); Do808(new T808()); Do809(new T809()); Do810(new T810()); Do811(new T811()); Do812(new T812()); Do813(new T813()); Do814(new T814()); Do815(new T815()); Do816(new T816()); Do817(new T817()); Do818(new T818()); Do819(new T819()); Do820(new T820()); Do821(new T821()); Do822(new T822()); Do823(new T823()); Do824(new T824()); Do825(new T825()); Do826(new T826()); Do827(new T827()); Do828(new T828()); Do829(new T829()); Do830(new T830()); Do831(new T831()); Do832(new T832()); Do833(new T833()); Do834(new T834()); Do835(new T835()); Do836(new T836()); Do837(new T837()); Do838(new T838()); Do839(new T839()); Do840(new T840()); Do841(new T841()); Do842(new T842()); Do843(new T843()); Do844(new T844()); Do845(new T845()); Do846(new T846()); Do847(new T847()); Do848(new T848()); Do849(new T849()); Do850(new T850()); Do851(new T851()); Do852(new T852()); Do853(new T853()); Do854(new T854()); Do855(new T855()); Do856(new T856()); Do857(new T857()); Do858(new T858()); Do859(new T859()); Do860(new T860()); Do861(new T861()); Do862(new T862()); Do863(new T863()); Do864(new T864()); Do865(new T865()); Do866(new T866()); Do867(new T867()); Do868(new T868()); Do869(new T869()); Do870(new T870()); Do871(new T871()); Do872(new T872()); Do873(new T873()); Do874(new T874()); Do875(new T875()); Do876(new T876()); Do877(new T877()); Do878(new T878()); Do879(new T879()); Do880(new T880()); Do881(new T881()); Do882(new T882()); Do883(new T883()); Do884(new T884()); Do885(new T885()); Do886(new T886()); Do887(new T887()); Do888(new T888()); Do889(new T889()); Do890(new T890()); Do891(new T891()); Do892(new T892()); Do893(new T893()); Do894(new T894()); Do895(new T895()); Do896(new T896()); Do897(new T897()); Do898(new T898()); Do899(new T899()); Do900(new T900()); Do901(new T901()); Do902(new T902()); Do903(new T903()); Do904(new T904()); Do905(new T905()); Do906(new T906()); Do907(new T907()); Do908(new T908()); Do909(new T909()); Do910(new T910()); Do911(new T911()); Do912(new T912()); Do913(new T913()); Do914(new T914()); Do915(new T915()); Do916(new T916()); Do917(new T917()); Do918(new T918()); Do919(new T919()); Do920(new T920()); Do921(new T921()); Do922(new T922()); Do923(new T923()); Do924(new T924()); Do925(new T925()); Do926(new T926()); Do927(new T927()); Do928(new T928()); Do929(new T929()); Do930(new T930()); Do931(new T931()); Do932(new T932()); Do933(new T933()); Do934(new T934()); Do935(new T935()); Do936(new T936()); Do937(new T937()); Do938(new T938()); Do939(new T939()); Do940(new T940()); Do941(new T941()); Do942(new T942()); Do943(new T943()); Do944(new T944()); Do945(new T945()); Do946(new T946()); Do947(new T947()); Do948(new T948()); Do949(new T949()); Do950(new T950()); Do951(new T951()); Do952(new T952()); Do953(new T953()); Do954(new T954()); Do955(new T955()); Do956(new T956()); Do957(new T957()); Do958(new T958()); Do959(new T959()); Do960(new T960()); Do961(new T961()); Do962(new T962()); Do963(new T963()); Do964(new T964()); Do965(new T965()); Do966(new T966()); Do967(new T967()); Do968(new T968()); Do969(new T969()); Do970(new T970()); Do971(new T971()); Do972(new T972()); Do973(new T973()); Do974(new T974()); Do975(new T975()); Do976(new T976()); Do977(new T977()); Do978(new T978()); Do979(new T979()); Do980(new T980()); Do981(new T981()); Do982(new T982()); Do983(new T983()); Do984(new T984()); Do985(new T985()); Do986(new T986()); Do987(new T987()); Do988(new T988()); Do989(new T989()); Do990(new T990()); Do991(new T991()); Do992(new T992()); Do993(new T993()); Do994(new T994()); Do995(new T995()); Do996(new T996()); Do997(new T997()); Do998(new T998()); Do999(new T999()); Console.WriteLine("PASS"); return 100; } catch (TypeLoadException e) { Console.WriteLine("FAIL: Caught unexpected TypeLoadException" + e.Message); return 101; } catch (Exception e) { Console.WriteLine("FAIL: Caught unexpected exception:" + e.Message); return 101; } } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do0(T0 t) { Nullable<T0> n = new Nullable<T0>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do1(T1 t) { Nullable<T1> n = new Nullable<T1>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do2(T2 t) { Nullable<T2> n = new Nullable<T2>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do3(T3 t) { Nullable<T3> n = new Nullable<T3>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do4(T4 t) { Nullable<T4> n = new Nullable<T4>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do5(T5 t) { Nullable<T5> n = new Nullable<T5>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do6(T6 t) { Nullable<T6> n = new Nullable<T6>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do7(T7 t) { Nullable<T7> n = new Nullable<T7>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do8(T8 t) { Nullable<T8> n = new Nullable<T8>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do9(T9 t) { Nullable<T9> n = new Nullable<T9>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do10(T10 t) { Nullable<T10> n = new Nullable<T10>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do11(T11 t) { Nullable<T11> n = new Nullable<T11>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do12(T12 t) { Nullable<T12> n = new Nullable<T12>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do13(T13 t) { Nullable<T13> n = new Nullable<T13>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do14(T14 t) { Nullable<T14> n = new Nullable<T14>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do15(T15 t) { Nullable<T15> n = new Nullable<T15>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do16(T16 t) { Nullable<T16> n = new Nullable<T16>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do17(T17 t) { Nullable<T17> n = new Nullable<T17>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do18(T18 t) { Nullable<T18> n = new Nullable<T18>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do19(T19 t) { Nullable<T19> n = new Nullable<T19>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do20(T20 t) { Nullable<T20> n = new Nullable<T20>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do21(T21 t) { Nullable<T21> n = new Nullable<T21>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do22(T22 t) { Nullable<T22> n = new Nullable<T22>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do23(T23 t) { Nullable<T23> n = new Nullable<T23>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do24(T24 t) { Nullable<T24> n = new Nullable<T24>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do25(T25 t) { Nullable<T25> n = new Nullable<T25>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do26(T26 t) { Nullable<T26> n = new Nullable<T26>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do27(T27 t) { Nullable<T27> n = new Nullable<T27>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do28(T28 t) { Nullable<T28> n = new Nullable<T28>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do29(T29 t) { Nullable<T29> n = new Nullable<T29>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do30(T30 t) { Nullable<T30> n = new Nullable<T30>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do31(T31 t) { Nullable<T31> n = new Nullable<T31>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do32(T32 t) { Nullable<T32> n = new Nullable<T32>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do33(T33 t) { Nullable<T33> n = new Nullable<T33>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do34(T34 t) { Nullable<T34> n = new Nullable<T34>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do35(T35 t) { Nullable<T35> n = new Nullable<T35>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do36(T36 t) { Nullable<T36> n = new Nullable<T36>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do37(T37 t) { Nullable<T37> n = new Nullable<T37>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do38(T38 t) { Nullable<T38> n = new Nullable<T38>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do39(T39 t) { Nullable<T39> n = new Nullable<T39>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do40(T40 t) { Nullable<T40> n = new Nullable<T40>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do41(T41 t) { Nullable<T41> n = new Nullable<T41>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do42(T42 t) { Nullable<T42> n = new Nullable<T42>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do43(T43 t) { Nullable<T43> n = new Nullable<T43>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do44(T44 t) { Nullable<T44> n = new Nullable<T44>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do45(T45 t) { Nullable<T45> n = new Nullable<T45>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do46(T46 t) { Nullable<T46> n = new Nullable<T46>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do47(T47 t) { Nullable<T47> n = new Nullable<T47>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do48(T48 t) { Nullable<T48> n = new Nullable<T48>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do49(T49 t) { Nullable<T49> n = new Nullable<T49>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do50(T50 t) { Nullable<T50> n = new Nullable<T50>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do51(T51 t) { Nullable<T51> n = new Nullable<T51>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do52(T52 t) { Nullable<T52> n = new Nullable<T52>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do53(T53 t) { Nullable<T53> n = new Nullable<T53>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do54(T54 t) { Nullable<T54> n = new Nullable<T54>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do55(T55 t) { Nullable<T55> n = new Nullable<T55>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do56(T56 t) { Nullable<T56> n = new Nullable<T56>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do57(T57 t) { Nullable<T57> n = new Nullable<T57>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do58(T58 t) { Nullable<T58> n = new Nullable<T58>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do59(T59 t) { Nullable<T59> n = new Nullable<T59>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do60(T60 t) { Nullable<T60> n = new Nullable<T60>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do61(T61 t) { Nullable<T61> n = new Nullable<T61>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do62(T62 t) { Nullable<T62> n = new Nullable<T62>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do63(T63 t) { Nullable<T63> n = new Nullable<T63>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do64(T64 t) { Nullable<T64> n = new Nullable<T64>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do65(T65 t) { Nullable<T65> n = new Nullable<T65>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do66(T66 t) { Nullable<T66> n = new Nullable<T66>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do67(T67 t) { Nullable<T67> n = new Nullable<T67>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do68(T68 t) { Nullable<T68> n = new Nullable<T68>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do69(T69 t) { Nullable<T69> n = new Nullable<T69>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do70(T70 t) { Nullable<T70> n = new Nullable<T70>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do71(T71 t) { Nullable<T71> n = new Nullable<T71>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do72(T72 t) { Nullable<T72> n = new Nullable<T72>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do73(T73 t) { Nullable<T73> n = new Nullable<T73>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do74(T74 t) { Nullable<T74> n = new Nullable<T74>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do75(T75 t) { Nullable<T75> n = new Nullable<T75>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do76(T76 t) { Nullable<T76> n = new Nullable<T76>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do77(T77 t) { Nullable<T77> n = new Nullable<T77>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do78(T78 t) { Nullable<T78> n = new Nullable<T78>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do79(T79 t) { Nullable<T79> n = new Nullable<T79>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do80(T80 t) { Nullable<T80> n = new Nullable<T80>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do81(T81 t) { Nullable<T81> n = new Nullable<T81>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do82(T82 t) { Nullable<T82> n = new Nullable<T82>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do83(T83 t) { Nullable<T83> n = new Nullable<T83>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do84(T84 t) { Nullable<T84> n = new Nullable<T84>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do85(T85 t) { Nullable<T85> n = new Nullable<T85>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do86(T86 t) { Nullable<T86> n = new Nullable<T86>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do87(T87 t) { Nullable<T87> n = new Nullable<T87>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do88(T88 t) { Nullable<T88> n = new Nullable<T88>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do89(T89 t) { Nullable<T89> n = new Nullable<T89>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do90(T90 t) { Nullable<T90> n = new Nullable<T90>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do91(T91 t) { Nullable<T91> n = new Nullable<T91>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do92(T92 t) { Nullable<T92> n = new Nullable<T92>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do93(T93 t) { Nullable<T93> n = new Nullable<T93>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do94(T94 t) { Nullable<T94> n = new Nullable<T94>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do95(T95 t) { Nullable<T95> n = new Nullable<T95>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do96(T96 t) { Nullable<T96> n = new Nullable<T96>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do97(T97 t) { Nullable<T97> n = new Nullable<T97>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do98(T98 t) { Nullable<T98> n = new Nullable<T98>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do99(T99 t) { Nullable<T99> n = new Nullable<T99>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do100(T100 t) { Nullable<T100> n = new Nullable<T100>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do101(T101 t) { Nullable<T101> n = new Nullable<T101>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do102(T102 t) { Nullable<T102> n = new Nullable<T102>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do103(T103 t) { Nullable<T103> n = new Nullable<T103>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do104(T104 t) { Nullable<T104> n = new Nullable<T104>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do105(T105 t) { Nullable<T105> n = new Nullable<T105>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do106(T106 t) { Nullable<T106> n = new Nullable<T106>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do107(T107 t) { Nullable<T107> n = new Nullable<T107>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do108(T108 t) { Nullable<T108> n = new Nullable<T108>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do109(T109 t) { Nullable<T109> n = new Nullable<T109>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do110(T110 t) { Nullable<T110> n = new Nullable<T110>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do111(T111 t) { Nullable<T111> n = new Nullable<T111>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do112(T112 t) { Nullable<T112> n = new Nullable<T112>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do113(T113 t) { Nullable<T113> n = new Nullable<T113>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do114(T114 t) { Nullable<T114> n = new Nullable<T114>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do115(T115 t) { Nullable<T115> n = new Nullable<T115>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do116(T116 t) { Nullable<T116> n = new Nullable<T116>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do117(T117 t) { Nullable<T117> n = new Nullable<T117>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do118(T118 t) { Nullable<T118> n = new Nullable<T118>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do119(T119 t) { Nullable<T119> n = new Nullable<T119>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do120(T120 t) { Nullable<T120> n = new Nullable<T120>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do121(T121 t) { Nullable<T121> n = new Nullable<T121>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do122(T122 t) { Nullable<T122> n = new Nullable<T122>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do123(T123 t) { Nullable<T123> n = new Nullable<T123>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do124(T124 t) { Nullable<T124> n = new Nullable<T124>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do125(T125 t) { Nullable<T125> n = new Nullable<T125>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do126(T126 t) { Nullable<T126> n = new Nullable<T126>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do127(T127 t) { Nullable<T127> n = new Nullable<T127>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do128(T128 t) { Nullable<T128> n = new Nullable<T128>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do129(T129 t) { Nullable<T129> n = new Nullable<T129>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do130(T130 t) { Nullable<T130> n = new Nullable<T130>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do131(T131 t) { Nullable<T131> n = new Nullable<T131>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do132(T132 t) { Nullable<T132> n = new Nullable<T132>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do133(T133 t) { Nullable<T133> n = new Nullable<T133>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do134(T134 t) { Nullable<T134> n = new Nullable<T134>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do135(T135 t) { Nullable<T135> n = new Nullable<T135>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do136(T136 t) { Nullable<T136> n = new Nullable<T136>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do137(T137 t) { Nullable<T137> n = new Nullable<T137>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do138(T138 t) { Nullable<T138> n = new Nullable<T138>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do139(T139 t) { Nullable<T139> n = new Nullable<T139>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do140(T140 t) { Nullable<T140> n = new Nullable<T140>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do141(T141 t) { Nullable<T141> n = new Nullable<T141>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do142(T142 t) { Nullable<T142> n = new Nullable<T142>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do143(T143 t) { Nullable<T143> n = new Nullable<T143>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do144(T144 t) { Nullable<T144> n = new Nullable<T144>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do145(T145 t) { Nullable<T145> n = new Nullable<T145>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do146(T146 t) { Nullable<T146> n = new Nullable<T146>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do147(T147 t) { Nullable<T147> n = new Nullable<T147>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do148(T148 t) { Nullable<T148> n = new Nullable<T148>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do149(T149 t) { Nullable<T149> n = new Nullable<T149>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do150(T150 t) { Nullable<T150> n = new Nullable<T150>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do151(T151 t) { Nullable<T151> n = new Nullable<T151>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do152(T152 t) { Nullable<T152> n = new Nullable<T152>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do153(T153 t) { Nullable<T153> n = new Nullable<T153>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do154(T154 t) { Nullable<T154> n = new Nullable<T154>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do155(T155 t) { Nullable<T155> n = new Nullable<T155>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do156(T156 t) { Nullable<T156> n = new Nullable<T156>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do157(T157 t) { Nullable<T157> n = new Nullable<T157>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do158(T158 t) { Nullable<T158> n = new Nullable<T158>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do159(T159 t) { Nullable<T159> n = new Nullable<T159>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do160(T160 t) { Nullable<T160> n = new Nullable<T160>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do161(T161 t) { Nullable<T161> n = new Nullable<T161>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do162(T162 t) { Nullable<T162> n = new Nullable<T162>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do163(T163 t) { Nullable<T163> n = new Nullable<T163>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do164(T164 t) { Nullable<T164> n = new Nullable<T164>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do165(T165 t) { Nullable<T165> n = new Nullable<T165>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do166(T166 t) { Nullable<T166> n = new Nullable<T166>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do167(T167 t) { Nullable<T167> n = new Nullable<T167>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do168(T168 t) { Nullable<T168> n = new Nullable<T168>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do169(T169 t) { Nullable<T169> n = new Nullable<T169>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do170(T170 t) { Nullable<T170> n = new Nullable<T170>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do171(T171 t) { Nullable<T171> n = new Nullable<T171>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do172(T172 t) { Nullable<T172> n = new Nullable<T172>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do173(T173 t) { Nullable<T173> n = new Nullable<T173>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do174(T174 t) { Nullable<T174> n = new Nullable<T174>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do175(T175 t) { Nullable<T175> n = new Nullable<T175>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do176(T176 t) { Nullable<T176> n = new Nullable<T176>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do177(T177 t) { Nullable<T177> n = new Nullable<T177>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do178(T178 t) { Nullable<T178> n = new Nullable<T178>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do179(T179 t) { Nullable<T179> n = new Nullable<T179>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do180(T180 t) { Nullable<T180> n = new Nullable<T180>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do181(T181 t) { Nullable<T181> n = new Nullable<T181>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do182(T182 t) { Nullable<T182> n = new Nullable<T182>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do183(T183 t) { Nullable<T183> n = new Nullable<T183>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do184(T184 t) { Nullable<T184> n = new Nullable<T184>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do185(T185 t) { Nullable<T185> n = new Nullable<T185>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do186(T186 t) { Nullable<T186> n = new Nullable<T186>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do187(T187 t) { Nullable<T187> n = new Nullable<T187>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do188(T188 t) { Nullable<T188> n = new Nullable<T188>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do189(T189 t) { Nullable<T189> n = new Nullable<T189>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do190(T190 t) { Nullable<T190> n = new Nullable<T190>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do191(T191 t) { Nullable<T191> n = new Nullable<T191>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do192(T192 t) { Nullable<T192> n = new Nullable<T192>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do193(T193 t) { Nullable<T193> n = new Nullable<T193>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do194(T194 t) { Nullable<T194> n = new Nullable<T194>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do195(T195 t) { Nullable<T195> n = new Nullable<T195>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do196(T196 t) { Nullable<T196> n = new Nullable<T196>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do197(T197 t) { Nullable<T197> n = new Nullable<T197>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do198(T198 t) { Nullable<T198> n = new Nullable<T198>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do199(T199 t) { Nullable<T199> n = new Nullable<T199>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do200(T200 t) { Nullable<T200> n = new Nullable<T200>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do201(T201 t) { Nullable<T201> n = new Nullable<T201>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do202(T202 t) { Nullable<T202> n = new Nullable<T202>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do203(T203 t) { Nullable<T203> n = new Nullable<T203>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do204(T204 t) { Nullable<T204> n = new Nullable<T204>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do205(T205 t) { Nullable<T205> n = new Nullable<T205>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do206(T206 t) { Nullable<T206> n = new Nullable<T206>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do207(T207 t) { Nullable<T207> n = new Nullable<T207>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do208(T208 t) { Nullable<T208> n = new Nullable<T208>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do209(T209 t) { Nullable<T209> n = new Nullable<T209>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do210(T210 t) { Nullable<T210> n = new Nullable<T210>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do211(T211 t) { Nullable<T211> n = new Nullable<T211>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do212(T212 t) { Nullable<T212> n = new Nullable<T212>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do213(T213 t) { Nullable<T213> n = new Nullable<T213>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do214(T214 t) { Nullable<T214> n = new Nullable<T214>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do215(T215 t) { Nullable<T215> n = new Nullable<T215>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do216(T216 t) { Nullable<T216> n = new Nullable<T216>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do217(T217 t) { Nullable<T217> n = new Nullable<T217>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do218(T218 t) { Nullable<T218> n = new Nullable<T218>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do219(T219 t) { Nullable<T219> n = new Nullable<T219>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do220(T220 t) { Nullable<T220> n = new Nullable<T220>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do221(T221 t) { Nullable<T221> n = new Nullable<T221>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do222(T222 t) { Nullable<T222> n = new Nullable<T222>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do223(T223 t) { Nullable<T223> n = new Nullable<T223>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do224(T224 t) { Nullable<T224> n = new Nullable<T224>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do225(T225 t) { Nullable<T225> n = new Nullable<T225>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do226(T226 t) { Nullable<T226> n = new Nullable<T226>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do227(T227 t) { Nullable<T227> n = new Nullable<T227>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do228(T228 t) { Nullable<T228> n = new Nullable<T228>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do229(T229 t) { Nullable<T229> n = new Nullable<T229>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do230(T230 t) { Nullable<T230> n = new Nullable<T230>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do231(T231 t) { Nullable<T231> n = new Nullable<T231>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do232(T232 t) { Nullable<T232> n = new Nullable<T232>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do233(T233 t) { Nullable<T233> n = new Nullable<T233>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do234(T234 t) { Nullable<T234> n = new Nullable<T234>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do235(T235 t) { Nullable<T235> n = new Nullable<T235>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do236(T236 t) { Nullable<T236> n = new Nullable<T236>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do237(T237 t) { Nullable<T237> n = new Nullable<T237>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do238(T238 t) { Nullable<T238> n = new Nullable<T238>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do239(T239 t) { Nullable<T239> n = new Nullable<T239>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do240(T240 t) { Nullable<T240> n = new Nullable<T240>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do241(T241 t) { Nullable<T241> n = new Nullable<T241>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do242(T242 t) { Nullable<T242> n = new Nullable<T242>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do243(T243 t) { Nullable<T243> n = new Nullable<T243>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do244(T244 t) { Nullable<T244> n = new Nullable<T244>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do245(T245 t) { Nullable<T245> n = new Nullable<T245>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do246(T246 t) { Nullable<T246> n = new Nullable<T246>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do247(T247 t) { Nullable<T247> n = new Nullable<T247>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do248(T248 t) { Nullable<T248> n = new Nullable<T248>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do249(T249 t) { Nullable<T249> n = new Nullable<T249>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do250(T250 t) { Nullable<T250> n = new Nullable<T250>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do251(T251 t) { Nullable<T251> n = new Nullable<T251>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do252(T252 t) { Nullable<T252> n = new Nullable<T252>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do253(T253 t) { Nullable<T253> n = new Nullable<T253>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do254(T254 t) { Nullable<T254> n = new Nullable<T254>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do255(T255 t) { Nullable<T255> n = new Nullable<T255>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do256(T256 t) { Nullable<T256> n = new Nullable<T256>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do257(T257 t) { Nullable<T257> n = new Nullable<T257>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do258(T258 t) { Nullable<T258> n = new Nullable<T258>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do259(T259 t) { Nullable<T259> n = new Nullable<T259>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do260(T260 t) { Nullable<T260> n = new Nullable<T260>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do261(T261 t) { Nullable<T261> n = new Nullable<T261>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do262(T262 t) { Nullable<T262> n = new Nullable<T262>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do263(T263 t) { Nullable<T263> n = new Nullable<T263>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do264(T264 t) { Nullable<T264> n = new Nullable<T264>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do265(T265 t) { Nullable<T265> n = new Nullable<T265>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do266(T266 t) { Nullable<T266> n = new Nullable<T266>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do267(T267 t) { Nullable<T267> n = new Nullable<T267>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do268(T268 t) { Nullable<T268> n = new Nullable<T268>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do269(T269 t) { Nullable<T269> n = new Nullable<T269>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do270(T270 t) { Nullable<T270> n = new Nullable<T270>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do271(T271 t) { Nullable<T271> n = new Nullable<T271>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do272(T272 t) { Nullable<T272> n = new Nullable<T272>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do273(T273 t) { Nullable<T273> n = new Nullable<T273>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do274(T274 t) { Nullable<T274> n = new Nullable<T274>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do275(T275 t) { Nullable<T275> n = new Nullable<T275>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do276(T276 t) { Nullable<T276> n = new Nullable<T276>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do277(T277 t) { Nullable<T277> n = new Nullable<T277>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do278(T278 t) { Nullable<T278> n = new Nullable<T278>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do279(T279 t) { Nullable<T279> n = new Nullable<T279>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do280(T280 t) { Nullable<T280> n = new Nullable<T280>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do281(T281 t) { Nullable<T281> n = new Nullable<T281>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do282(T282 t) { Nullable<T282> n = new Nullable<T282>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do283(T283 t) { Nullable<T283> n = new Nullable<T283>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do284(T284 t) { Nullable<T284> n = new Nullable<T284>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do285(T285 t) { Nullable<T285> n = new Nullable<T285>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do286(T286 t) { Nullable<T286> n = new Nullable<T286>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do287(T287 t) { Nullable<T287> n = new Nullable<T287>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do288(T288 t) { Nullable<T288> n = new Nullable<T288>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do289(T289 t) { Nullable<T289> n = new Nullable<T289>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do290(T290 t) { Nullable<T290> n = new Nullable<T290>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do291(T291 t) { Nullable<T291> n = new Nullable<T291>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do292(T292 t) { Nullable<T292> n = new Nullable<T292>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do293(T293 t) { Nullable<T293> n = new Nullable<T293>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do294(T294 t) { Nullable<T294> n = new Nullable<T294>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do295(T295 t) { Nullable<T295> n = new Nullable<T295>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do296(T296 t) { Nullable<T296> n = new Nullable<T296>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do297(T297 t) { Nullable<T297> n = new Nullable<T297>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do298(T298 t) { Nullable<T298> n = new Nullable<T298>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do299(T299 t) { Nullable<T299> n = new Nullable<T299>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do300(T300 t) { Nullable<T300> n = new Nullable<T300>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do301(T301 t) { Nullable<T301> n = new Nullable<T301>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do302(T302 t) { Nullable<T302> n = new Nullable<T302>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do303(T303 t) { Nullable<T303> n = new Nullable<T303>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do304(T304 t) { Nullable<T304> n = new Nullable<T304>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do305(T305 t) { Nullable<T305> n = new Nullable<T305>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do306(T306 t) { Nullable<T306> n = new Nullable<T306>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do307(T307 t) { Nullable<T307> n = new Nullable<T307>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do308(T308 t) { Nullable<T308> n = new Nullable<T308>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do309(T309 t) { Nullable<T309> n = new Nullable<T309>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do310(T310 t) { Nullable<T310> n = new Nullable<T310>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do311(T311 t) { Nullable<T311> n = new Nullable<T311>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do312(T312 t) { Nullable<T312> n = new Nullable<T312>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do313(T313 t) { Nullable<T313> n = new Nullable<T313>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do314(T314 t) { Nullable<T314> n = new Nullable<T314>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do315(T315 t) { Nullable<T315> n = new Nullable<T315>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do316(T316 t) { Nullable<T316> n = new Nullable<T316>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do317(T317 t) { Nullable<T317> n = new Nullable<T317>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do318(T318 t) { Nullable<T318> n = new Nullable<T318>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do319(T319 t) { Nullable<T319> n = new Nullable<T319>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do320(T320 t) { Nullable<T320> n = new Nullable<T320>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do321(T321 t) { Nullable<T321> n = new Nullable<T321>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do322(T322 t) { Nullable<T322> n = new Nullable<T322>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do323(T323 t) { Nullable<T323> n = new Nullable<T323>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do324(T324 t) { Nullable<T324> n = new Nullable<T324>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do325(T325 t) { Nullable<T325> n = new Nullable<T325>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do326(T326 t) { Nullable<T326> n = new Nullable<T326>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do327(T327 t) { Nullable<T327> n = new Nullable<T327>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do328(T328 t) { Nullable<T328> n = new Nullable<T328>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do329(T329 t) { Nullable<T329> n = new Nullable<T329>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do330(T330 t) { Nullable<T330> n = new Nullable<T330>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do331(T331 t) { Nullable<T331> n = new Nullable<T331>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do332(T332 t) { Nullable<T332> n = new Nullable<T332>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do333(T333 t) { Nullable<T333> n = new Nullable<T333>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do334(T334 t) { Nullable<T334> n = new Nullable<T334>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do335(T335 t) { Nullable<T335> n = new Nullable<T335>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do336(T336 t) { Nullable<T336> n = new Nullable<T336>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do337(T337 t) { Nullable<T337> n = new Nullable<T337>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do338(T338 t) { Nullable<T338> n = new Nullable<T338>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do339(T339 t) { Nullable<T339> n = new Nullable<T339>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do340(T340 t) { Nullable<T340> n = new Nullable<T340>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do341(T341 t) { Nullable<T341> n = new Nullable<T341>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do342(T342 t) { Nullable<T342> n = new Nullable<T342>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do343(T343 t) { Nullable<T343> n = new Nullable<T343>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do344(T344 t) { Nullable<T344> n = new Nullable<T344>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do345(T345 t) { Nullable<T345> n = new Nullable<T345>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do346(T346 t) { Nullable<T346> n = new Nullable<T346>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do347(T347 t) { Nullable<T347> n = new Nullable<T347>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do348(T348 t) { Nullable<T348> n = new Nullable<T348>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do349(T349 t) { Nullable<T349> n = new Nullable<T349>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do350(T350 t) { Nullable<T350> n = new Nullable<T350>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do351(T351 t) { Nullable<T351> n = new Nullable<T351>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do352(T352 t) { Nullable<T352> n = new Nullable<T352>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do353(T353 t) { Nullable<T353> n = new Nullable<T353>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do354(T354 t) { Nullable<T354> n = new Nullable<T354>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do355(T355 t) { Nullable<T355> n = new Nullable<T355>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do356(T356 t) { Nullable<T356> n = new Nullable<T356>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do357(T357 t) { Nullable<T357> n = new Nullable<T357>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do358(T358 t) { Nullable<T358> n = new Nullable<T358>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do359(T359 t) { Nullable<T359> n = new Nullable<T359>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do360(T360 t) { Nullable<T360> n = new Nullable<T360>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do361(T361 t) { Nullable<T361> n = new Nullable<T361>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do362(T362 t) { Nullable<T362> n = new Nullable<T362>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do363(T363 t) { Nullable<T363> n = new Nullable<T363>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do364(T364 t) { Nullable<T364> n = new Nullable<T364>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do365(T365 t) { Nullable<T365> n = new Nullable<T365>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do366(T366 t) { Nullable<T366> n = new Nullable<T366>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do367(T367 t) { Nullable<T367> n = new Nullable<T367>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do368(T368 t) { Nullable<T368> n = new Nullable<T368>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do369(T369 t) { Nullable<T369> n = new Nullable<T369>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do370(T370 t) { Nullable<T370> n = new Nullable<T370>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do371(T371 t) { Nullable<T371> n = new Nullable<T371>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do372(T372 t) { Nullable<T372> n = new Nullable<T372>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do373(T373 t) { Nullable<T373> n = new Nullable<T373>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do374(T374 t) { Nullable<T374> n = new Nullable<T374>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do375(T375 t) { Nullable<T375> n = new Nullable<T375>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do376(T376 t) { Nullable<T376> n = new Nullable<T376>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do377(T377 t) { Nullable<T377> n = new Nullable<T377>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do378(T378 t) { Nullable<T378> n = new Nullable<T378>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do379(T379 t) { Nullable<T379> n = new Nullable<T379>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do380(T380 t) { Nullable<T380> n = new Nullable<T380>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do381(T381 t) { Nullable<T381> n = new Nullable<T381>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do382(T382 t) { Nullable<T382> n = new Nullable<T382>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do383(T383 t) { Nullable<T383> n = new Nullable<T383>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do384(T384 t) { Nullable<T384> n = new Nullable<T384>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do385(T385 t) { Nullable<T385> n = new Nullable<T385>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do386(T386 t) { Nullable<T386> n = new Nullable<T386>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do387(T387 t) { Nullable<T387> n = new Nullable<T387>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do388(T388 t) { Nullable<T388> n = new Nullable<T388>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do389(T389 t) { Nullable<T389> n = new Nullable<T389>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do390(T390 t) { Nullable<T390> n = new Nullable<T390>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do391(T391 t) { Nullable<T391> n = new Nullable<T391>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do392(T392 t) { Nullable<T392> n = new Nullable<T392>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do393(T393 t) { Nullable<T393> n = new Nullable<T393>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do394(T394 t) { Nullable<T394> n = new Nullable<T394>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do395(T395 t) { Nullable<T395> n = new Nullable<T395>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do396(T396 t) { Nullable<T396> n = new Nullable<T396>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do397(T397 t) { Nullable<T397> n = new Nullable<T397>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do398(T398 t) { Nullable<T398> n = new Nullable<T398>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do399(T399 t) { Nullable<T399> n = new Nullable<T399>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do400(T400 t) { Nullable<T400> n = new Nullable<T400>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do401(T401 t) { Nullable<T401> n = new Nullable<T401>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do402(T402 t) { Nullable<T402> n = new Nullable<T402>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do403(T403 t) { Nullable<T403> n = new Nullable<T403>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do404(T404 t) { Nullable<T404> n = new Nullable<T404>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do405(T405 t) { Nullable<T405> n = new Nullable<T405>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do406(T406 t) { Nullable<T406> n = new Nullable<T406>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do407(T407 t) { Nullable<T407> n = new Nullable<T407>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do408(T408 t) { Nullable<T408> n = new Nullable<T408>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do409(T409 t) { Nullable<T409> n = new Nullable<T409>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do410(T410 t) { Nullable<T410> n = new Nullable<T410>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do411(T411 t) { Nullable<T411> n = new Nullable<T411>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do412(T412 t) { Nullable<T412> n = new Nullable<T412>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do413(T413 t) { Nullable<T413> n = new Nullable<T413>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do414(T414 t) { Nullable<T414> n = new Nullable<T414>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do415(T415 t) { Nullable<T415> n = new Nullable<T415>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do416(T416 t) { Nullable<T416> n = new Nullable<T416>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do417(T417 t) { Nullable<T417> n = new Nullable<T417>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do418(T418 t) { Nullable<T418> n = new Nullable<T418>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do419(T419 t) { Nullable<T419> n = new Nullable<T419>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do420(T420 t) { Nullable<T420> n = new Nullable<T420>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do421(T421 t) { Nullable<T421> n = new Nullable<T421>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do422(T422 t) { Nullable<T422> n = new Nullable<T422>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do423(T423 t) { Nullable<T423> n = new Nullable<T423>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do424(T424 t) { Nullable<T424> n = new Nullable<T424>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do425(T425 t) { Nullable<T425> n = new Nullable<T425>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do426(T426 t) { Nullable<T426> n = new Nullable<T426>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do427(T427 t) { Nullable<T427> n = new Nullable<T427>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do428(T428 t) { Nullable<T428> n = new Nullable<T428>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do429(T429 t) { Nullable<T429> n = new Nullable<T429>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do430(T430 t) { Nullable<T430> n = new Nullable<T430>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do431(T431 t) { Nullable<T431> n = new Nullable<T431>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do432(T432 t) { Nullable<T432> n = new Nullable<T432>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do433(T433 t) { Nullable<T433> n = new Nullable<T433>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do434(T434 t) { Nullable<T434> n = new Nullable<T434>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do435(T435 t) { Nullable<T435> n = new Nullable<T435>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do436(T436 t) { Nullable<T436> n = new Nullable<T436>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do437(T437 t) { Nullable<T437> n = new Nullable<T437>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do438(T438 t) { Nullable<T438> n = new Nullable<T438>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do439(T439 t) { Nullable<T439> n = new Nullable<T439>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do440(T440 t) { Nullable<T440> n = new Nullable<T440>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do441(T441 t) { Nullable<T441> n = new Nullable<T441>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do442(T442 t) { Nullable<T442> n = new Nullable<T442>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do443(T443 t) { Nullable<T443> n = new Nullable<T443>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do444(T444 t) { Nullable<T444> n = new Nullable<T444>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do445(T445 t) { Nullable<T445> n = new Nullable<T445>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do446(T446 t) { Nullable<T446> n = new Nullable<T446>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do447(T447 t) { Nullable<T447> n = new Nullable<T447>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do448(T448 t) { Nullable<T448> n = new Nullable<T448>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do449(T449 t) { Nullable<T449> n = new Nullable<T449>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do450(T450 t) { Nullable<T450> n = new Nullable<T450>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do451(T451 t) { Nullable<T451> n = new Nullable<T451>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do452(T452 t) { Nullable<T452> n = new Nullable<T452>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do453(T453 t) { Nullable<T453> n = new Nullable<T453>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do454(T454 t) { Nullable<T454> n = new Nullable<T454>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do455(T455 t) { Nullable<T455> n = new Nullable<T455>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do456(T456 t) { Nullable<T456> n = new Nullable<T456>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do457(T457 t) { Nullable<T457> n = new Nullable<T457>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do458(T458 t) { Nullable<T458> n = new Nullable<T458>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do459(T459 t) { Nullable<T459> n = new Nullable<T459>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do460(T460 t) { Nullable<T460> n = new Nullable<T460>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do461(T461 t) { Nullable<T461> n = new Nullable<T461>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do462(T462 t) { Nullable<T462> n = new Nullable<T462>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do463(T463 t) { Nullable<T463> n = new Nullable<T463>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do464(T464 t) { Nullable<T464> n = new Nullable<T464>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do465(T465 t) { Nullable<T465> n = new Nullable<T465>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do466(T466 t) { Nullable<T466> n = new Nullable<T466>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do467(T467 t) { Nullable<T467> n = new Nullable<T467>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do468(T468 t) { Nullable<T468> n = new Nullable<T468>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do469(T469 t) { Nullable<T469> n = new Nullable<T469>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do470(T470 t) { Nullable<T470> n = new Nullable<T470>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do471(T471 t) { Nullable<T471> n = new Nullable<T471>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do472(T472 t) { Nullable<T472> n = new Nullable<T472>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do473(T473 t) { Nullable<T473> n = new Nullable<T473>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do474(T474 t) { Nullable<T474> n = new Nullable<T474>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do475(T475 t) { Nullable<T475> n = new Nullable<T475>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do476(T476 t) { Nullable<T476> n = new Nullable<T476>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do477(T477 t) { Nullable<T477> n = new Nullable<T477>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do478(T478 t) { Nullable<T478> n = new Nullable<T478>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do479(T479 t) { Nullable<T479> n = new Nullable<T479>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do480(T480 t) { Nullable<T480> n = new Nullable<T480>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do481(T481 t) { Nullable<T481> n = new Nullable<T481>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do482(T482 t) { Nullable<T482> n = new Nullable<T482>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do483(T483 t) { Nullable<T483> n = new Nullable<T483>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do484(T484 t) { Nullable<T484> n = new Nullable<T484>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do485(T485 t) { Nullable<T485> n = new Nullable<T485>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do486(T486 t) { Nullable<T486> n = new Nullable<T486>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do487(T487 t) { Nullable<T487> n = new Nullable<T487>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do488(T488 t) { Nullable<T488> n = new Nullable<T488>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do489(T489 t) { Nullable<T489> n = new Nullable<T489>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do490(T490 t) { Nullable<T490> n = new Nullable<T490>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do491(T491 t) { Nullable<T491> n = new Nullable<T491>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do492(T492 t) { Nullable<T492> n = new Nullable<T492>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do493(T493 t) { Nullable<T493> n = new Nullable<T493>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do494(T494 t) { Nullable<T494> n = new Nullable<T494>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do495(T495 t) { Nullable<T495> n = new Nullable<T495>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do496(T496 t) { Nullable<T496> n = new Nullable<T496>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do497(T497 t) { Nullable<T497> n = new Nullable<T497>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do498(T498 t) { Nullable<T498> n = new Nullable<T498>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do499(T499 t) { Nullable<T499> n = new Nullable<T499>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do500(T500 t) { Nullable<T500> n = new Nullable<T500>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do501(T501 t) { Nullable<T501> n = new Nullable<T501>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do502(T502 t) { Nullable<T502> n = new Nullable<T502>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do503(T503 t) { Nullable<T503> n = new Nullable<T503>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do504(T504 t) { Nullable<T504> n = new Nullable<T504>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do505(T505 t) { Nullable<T505> n = new Nullable<T505>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do506(T506 t) { Nullable<T506> n = new Nullable<T506>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do507(T507 t) { Nullable<T507> n = new Nullable<T507>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do508(T508 t) { Nullable<T508> n = new Nullable<T508>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do509(T509 t) { Nullable<T509> n = new Nullable<T509>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do510(T510 t) { Nullable<T510> n = new Nullable<T510>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do511(T511 t) { Nullable<T511> n = new Nullable<T511>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do512(T512 t) { Nullable<T512> n = new Nullable<T512>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do513(T513 t) { Nullable<T513> n = new Nullable<T513>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do514(T514 t) { Nullable<T514> n = new Nullable<T514>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do515(T515 t) { Nullable<T515> n = new Nullable<T515>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do516(T516 t) { Nullable<T516> n = new Nullable<T516>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do517(T517 t) { Nullable<T517> n = new Nullable<T517>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do518(T518 t) { Nullable<T518> n = new Nullable<T518>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do519(T519 t) { Nullable<T519> n = new Nullable<T519>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do520(T520 t) { Nullable<T520> n = new Nullable<T520>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do521(T521 t) { Nullable<T521> n = new Nullable<T521>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do522(T522 t) { Nullable<T522> n = new Nullable<T522>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do523(T523 t) { Nullable<T523> n = new Nullable<T523>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do524(T524 t) { Nullable<T524> n = new Nullable<T524>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do525(T525 t) { Nullable<T525> n = new Nullable<T525>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do526(T526 t) { Nullable<T526> n = new Nullable<T526>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do527(T527 t) { Nullable<T527> n = new Nullable<T527>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do528(T528 t) { Nullable<T528> n = new Nullable<T528>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do529(T529 t) { Nullable<T529> n = new Nullable<T529>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do530(T530 t) { Nullable<T530> n = new Nullable<T530>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do531(T531 t) { Nullable<T531> n = new Nullable<T531>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do532(T532 t) { Nullable<T532> n = new Nullable<T532>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do533(T533 t) { Nullable<T533> n = new Nullable<T533>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do534(T534 t) { Nullable<T534> n = new Nullable<T534>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do535(T535 t) { Nullable<T535> n = new Nullable<T535>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do536(T536 t) { Nullable<T536> n = new Nullable<T536>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do537(T537 t) { Nullable<T537> n = new Nullable<T537>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do538(T538 t) { Nullable<T538> n = new Nullable<T538>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do539(T539 t) { Nullable<T539> n = new Nullable<T539>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do540(T540 t) { Nullable<T540> n = new Nullable<T540>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do541(T541 t) { Nullable<T541> n = new Nullable<T541>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do542(T542 t) { Nullable<T542> n = new Nullable<T542>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do543(T543 t) { Nullable<T543> n = new Nullable<T543>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do544(T544 t) { Nullable<T544> n = new Nullable<T544>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do545(T545 t) { Nullable<T545> n = new Nullable<T545>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do546(T546 t) { Nullable<T546> n = new Nullable<T546>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do547(T547 t) { Nullable<T547> n = new Nullable<T547>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do548(T548 t) { Nullable<T548> n = new Nullable<T548>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do549(T549 t) { Nullable<T549> n = new Nullable<T549>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do550(T550 t) { Nullable<T550> n = new Nullable<T550>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do551(T551 t) { Nullable<T551> n = new Nullable<T551>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do552(T552 t) { Nullable<T552> n = new Nullable<T552>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do553(T553 t) { Nullable<T553> n = new Nullable<T553>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do554(T554 t) { Nullable<T554> n = new Nullable<T554>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do555(T555 t) { Nullable<T555> n = new Nullable<T555>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do556(T556 t) { Nullable<T556> n = new Nullable<T556>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do557(T557 t) { Nullable<T557> n = new Nullable<T557>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do558(T558 t) { Nullable<T558> n = new Nullable<T558>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do559(T559 t) { Nullable<T559> n = new Nullable<T559>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do560(T560 t) { Nullable<T560> n = new Nullable<T560>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do561(T561 t) { Nullable<T561> n = new Nullable<T561>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do562(T562 t) { Nullable<T562> n = new Nullable<T562>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do563(T563 t) { Nullable<T563> n = new Nullable<T563>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do564(T564 t) { Nullable<T564> n = new Nullable<T564>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do565(T565 t) { Nullable<T565> n = new Nullable<T565>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do566(T566 t) { Nullable<T566> n = new Nullable<T566>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do567(T567 t) { Nullable<T567> n = new Nullable<T567>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do568(T568 t) { Nullable<T568> n = new Nullable<T568>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do569(T569 t) { Nullable<T569> n = new Nullable<T569>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do570(T570 t) { Nullable<T570> n = new Nullable<T570>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do571(T571 t) { Nullable<T571> n = new Nullable<T571>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do572(T572 t) { Nullable<T572> n = new Nullable<T572>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do573(T573 t) { Nullable<T573> n = new Nullable<T573>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do574(T574 t) { Nullable<T574> n = new Nullable<T574>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do575(T575 t) { Nullable<T575> n = new Nullable<T575>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do576(T576 t) { Nullable<T576> n = new Nullable<T576>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do577(T577 t) { Nullable<T577> n = new Nullable<T577>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do578(T578 t) { Nullable<T578> n = new Nullable<T578>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do579(T579 t) { Nullable<T579> n = new Nullable<T579>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do580(T580 t) { Nullable<T580> n = new Nullable<T580>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do581(T581 t) { Nullable<T581> n = new Nullable<T581>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do582(T582 t) { Nullable<T582> n = new Nullable<T582>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do583(T583 t) { Nullable<T583> n = new Nullable<T583>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do584(T584 t) { Nullable<T584> n = new Nullable<T584>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do585(T585 t) { Nullable<T585> n = new Nullable<T585>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do586(T586 t) { Nullable<T586> n = new Nullable<T586>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do587(T587 t) { Nullable<T587> n = new Nullable<T587>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do588(T588 t) { Nullable<T588> n = new Nullable<T588>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do589(T589 t) { Nullable<T589> n = new Nullable<T589>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do590(T590 t) { Nullable<T590> n = new Nullable<T590>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do591(T591 t) { Nullable<T591> n = new Nullable<T591>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do592(T592 t) { Nullable<T592> n = new Nullable<T592>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do593(T593 t) { Nullable<T593> n = new Nullable<T593>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do594(T594 t) { Nullable<T594> n = new Nullable<T594>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do595(T595 t) { Nullable<T595> n = new Nullable<T595>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do596(T596 t) { Nullable<T596> n = new Nullable<T596>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do597(T597 t) { Nullable<T597> n = new Nullable<T597>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do598(T598 t) { Nullable<T598> n = new Nullable<T598>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do599(T599 t) { Nullable<T599> n = new Nullable<T599>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do600(T600 t) { Nullable<T600> n = new Nullable<T600>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do601(T601 t) { Nullable<T601> n = new Nullable<T601>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do602(T602 t) { Nullable<T602> n = new Nullable<T602>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do603(T603 t) { Nullable<T603> n = new Nullable<T603>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do604(T604 t) { Nullable<T604> n = new Nullable<T604>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do605(T605 t) { Nullable<T605> n = new Nullable<T605>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do606(T606 t) { Nullable<T606> n = new Nullable<T606>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do607(T607 t) { Nullable<T607> n = new Nullable<T607>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do608(T608 t) { Nullable<T608> n = new Nullable<T608>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do609(T609 t) { Nullable<T609> n = new Nullable<T609>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do610(T610 t) { Nullable<T610> n = new Nullable<T610>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do611(T611 t) { Nullable<T611> n = new Nullable<T611>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do612(T612 t) { Nullable<T612> n = new Nullable<T612>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do613(T613 t) { Nullable<T613> n = new Nullable<T613>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do614(T614 t) { Nullable<T614> n = new Nullable<T614>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do615(T615 t) { Nullable<T615> n = new Nullable<T615>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do616(T616 t) { Nullable<T616> n = new Nullable<T616>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do617(T617 t) { Nullable<T617> n = new Nullable<T617>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do618(T618 t) { Nullable<T618> n = new Nullable<T618>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do619(T619 t) { Nullable<T619> n = new Nullable<T619>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do620(T620 t) { Nullable<T620> n = new Nullable<T620>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do621(T621 t) { Nullable<T621> n = new Nullable<T621>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do622(T622 t) { Nullable<T622> n = new Nullable<T622>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do623(T623 t) { Nullable<T623> n = new Nullable<T623>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do624(T624 t) { Nullable<T624> n = new Nullable<T624>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do625(T625 t) { Nullable<T625> n = new Nullable<T625>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do626(T626 t) { Nullable<T626> n = new Nullable<T626>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do627(T627 t) { Nullable<T627> n = new Nullable<T627>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do628(T628 t) { Nullable<T628> n = new Nullable<T628>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do629(T629 t) { Nullable<T629> n = new Nullable<T629>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do630(T630 t) { Nullable<T630> n = new Nullable<T630>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do631(T631 t) { Nullable<T631> n = new Nullable<T631>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do632(T632 t) { Nullable<T632> n = new Nullable<T632>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do633(T633 t) { Nullable<T633> n = new Nullable<T633>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do634(T634 t) { Nullable<T634> n = new Nullable<T634>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do635(T635 t) { Nullable<T635> n = new Nullable<T635>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do636(T636 t) { Nullable<T636> n = new Nullable<T636>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do637(T637 t) { Nullable<T637> n = new Nullable<T637>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do638(T638 t) { Nullable<T638> n = new Nullable<T638>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do639(T639 t) { Nullable<T639> n = new Nullable<T639>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do640(T640 t) { Nullable<T640> n = new Nullable<T640>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do641(T641 t) { Nullable<T641> n = new Nullable<T641>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do642(T642 t) { Nullable<T642> n = new Nullable<T642>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do643(T643 t) { Nullable<T643> n = new Nullable<T643>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do644(T644 t) { Nullable<T644> n = new Nullable<T644>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do645(T645 t) { Nullable<T645> n = new Nullable<T645>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do646(T646 t) { Nullable<T646> n = new Nullable<T646>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do647(T647 t) { Nullable<T647> n = new Nullable<T647>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do648(T648 t) { Nullable<T648> n = new Nullable<T648>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do649(T649 t) { Nullable<T649> n = new Nullable<T649>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do650(T650 t) { Nullable<T650> n = new Nullable<T650>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do651(T651 t) { Nullable<T651> n = new Nullable<T651>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do652(T652 t) { Nullable<T652> n = new Nullable<T652>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do653(T653 t) { Nullable<T653> n = new Nullable<T653>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do654(T654 t) { Nullable<T654> n = new Nullable<T654>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do655(T655 t) { Nullable<T655> n = new Nullable<T655>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do656(T656 t) { Nullable<T656> n = new Nullable<T656>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do657(T657 t) { Nullable<T657> n = new Nullable<T657>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do658(T658 t) { Nullable<T658> n = new Nullable<T658>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do659(T659 t) { Nullable<T659> n = new Nullable<T659>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do660(T660 t) { Nullable<T660> n = new Nullable<T660>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do661(T661 t) { Nullable<T661> n = new Nullable<T661>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do662(T662 t) { Nullable<T662> n = new Nullable<T662>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do663(T663 t) { Nullable<T663> n = new Nullable<T663>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do664(T664 t) { Nullable<T664> n = new Nullable<T664>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do665(T665 t) { Nullable<T665> n = new Nullable<T665>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do666(T666 t) { Nullable<T666> n = new Nullable<T666>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do667(T667 t) { Nullable<T667> n = new Nullable<T667>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do668(T668 t) { Nullable<T668> n = new Nullable<T668>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do669(T669 t) { Nullable<T669> n = new Nullable<T669>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do670(T670 t) { Nullable<T670> n = new Nullable<T670>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do671(T671 t) { Nullable<T671> n = new Nullable<T671>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do672(T672 t) { Nullable<T672> n = new Nullable<T672>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do673(T673 t) { Nullable<T673> n = new Nullable<T673>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do674(T674 t) { Nullable<T674> n = new Nullable<T674>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do675(T675 t) { Nullable<T675> n = new Nullable<T675>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do676(T676 t) { Nullable<T676> n = new Nullable<T676>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do677(T677 t) { Nullable<T677> n = new Nullable<T677>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do678(T678 t) { Nullable<T678> n = new Nullable<T678>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do679(T679 t) { Nullable<T679> n = new Nullable<T679>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do680(T680 t) { Nullable<T680> n = new Nullable<T680>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do681(T681 t) { Nullable<T681> n = new Nullable<T681>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do682(T682 t) { Nullable<T682> n = new Nullable<T682>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do683(T683 t) { Nullable<T683> n = new Nullable<T683>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do684(T684 t) { Nullable<T684> n = new Nullable<T684>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do685(T685 t) { Nullable<T685> n = new Nullable<T685>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do686(T686 t) { Nullable<T686> n = new Nullable<T686>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do687(T687 t) { Nullable<T687> n = new Nullable<T687>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do688(T688 t) { Nullable<T688> n = new Nullable<T688>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do689(T689 t) { Nullable<T689> n = new Nullable<T689>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do690(T690 t) { Nullable<T690> n = new Nullable<T690>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do691(T691 t) { Nullable<T691> n = new Nullable<T691>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do692(T692 t) { Nullable<T692> n = new Nullable<T692>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do693(T693 t) { Nullable<T693> n = new Nullable<T693>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do694(T694 t) { Nullable<T694> n = new Nullable<T694>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do695(T695 t) { Nullable<T695> n = new Nullable<T695>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do696(T696 t) { Nullable<T696> n = new Nullable<T696>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do697(T697 t) { Nullable<T697> n = new Nullable<T697>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do698(T698 t) { Nullable<T698> n = new Nullable<T698>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do699(T699 t) { Nullable<T699> n = new Nullable<T699>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do700(T700 t) { Nullable<T700> n = new Nullable<T700>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do701(T701 t) { Nullable<T701> n = new Nullable<T701>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do702(T702 t) { Nullable<T702> n = new Nullable<T702>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do703(T703 t) { Nullable<T703> n = new Nullable<T703>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do704(T704 t) { Nullable<T704> n = new Nullable<T704>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do705(T705 t) { Nullable<T705> n = new Nullable<T705>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do706(T706 t) { Nullable<T706> n = new Nullable<T706>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do707(T707 t) { Nullable<T707> n = new Nullable<T707>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do708(T708 t) { Nullable<T708> n = new Nullable<T708>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do709(T709 t) { Nullable<T709> n = new Nullable<T709>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do710(T710 t) { Nullable<T710> n = new Nullable<T710>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do711(T711 t) { Nullable<T711> n = new Nullable<T711>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do712(T712 t) { Nullable<T712> n = new Nullable<T712>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do713(T713 t) { Nullable<T713> n = new Nullable<T713>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do714(T714 t) { Nullable<T714> n = new Nullable<T714>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do715(T715 t) { Nullable<T715> n = new Nullable<T715>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do716(T716 t) { Nullable<T716> n = new Nullable<T716>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do717(T717 t) { Nullable<T717> n = new Nullable<T717>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do718(T718 t) { Nullable<T718> n = new Nullable<T718>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do719(T719 t) { Nullable<T719> n = new Nullable<T719>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do720(T720 t) { Nullable<T720> n = new Nullable<T720>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do721(T721 t) { Nullable<T721> n = new Nullable<T721>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do722(T722 t) { Nullable<T722> n = new Nullable<T722>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do723(T723 t) { Nullable<T723> n = new Nullable<T723>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do724(T724 t) { Nullable<T724> n = new Nullable<T724>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do725(T725 t) { Nullable<T725> n = new Nullable<T725>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do726(T726 t) { Nullable<T726> n = new Nullable<T726>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do727(T727 t) { Nullable<T727> n = new Nullable<T727>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do728(T728 t) { Nullable<T728> n = new Nullable<T728>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do729(T729 t) { Nullable<T729> n = new Nullable<T729>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do730(T730 t) { Nullable<T730> n = new Nullable<T730>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do731(T731 t) { Nullable<T731> n = new Nullable<T731>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do732(T732 t) { Nullable<T732> n = new Nullable<T732>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do733(T733 t) { Nullable<T733> n = new Nullable<T733>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do734(T734 t) { Nullable<T734> n = new Nullable<T734>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do735(T735 t) { Nullable<T735> n = new Nullable<T735>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do736(T736 t) { Nullable<T736> n = new Nullable<T736>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do737(T737 t) { Nullable<T737> n = new Nullable<T737>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do738(T738 t) { Nullable<T738> n = new Nullable<T738>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do739(T739 t) { Nullable<T739> n = new Nullable<T739>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do740(T740 t) { Nullable<T740> n = new Nullable<T740>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do741(T741 t) { Nullable<T741> n = new Nullable<T741>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do742(T742 t) { Nullable<T742> n = new Nullable<T742>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do743(T743 t) { Nullable<T743> n = new Nullable<T743>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do744(T744 t) { Nullable<T744> n = new Nullable<T744>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do745(T745 t) { Nullable<T745> n = new Nullable<T745>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do746(T746 t) { Nullable<T746> n = new Nullable<T746>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do747(T747 t) { Nullable<T747> n = new Nullable<T747>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do748(T748 t) { Nullable<T748> n = new Nullable<T748>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do749(T749 t) { Nullable<T749> n = new Nullable<T749>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do750(T750 t) { Nullable<T750> n = new Nullable<T750>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do751(T751 t) { Nullable<T751> n = new Nullable<T751>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do752(T752 t) { Nullable<T752> n = new Nullable<T752>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do753(T753 t) { Nullable<T753> n = new Nullable<T753>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do754(T754 t) { Nullable<T754> n = new Nullable<T754>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do755(T755 t) { Nullable<T755> n = new Nullable<T755>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do756(T756 t) { Nullable<T756> n = new Nullable<T756>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do757(T757 t) { Nullable<T757> n = new Nullable<T757>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do758(T758 t) { Nullable<T758> n = new Nullable<T758>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do759(T759 t) { Nullable<T759> n = new Nullable<T759>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do760(T760 t) { Nullable<T760> n = new Nullable<T760>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do761(T761 t) { Nullable<T761> n = new Nullable<T761>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do762(T762 t) { Nullable<T762> n = new Nullable<T762>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do763(T763 t) { Nullable<T763> n = new Nullable<T763>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do764(T764 t) { Nullable<T764> n = new Nullable<T764>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do765(T765 t) { Nullable<T765> n = new Nullable<T765>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do766(T766 t) { Nullable<T766> n = new Nullable<T766>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do767(T767 t) { Nullable<T767> n = new Nullable<T767>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do768(T768 t) { Nullable<T768> n = new Nullable<T768>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do769(T769 t) { Nullable<T769> n = new Nullable<T769>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do770(T770 t) { Nullable<T770> n = new Nullable<T770>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do771(T771 t) { Nullable<T771> n = new Nullable<T771>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do772(T772 t) { Nullable<T772> n = new Nullable<T772>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do773(T773 t) { Nullable<T773> n = new Nullable<T773>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do774(T774 t) { Nullable<T774> n = new Nullable<T774>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do775(T775 t) { Nullable<T775> n = new Nullable<T775>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do776(T776 t) { Nullable<T776> n = new Nullable<T776>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do777(T777 t) { Nullable<T777> n = new Nullable<T777>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do778(T778 t) { Nullable<T778> n = new Nullable<T778>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do779(T779 t) { Nullable<T779> n = new Nullable<T779>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do780(T780 t) { Nullable<T780> n = new Nullable<T780>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do781(T781 t) { Nullable<T781> n = new Nullable<T781>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do782(T782 t) { Nullable<T782> n = new Nullable<T782>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do783(T783 t) { Nullable<T783> n = new Nullable<T783>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do784(T784 t) { Nullable<T784> n = new Nullable<T784>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do785(T785 t) { Nullable<T785> n = new Nullable<T785>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do786(T786 t) { Nullable<T786> n = new Nullable<T786>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do787(T787 t) { Nullable<T787> n = new Nullable<T787>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do788(T788 t) { Nullable<T788> n = new Nullable<T788>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do789(T789 t) { Nullable<T789> n = new Nullable<T789>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do790(T790 t) { Nullable<T790> n = new Nullable<T790>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do791(T791 t) { Nullable<T791> n = new Nullable<T791>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do792(T792 t) { Nullable<T792> n = new Nullable<T792>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do793(T793 t) { Nullable<T793> n = new Nullable<T793>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do794(T794 t) { Nullable<T794> n = new Nullable<T794>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do795(T795 t) { Nullable<T795> n = new Nullable<T795>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do796(T796 t) { Nullable<T796> n = new Nullable<T796>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do797(T797 t) { Nullable<T797> n = new Nullable<T797>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do798(T798 t) { Nullable<T798> n = new Nullable<T798>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do799(T799 t) { Nullable<T799> n = new Nullable<T799>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do800(T800 t) { Nullable<T800> n = new Nullable<T800>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do801(T801 t) { Nullable<T801> n = new Nullable<T801>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do802(T802 t) { Nullable<T802> n = new Nullable<T802>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do803(T803 t) { Nullable<T803> n = new Nullable<T803>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do804(T804 t) { Nullable<T804> n = new Nullable<T804>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do805(T805 t) { Nullable<T805> n = new Nullable<T805>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do806(T806 t) { Nullable<T806> n = new Nullable<T806>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do807(T807 t) { Nullable<T807> n = new Nullable<T807>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do808(T808 t) { Nullable<T808> n = new Nullable<T808>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do809(T809 t) { Nullable<T809> n = new Nullable<T809>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do810(T810 t) { Nullable<T810> n = new Nullable<T810>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do811(T811 t) { Nullable<T811> n = new Nullable<T811>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do812(T812 t) { Nullable<T812> n = new Nullable<T812>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do813(T813 t) { Nullable<T813> n = new Nullable<T813>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do814(T814 t) { Nullable<T814> n = new Nullable<T814>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do815(T815 t) { Nullable<T815> n = new Nullable<T815>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do816(T816 t) { Nullable<T816> n = new Nullable<T816>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do817(T817 t) { Nullable<T817> n = new Nullable<T817>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do818(T818 t) { Nullable<T818> n = new Nullable<T818>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do819(T819 t) { Nullable<T819> n = new Nullable<T819>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do820(T820 t) { Nullable<T820> n = new Nullable<T820>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do821(T821 t) { Nullable<T821> n = new Nullable<T821>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do822(T822 t) { Nullable<T822> n = new Nullable<T822>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do823(T823 t) { Nullable<T823> n = new Nullable<T823>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do824(T824 t) { Nullable<T824> n = new Nullable<T824>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do825(T825 t) { Nullable<T825> n = new Nullable<T825>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do826(T826 t) { Nullable<T826> n = new Nullable<T826>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do827(T827 t) { Nullable<T827> n = new Nullable<T827>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do828(T828 t) { Nullable<T828> n = new Nullable<T828>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do829(T829 t) { Nullable<T829> n = new Nullable<T829>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do830(T830 t) { Nullable<T830> n = new Nullable<T830>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do831(T831 t) { Nullable<T831> n = new Nullable<T831>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do832(T832 t) { Nullable<T832> n = new Nullable<T832>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do833(T833 t) { Nullable<T833> n = new Nullable<T833>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do834(T834 t) { Nullable<T834> n = new Nullable<T834>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do835(T835 t) { Nullable<T835> n = new Nullable<T835>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do836(T836 t) { Nullable<T836> n = new Nullable<T836>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do837(T837 t) { Nullable<T837> n = new Nullable<T837>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do838(T838 t) { Nullable<T838> n = new Nullable<T838>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do839(T839 t) { Nullable<T839> n = new Nullable<T839>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do840(T840 t) { Nullable<T840> n = new Nullable<T840>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do841(T841 t) { Nullable<T841> n = new Nullable<T841>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do842(T842 t) { Nullable<T842> n = new Nullable<T842>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do843(T843 t) { Nullable<T843> n = new Nullable<T843>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do844(T844 t) { Nullable<T844> n = new Nullable<T844>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do845(T845 t) { Nullable<T845> n = new Nullable<T845>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do846(T846 t) { Nullable<T846> n = new Nullable<T846>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do847(T847 t) { Nullable<T847> n = new Nullable<T847>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do848(T848 t) { Nullable<T848> n = new Nullable<T848>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do849(T849 t) { Nullable<T849> n = new Nullable<T849>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do850(T850 t) { Nullable<T850> n = new Nullable<T850>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do851(T851 t) { Nullable<T851> n = new Nullable<T851>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do852(T852 t) { Nullable<T852> n = new Nullable<T852>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do853(T853 t) { Nullable<T853> n = new Nullable<T853>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do854(T854 t) { Nullable<T854> n = new Nullable<T854>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do855(T855 t) { Nullable<T855> n = new Nullable<T855>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do856(T856 t) { Nullable<T856> n = new Nullable<T856>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do857(T857 t) { Nullable<T857> n = new Nullable<T857>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do858(T858 t) { Nullable<T858> n = new Nullable<T858>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do859(T859 t) { Nullable<T859> n = new Nullable<T859>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do860(T860 t) { Nullable<T860> n = new Nullable<T860>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do861(T861 t) { Nullable<T861> n = new Nullable<T861>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do862(T862 t) { Nullable<T862> n = new Nullable<T862>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do863(T863 t) { Nullable<T863> n = new Nullable<T863>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do864(T864 t) { Nullable<T864> n = new Nullable<T864>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do865(T865 t) { Nullable<T865> n = new Nullable<T865>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do866(T866 t) { Nullable<T866> n = new Nullable<T866>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do867(T867 t) { Nullable<T867> n = new Nullable<T867>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do868(T868 t) { Nullable<T868> n = new Nullable<T868>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do869(T869 t) { Nullable<T869> n = new Nullable<T869>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do870(T870 t) { Nullable<T870> n = new Nullable<T870>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do871(T871 t) { Nullable<T871> n = new Nullable<T871>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do872(T872 t) { Nullable<T872> n = new Nullable<T872>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do873(T873 t) { Nullable<T873> n = new Nullable<T873>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do874(T874 t) { Nullable<T874> n = new Nullable<T874>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do875(T875 t) { Nullable<T875> n = new Nullable<T875>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do876(T876 t) { Nullable<T876> n = new Nullable<T876>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do877(T877 t) { Nullable<T877> n = new Nullable<T877>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do878(T878 t) { Nullable<T878> n = new Nullable<T878>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do879(T879 t) { Nullable<T879> n = new Nullable<T879>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do880(T880 t) { Nullable<T880> n = new Nullable<T880>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do881(T881 t) { Nullable<T881> n = new Nullable<T881>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do882(T882 t) { Nullable<T882> n = new Nullable<T882>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do883(T883 t) { Nullable<T883> n = new Nullable<T883>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do884(T884 t) { Nullable<T884> n = new Nullable<T884>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do885(T885 t) { Nullable<T885> n = new Nullable<T885>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do886(T886 t) { Nullable<T886> n = new Nullable<T886>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do887(T887 t) { Nullable<T887> n = new Nullable<T887>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do888(T888 t) { Nullable<T888> n = new Nullable<T888>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do889(T889 t) { Nullable<T889> n = new Nullable<T889>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do890(T890 t) { Nullable<T890> n = new Nullable<T890>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do891(T891 t) { Nullable<T891> n = new Nullable<T891>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do892(T892 t) { Nullable<T892> n = new Nullable<T892>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do893(T893 t) { Nullable<T893> n = new Nullable<T893>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do894(T894 t) { Nullable<T894> n = new Nullable<T894>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do895(T895 t) { Nullable<T895> n = new Nullable<T895>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do896(T896 t) { Nullable<T896> n = new Nullable<T896>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do897(T897 t) { Nullable<T897> n = new Nullable<T897>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do898(T898 t) { Nullable<T898> n = new Nullable<T898>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do899(T899 t) { Nullable<T899> n = new Nullable<T899>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do900(T900 t) { Nullable<T900> n = new Nullable<T900>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do901(T901 t) { Nullable<T901> n = new Nullable<T901>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do902(T902 t) { Nullable<T902> n = new Nullable<T902>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do903(T903 t) { Nullable<T903> n = new Nullable<T903>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do904(T904 t) { Nullable<T904> n = new Nullable<T904>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do905(T905 t) { Nullable<T905> n = new Nullable<T905>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do906(T906 t) { Nullable<T906> n = new Nullable<T906>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do907(T907 t) { Nullable<T907> n = new Nullable<T907>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do908(T908 t) { Nullable<T908> n = new Nullable<T908>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do909(T909 t) { Nullable<T909> n = new Nullable<T909>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do910(T910 t) { Nullable<T910> n = new Nullable<T910>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do911(T911 t) { Nullable<T911> n = new Nullable<T911>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do912(T912 t) { Nullable<T912> n = new Nullable<T912>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do913(T913 t) { Nullable<T913> n = new Nullable<T913>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do914(T914 t) { Nullable<T914> n = new Nullable<T914>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do915(T915 t) { Nullable<T915> n = new Nullable<T915>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do916(T916 t) { Nullable<T916> n = new Nullable<T916>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do917(T917 t) { Nullable<T917> n = new Nullable<T917>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do918(T918 t) { Nullable<T918> n = new Nullable<T918>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do919(T919 t) { Nullable<T919> n = new Nullable<T919>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do920(T920 t) { Nullable<T920> n = new Nullable<T920>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do921(T921 t) { Nullable<T921> n = new Nullable<T921>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do922(T922 t) { Nullable<T922> n = new Nullable<T922>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do923(T923 t) { Nullable<T923> n = new Nullable<T923>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do924(T924 t) { Nullable<T924> n = new Nullable<T924>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do925(T925 t) { Nullable<T925> n = new Nullable<T925>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do926(T926 t) { Nullable<T926> n = new Nullable<T926>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do927(T927 t) { Nullable<T927> n = new Nullable<T927>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do928(T928 t) { Nullable<T928> n = new Nullable<T928>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do929(T929 t) { Nullable<T929> n = new Nullable<T929>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do930(T930 t) { Nullable<T930> n = new Nullable<T930>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do931(T931 t) { Nullable<T931> n = new Nullable<T931>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do932(T932 t) { Nullable<T932> n = new Nullable<T932>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do933(T933 t) { Nullable<T933> n = new Nullable<T933>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do934(T934 t) { Nullable<T934> n = new Nullable<T934>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do935(T935 t) { Nullable<T935> n = new Nullable<T935>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do936(T936 t) { Nullable<T936> n = new Nullable<T936>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do937(T937 t) { Nullable<T937> n = new Nullable<T937>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do938(T938 t) { Nullable<T938> n = new Nullable<T938>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do939(T939 t) { Nullable<T939> n = new Nullable<T939>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do940(T940 t) { Nullable<T940> n = new Nullable<T940>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do941(T941 t) { Nullable<T941> n = new Nullable<T941>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do942(T942 t) { Nullable<T942> n = new Nullable<T942>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do943(T943 t) { Nullable<T943> n = new Nullable<T943>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do944(T944 t) { Nullable<T944> n = new Nullable<T944>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do945(T945 t) { Nullable<T945> n = new Nullable<T945>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do946(T946 t) { Nullable<T946> n = new Nullable<T946>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do947(T947 t) { Nullable<T947> n = new Nullable<T947>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do948(T948 t) { Nullable<T948> n = new Nullable<T948>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do949(T949 t) { Nullable<T949> n = new Nullable<T949>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do950(T950 t) { Nullable<T950> n = new Nullable<T950>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do951(T951 t) { Nullable<T951> n = new Nullable<T951>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do952(T952 t) { Nullable<T952> n = new Nullable<T952>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do953(T953 t) { Nullable<T953> n = new Nullable<T953>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do954(T954 t) { Nullable<T954> n = new Nullable<T954>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do955(T955 t) { Nullable<T955> n = new Nullable<T955>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do956(T956 t) { Nullable<T956> n = new Nullable<T956>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do957(T957 t) { Nullable<T957> n = new Nullable<T957>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do958(T958 t) { Nullable<T958> n = new Nullable<T958>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do959(T959 t) { Nullable<T959> n = new Nullable<T959>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do960(T960 t) { Nullable<T960> n = new Nullable<T960>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do961(T961 t) { Nullable<T961> n = new Nullable<T961>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do962(T962 t) { Nullable<T962> n = new Nullable<T962>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do963(T963 t) { Nullable<T963> n = new Nullable<T963>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do964(T964 t) { Nullable<T964> n = new Nullable<T964>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do965(T965 t) { Nullable<T965> n = new Nullable<T965>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do966(T966 t) { Nullable<T966> n = new Nullable<T966>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do967(T967 t) { Nullable<T967> n = new Nullable<T967>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do968(T968 t) { Nullable<T968> n = new Nullable<T968>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do969(T969 t) { Nullable<T969> n = new Nullable<T969>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do970(T970 t) { Nullable<T970> n = new Nullable<T970>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do971(T971 t) { Nullable<T971> n = new Nullable<T971>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do972(T972 t) { Nullable<T972> n = new Nullable<T972>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do973(T973 t) { Nullable<T973> n = new Nullable<T973>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do974(T974 t) { Nullable<T974> n = new Nullable<T974>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do975(T975 t) { Nullable<T975> n = new Nullable<T975>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do976(T976 t) { Nullable<T976> n = new Nullable<T976>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do977(T977 t) { Nullable<T977> n = new Nullable<T977>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do978(T978 t) { Nullable<T978> n = new Nullable<T978>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do979(T979 t) { Nullable<T979> n = new Nullable<T979>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do980(T980 t) { Nullable<T980> n = new Nullable<T980>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do981(T981 t) { Nullable<T981> n = new Nullable<T981>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do982(T982 t) { Nullable<T982> n = new Nullable<T982>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do983(T983 t) { Nullable<T983> n = new Nullable<T983>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do984(T984 t) { Nullable<T984> n = new Nullable<T984>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do985(T985 t) { Nullable<T985> n = new Nullable<T985>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do986(T986 t) { Nullable<T986> n = new Nullable<T986>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do987(T987 t) { Nullable<T987> n = new Nullable<T987>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do988(T988 t) { Nullable<T988> n = new Nullable<T988>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do989(T989 t) { Nullable<T989> n = new Nullable<T989>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do990(T990 t) { Nullable<T990> n = new Nullable<T990>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do991(T991 t) { Nullable<T991> n = new Nullable<T991>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do992(T992 t) { Nullable<T992> n = new Nullable<T992>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do993(T993 t) { Nullable<T993> n = new Nullable<T993>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do994(T994 t) { Nullable<T994> n = new Nullable<T994>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do995(T995 t) { Nullable<T995> n = new Nullable<T995>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do996(T996 t) { Nullable<T996> n = new Nullable<T996>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do997(T997 t) { Nullable<T997> n = new Nullable<T997>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do998(T998 t) { Nullable<T998> n = new Nullable<T998>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Do999(T999 t) { Nullable<T999> n = new Nullable<T999>(t); return Ensure(n.HasValue && n.Value == t); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Ensure(bool pred) { if (!pred) throw new Exception("Ensure fails"); return pred; } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Generics/Arrays/ConstructedTypes/Jagged/struct01_static.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; public struct ValX1<T> { public T t; public ValX1(T t) { this.t = t; } } public class RefX1<T> { public T t; public RefX1(T t) { this.t = t; } } public struct Gen<T> { public T Fld1; public Gen(T fld1) { Fld1 = fld1; } } public class ArrayHolder { public static Gen<int>[][][][][] GenArray = new Gen<int>[10][][][][]; } public class Test_struct01_static { public static int counter = 0; public static bool result = true; public static void Eval(bool exp) { counter++; if (!exp) { result = exp; Console.WriteLine("Test Failed at location: " + counter); } } public static int Main() { int size = 10; int i, j, k, l, m; double sum = 0; for (i = 0; i < size; i++) { ArrayHolder.GenArray[i] = new Gen<int>[i][][][]; for (j = 0; j < i; j++) { ArrayHolder.GenArray[i][j] = new Gen<int>[j][][]; for (k = 0; k < j; k++) { ArrayHolder.GenArray[i][j][k] = new Gen<int>[k][]; for (l = 0; l < k; l++) { ArrayHolder.GenArray[i][j][k][l] = new Gen<int>[l]; for (m = 0; m < l; m++) { ArrayHolder.GenArray[i][j][k][l][m] = new Gen<int>(i * j * k * l * m); } } } } } for (i = 0; i < size; i++) { for (j = 0; j < i; j++) { for (k = 0; k < j; k++) { for (l = 0; l < k; l++) { for (m = 0; m < l; m++) { sum += ArrayHolder.GenArray[i][j][k][l][m].Fld1; } } } } } Eval(sum == 269325); sum = 0; if (result) { Console.WriteLine("Test Passed"); return 100; } else { 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. // using System; public struct ValX1<T> { public T t; public ValX1(T t) { this.t = t; } } public class RefX1<T> { public T t; public RefX1(T t) { this.t = t; } } public struct Gen<T> { public T Fld1; public Gen(T fld1) { Fld1 = fld1; } } public class ArrayHolder { public static Gen<int>[][][][][] GenArray = new Gen<int>[10][][][][]; } public class Test_struct01_static { public static int counter = 0; public static bool result = true; public static void Eval(bool exp) { counter++; if (!exp) { result = exp; Console.WriteLine("Test Failed at location: " + counter); } } public static int Main() { int size = 10; int i, j, k, l, m; double sum = 0; for (i = 0; i < size; i++) { ArrayHolder.GenArray[i] = new Gen<int>[i][][][]; for (j = 0; j < i; j++) { ArrayHolder.GenArray[i][j] = new Gen<int>[j][][]; for (k = 0; k < j; k++) { ArrayHolder.GenArray[i][j][k] = new Gen<int>[k][]; for (l = 0; l < k; l++) { ArrayHolder.GenArray[i][j][k][l] = new Gen<int>[l]; for (m = 0; m < l; m++) { ArrayHolder.GenArray[i][j][k][l][m] = new Gen<int>(i * j * k * l * m); } } } } } for (i = 0; i < size; i++) { for (j = 0; j < i; j++) { for (k = 0; k < j; k++) { for (l = 0; l < k; l++) { for (m = 0; m < l; m++) { sum += ArrayHolder.GenArray[i][j][k][l][m].Fld1; } } } } } Eval(sum == 269325); sum = 0; if (result) { Console.WriteLine("Test Passed"); return 100; } else { Console.WriteLine("Test Failed"); return 1; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.macOS.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.Diagnostics; using System.IO; using System.Security.Cryptography.Apple; using Microsoft.Win32.SafeHandles; namespace System.Security.Cryptography.X509Certificates { internal sealed partial class StorePal { internal static partial IStorePal FromHandle(IntPtr storeHandle) { if (storeHandle == IntPtr.Zero) throw new ArgumentNullException(nameof(storeHandle)); var keychainHandle = new SafeKeychainHandle(storeHandle); Interop.CoreFoundation.CFRetain(storeHandle); return new AppleKeychainStore(keychainHandle, OpenFlags.MaxAllowed); } internal static partial ILoaderPal FromBlob(ReadOnlySpan<byte> rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) { Debug.Assert(password != null); X509ContentType contentType = X509Certificate2.GetCertContentType(rawData); if (contentType == X509ContentType.Pkcs12) { if ((keyStorageFlags & X509KeyStorageFlags.EphemeralKeySet) == X509KeyStorageFlags.EphemeralKeySet) { throw new PlatformNotSupportedException(SR.Cryptography_X509_NoEphemeralPfx); } bool exportable = (keyStorageFlags & X509KeyStorageFlags.Exportable) == X509KeyStorageFlags.Exportable; bool persist = (keyStorageFlags & X509KeyStorageFlags.PersistKeySet) == X509KeyStorageFlags.PersistKeySet; SafeKeychainHandle keychain = persist ? Interop.AppleCrypto.SecKeychainCopyDefault() : Interop.AppleCrypto.CreateTemporaryKeychain(); return ImportPkcs12(rawData, password, exportable, ephemeralSpecified: false, keychain); } SafeCFArrayHandle certs = Interop.AppleCrypto.X509ImportCollection( rawData, contentType, password, SafeTemporaryKeychainHandle.InvalidHandle, exportable: true); return new AppleCertLoader(certs, null); } private static ILoaderPal ImportPkcs12( ReadOnlySpan<byte> rawData, SafePasswordHandle password, bool exportable, bool ephemeralSpecified, SafeKeychainHandle keychain) { ApplePkcs12Reader reader = new ApplePkcs12Reader(rawData); try { reader.Decrypt(password, ephemeralSpecified); return new ApplePkcs12CertLoader(reader, keychain, password, exportable); } catch { reader.Dispose(); keychain.Dispose(); throw; } } internal static partial ILoaderPal FromFile(string fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) { Debug.Assert(password != null); byte[] fileBytes = File.ReadAllBytes(fileName); return FromBlob(fileBytes, password, keyStorageFlags); } internal static partial IExportPal FromCertificate(ICertificatePalCore cert) { return new AppleCertificateExporter(cert); } internal static partial IExportPal LinkFromCertificateCollection(X509Certificate2Collection certificates) { return new AppleCertificateExporter(certificates); } internal static partial IStorePal FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags) { StringComparer ordinalIgnoreCase = StringComparer.OrdinalIgnoreCase; switch (storeLocation) { case StoreLocation.CurrentUser: if (ordinalIgnoreCase.Equals("My", storeName)) return AppleKeychainStore.OpenDefaultKeychain(openFlags); if (ordinalIgnoreCase.Equals("Root", storeName)) return AppleTrustStore.OpenStore(StoreName.Root, storeLocation, openFlags); if (ordinalIgnoreCase.Equals("Disallowed", storeName)) return AppleTrustStore.OpenStore(StoreName.Disallowed, storeLocation, openFlags); return FromCustomKeychainStore(storeName, openFlags); case StoreLocation.LocalMachine: if (ordinalIgnoreCase.Equals("My", storeName)) return AppleKeychainStore.OpenSystemSharedKeychain(openFlags); if (ordinalIgnoreCase.Equals("Root", storeName)) return AppleTrustStore.OpenStore(StoreName.Root, storeLocation, openFlags); if (ordinalIgnoreCase.Equals("Disallowed", storeName)) return AppleTrustStore.OpenStore(StoreName.Disallowed, storeLocation, openFlags); break; } if ((openFlags & OpenFlags.OpenExistingOnly) == OpenFlags.OpenExistingOnly) throw new CryptographicException(SR.Cryptography_X509_StoreNotFound); string message = SR.Format( SR.Cryptography_X509_StoreCannotCreate, storeName, storeLocation); throw new CryptographicException(message, new PlatformNotSupportedException(message)); } private static IStorePal FromCustomKeychainStore(string storeName, OpenFlags openFlags) { string storePath; if (!IsValidStoreName(storeName)) throw new CryptographicException(SR.Format(SR.Security_InvalidValue, nameof(storeName))); storePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Keychains", storeName.ToLowerInvariant() + ".keychain"); return AppleKeychainStore.CreateOrOpenKeychain(storePath, openFlags); } private static bool IsValidStoreName(string storeName) { try { return !string.IsNullOrWhiteSpace(storeName) && Path.GetFileName(storeName) == storeName; } catch (IOException) { return false; } } private static void ReadCollection(SafeCFArrayHandle matches, HashSet<X509Certificate2> collection) { if (matches.IsInvalid) { return; } long count = Interop.CoreFoundation.CFArrayGetCount(matches); for (int i = 0; i < count; i++) { IntPtr handle = Interop.CoreFoundation.CFArrayGetValueAtIndex(matches, i); SafeSecCertificateHandle certHandle; SafeSecIdentityHandle identityHandle; if (Interop.AppleCrypto.X509DemuxAndRetainHandle(handle, out certHandle, out identityHandle)) { X509Certificate2 cert; if (certHandle.IsInvalid) { certHandle.Dispose(); cert = new X509Certificate2(new AppleCertificatePal(identityHandle)); } else { identityHandle.Dispose(); cert = new X509Certificate2(new AppleCertificatePal(certHandle)); } if (!collection.Add(cert)) { cert.Dispose(); } } } } } }
// 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.Diagnostics; using System.IO; using System.Security.Cryptography.Apple; using Microsoft.Win32.SafeHandles; namespace System.Security.Cryptography.X509Certificates { internal sealed partial class StorePal { internal static partial IStorePal FromHandle(IntPtr storeHandle) { if (storeHandle == IntPtr.Zero) throw new ArgumentNullException(nameof(storeHandle)); var keychainHandle = new SafeKeychainHandle(storeHandle); Interop.CoreFoundation.CFRetain(storeHandle); return new AppleKeychainStore(keychainHandle, OpenFlags.MaxAllowed); } internal static partial ILoaderPal FromBlob(ReadOnlySpan<byte> rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) { Debug.Assert(password != null); X509ContentType contentType = X509Certificate2.GetCertContentType(rawData); if (contentType == X509ContentType.Pkcs12) { if ((keyStorageFlags & X509KeyStorageFlags.EphemeralKeySet) == X509KeyStorageFlags.EphemeralKeySet) { throw new PlatformNotSupportedException(SR.Cryptography_X509_NoEphemeralPfx); } bool exportable = (keyStorageFlags & X509KeyStorageFlags.Exportable) == X509KeyStorageFlags.Exportable; bool persist = (keyStorageFlags & X509KeyStorageFlags.PersistKeySet) == X509KeyStorageFlags.PersistKeySet; SafeKeychainHandle keychain = persist ? Interop.AppleCrypto.SecKeychainCopyDefault() : Interop.AppleCrypto.CreateTemporaryKeychain(); return ImportPkcs12(rawData, password, exportable, ephemeralSpecified: false, keychain); } SafeCFArrayHandle certs = Interop.AppleCrypto.X509ImportCollection( rawData, contentType, password, SafeTemporaryKeychainHandle.InvalidHandle, exportable: true); return new AppleCertLoader(certs, null); } private static ILoaderPal ImportPkcs12( ReadOnlySpan<byte> rawData, SafePasswordHandle password, bool exportable, bool ephemeralSpecified, SafeKeychainHandle keychain) { ApplePkcs12Reader reader = new ApplePkcs12Reader(rawData); try { reader.Decrypt(password, ephemeralSpecified); return new ApplePkcs12CertLoader(reader, keychain, password, exportable); } catch { reader.Dispose(); keychain.Dispose(); throw; } } internal static partial ILoaderPal FromFile(string fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) { Debug.Assert(password != null); byte[] fileBytes = File.ReadAllBytes(fileName); return FromBlob(fileBytes, password, keyStorageFlags); } internal static partial IExportPal FromCertificate(ICertificatePalCore cert) { return new AppleCertificateExporter(cert); } internal static partial IExportPal LinkFromCertificateCollection(X509Certificate2Collection certificates) { return new AppleCertificateExporter(certificates); } internal static partial IStorePal FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags) { StringComparer ordinalIgnoreCase = StringComparer.OrdinalIgnoreCase; switch (storeLocation) { case StoreLocation.CurrentUser: if (ordinalIgnoreCase.Equals("My", storeName)) return AppleKeychainStore.OpenDefaultKeychain(openFlags); if (ordinalIgnoreCase.Equals("Root", storeName)) return AppleTrustStore.OpenStore(StoreName.Root, storeLocation, openFlags); if (ordinalIgnoreCase.Equals("Disallowed", storeName)) return AppleTrustStore.OpenStore(StoreName.Disallowed, storeLocation, openFlags); return FromCustomKeychainStore(storeName, openFlags); case StoreLocation.LocalMachine: if (ordinalIgnoreCase.Equals("My", storeName)) return AppleKeychainStore.OpenSystemSharedKeychain(openFlags); if (ordinalIgnoreCase.Equals("Root", storeName)) return AppleTrustStore.OpenStore(StoreName.Root, storeLocation, openFlags); if (ordinalIgnoreCase.Equals("Disallowed", storeName)) return AppleTrustStore.OpenStore(StoreName.Disallowed, storeLocation, openFlags); break; } if ((openFlags & OpenFlags.OpenExistingOnly) == OpenFlags.OpenExistingOnly) throw new CryptographicException(SR.Cryptography_X509_StoreNotFound); string message = SR.Format( SR.Cryptography_X509_StoreCannotCreate, storeName, storeLocation); throw new CryptographicException(message, new PlatformNotSupportedException(message)); } private static IStorePal FromCustomKeychainStore(string storeName, OpenFlags openFlags) { string storePath; if (!IsValidStoreName(storeName)) throw new CryptographicException(SR.Format(SR.Security_InvalidValue, nameof(storeName))); storePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Keychains", storeName.ToLowerInvariant() + ".keychain"); return AppleKeychainStore.CreateOrOpenKeychain(storePath, openFlags); } private static bool IsValidStoreName(string storeName) { try { return !string.IsNullOrWhiteSpace(storeName) && Path.GetFileName(storeName) == storeName; } catch (IOException) { return false; } } private static void ReadCollection(SafeCFArrayHandle matches, HashSet<X509Certificate2> collection) { if (matches.IsInvalid) { return; } long count = Interop.CoreFoundation.CFArrayGetCount(matches); for (int i = 0; i < count; i++) { IntPtr handle = Interop.CoreFoundation.CFArrayGetValueAtIndex(matches, i); SafeSecCertificateHandle certHandle; SafeSecIdentityHandle identityHandle; if (Interop.AppleCrypto.X509DemuxAndRetainHandle(handle, out certHandle, out identityHandle)) { X509Certificate2 cert; if (certHandle.IsInvalid) { certHandle.Dispose(); cert = new X509Certificate2(new AppleCertificatePal(identityHandle)); } else { identityHandle.Dispose(); cert = new X509Certificate2(new AppleCertificatePal(certHandle)); } if (!collection.Add(cert)) { cert.Dispose(); } } } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/SafeBufferTests.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.Runtime.InteropServices.Tests { public class SafeBufferTests { [Theory] [InlineData(true)] [InlineData(false)] public void Ctor_Bool(bool ownsHandle) { var buffer = new SubBuffer(ownsHandle); Assert.True(buffer.IsInvalid); } [Fact] public void Initialize_InvalidNumBytes_ThrowsArgumentOutOfRangeException() { var buffer = new SubBuffer(true); AssertExtensions.Throws<ArgumentOutOfRangeException>("numBytes", () => buffer.Initialize(ulong.MaxValue)); } [Fact] public void Initialize_NumBytesTimesSizeOfEachElement_ThrowsArgumentOutOfRangeExceptionIfNot64Bit() { var buffer = new SubBuffer(true); AssertExtensions.ThrowsIf<ArgumentOutOfRangeException>(!Environment.Is64BitProcess, () => buffer.Initialize(uint.MaxValue, uint.MaxValue)); AssertExtensions.ThrowsIf<ArgumentOutOfRangeException>(!Environment.Is64BitProcess, () => buffer.Initialize<int>(uint.MaxValue)); } [Fact] public unsafe void AcquirePointer_NotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); byte* pointer = null; Assert.Throws<InvalidOperationException>(() => wrapper.AcquirePointer(ref pointer)); } [Fact] public unsafe void AcquirePointer_Disposed_ThrowsObjectDisposedException() { var buffer = new SubBuffer(true); buffer.Initialize(4); buffer.Dispose(); byte* pointer = (byte*)12345; Assert.Throws<ObjectDisposedException>(() => buffer.AcquirePointer(ref pointer)); Assert.True(pointer is null); } [Fact] public void ReleasePointer_NotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); Assert.Throws<InvalidOperationException>(() => wrapper.ReleasePointer()); } [Fact] public void ReadWrite_NotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); Assert.Throws<InvalidOperationException>(() => wrapper.Read<int>(0)); Assert.Throws<InvalidOperationException>(() => wrapper.Write(0, 2)); } [Theory] [InlineData(4)] [InlineData(3)] [InlineData(ulong.MaxValue)] public void ReadWrite_NotEnoughSpaceInBuffer_ThrowsArgumentException(ulong byteOffset) { var buffer = new SubBuffer(true); buffer.Initialize(4); AssertExtensions.Throws<ArgumentException>(null, () => buffer.Read<int>(byteOffset)); AssertExtensions.Throws<ArgumentException>(null, () => buffer.Write<int>(byteOffset, 2)); } [Fact] public void ReadArray_NullArray_ThrowsArgumentNullException() { var wrapper = new SubBuffer(true); AssertExtensions.Throws<ArgumentNullException>("array", () => wrapper.ReadArray<int>(0, null, 0, 0)); AssertExtensions.Throws<ArgumentNullException>("array", () => wrapper.WriteArray<int>(0, null, 0, 0)); } [Fact] public void ReadWriteSpan_EmptySpan_Passes() { var buffer = new SubBuffer(true); buffer.Initialize(0); buffer.ReadSpan<int>(0, Span<int>.Empty); buffer.WriteSpan<int>(0, ReadOnlySpan<int>.Empty); } [Fact] public void ReadArray_NegativeIndex_ThrowsArgumentOutOfRangeException() { var wrapper = new SubBuffer(true); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => wrapper.ReadArray(0, new int[0], -1, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => wrapper.WriteArray(0, new int[0], -1, 0)); } [Fact] public void ReadWriteArray_NegativeCount_ThrowsArgumentOutOfRangeException() { var wrapper = new SubBuffer(true); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => wrapper.ReadArray(0, new int[0], 0, -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => wrapper.WriteArray(0, new int[0], 0, -1)); } [Theory] [InlineData(0, 1, 0)] [InlineData(0, 0, 1)] [InlineData(2, 3, 0)] [InlineData(2, 2, 1)] [InlineData(2, 1, 2)] [InlineData(2, 0, 3)] public void ReadWriteArray_NegativeCount_ThrowsArgumentException(int arrayLength, int index, int count) { var wrapper = new SubBuffer(true); AssertExtensions.Throws<ArgumentException>(null, () => wrapper.ReadArray(0, new int[arrayLength], index, count)); AssertExtensions.Throws<ArgumentException>(null, () => wrapper.WriteArray(0, new int[arrayLength], index, count)); } [Fact] public void ReadWriteArray_NotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); Assert.Throws<InvalidOperationException>(() => wrapper.ReadArray(0, new int[0], 0, 0)); Assert.Throws<InvalidOperationException>(() => wrapper.WriteArray(0, new int[0], 0, 0)); } [Fact] public void ByteLength_GetNotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); Assert.Throws<InvalidOperationException>(() => wrapper.ByteLength); } [Fact] public void ReadWrite_RoundTrip() { using var buffer = new HGlobalBuffer(100); int intValue = 1234; buffer.Write<int>(0, intValue); Assert.Equal(intValue, buffer.Read<int>(0)); double doubleValue = 123.45; buffer.Write<double>(10, doubleValue); Assert.Equal(doubleValue, buffer.Read<double>(10)); TestStruct structValue = new TestStruct { I = 1234, L = 987654321, D = double.MaxValue }; buffer.Write<TestStruct>(0, structValue); Assert.Equal(structValue, buffer.Read<TestStruct>(0)); } [Fact] public void ReadWriteSpanArray_RoundTrip() { using var buffer = new HGlobalBuffer(200); int[] intArray = new int[] { 11, 22, 33, 44 }; TestArray(intArray); TestSpan<int>(intArray); TestStruct[] structArray = new TestStruct[] { new TestStruct { I = 11, L = 22, D = 33 }, new TestStruct { I = 44, L = 55, D = 66 }, new TestStruct { I = 77, L = 88, D = 99 }, new TestStruct { I = 100, L = 200, D = 300 }, }; TestArray(structArray); TestSpan<TestStruct>(structArray); void TestArray<T>(T[] data) where T : struct { T[] destination = new T[data.Length]; buffer.WriteArray(0, data, 0, data.Length); buffer.ReadArray(0, destination, 0, data.Length); Assert.Equal(data, destination); } void TestSpan<T>(ReadOnlySpan<T> data) where T : unmanaged { Span<T> destination = stackalloc T[data.Length]; buffer.WriteSpan(0, data); buffer.ReadSpan(0, destination); for (int i = 0; i < data.Length; i++) Assert.Equal(data[i], destination[i]); } } public class SubBuffer : SafeBuffer { public SubBuffer(bool ownsHandle) : base(ownsHandle) { } protected override bool ReleaseHandle() { throw new NotImplementedException(); } } public class HGlobalBuffer : SafeBuffer { public HGlobalBuffer(int length) : base(true) { SetHandle(Marshal.AllocHGlobal(length)); Initialize((ulong)length); } protected override bool ReleaseHandle() { Marshal.FreeHGlobal(handle); return true; } } public struct TestStruct { public int I; public long L; public double D; } } }
// 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.Runtime.InteropServices.Tests { public class SafeBufferTests { [Theory] [InlineData(true)] [InlineData(false)] public void Ctor_Bool(bool ownsHandle) { var buffer = new SubBuffer(ownsHandle); Assert.True(buffer.IsInvalid); } [Fact] public void Initialize_InvalidNumBytes_ThrowsArgumentOutOfRangeException() { var buffer = new SubBuffer(true); AssertExtensions.Throws<ArgumentOutOfRangeException>("numBytes", () => buffer.Initialize(ulong.MaxValue)); } [Fact] public void Initialize_NumBytesTimesSizeOfEachElement_ThrowsArgumentOutOfRangeExceptionIfNot64Bit() { var buffer = new SubBuffer(true); AssertExtensions.ThrowsIf<ArgumentOutOfRangeException>(!Environment.Is64BitProcess, () => buffer.Initialize(uint.MaxValue, uint.MaxValue)); AssertExtensions.ThrowsIf<ArgumentOutOfRangeException>(!Environment.Is64BitProcess, () => buffer.Initialize<int>(uint.MaxValue)); } [Fact] public unsafe void AcquirePointer_NotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); byte* pointer = null; Assert.Throws<InvalidOperationException>(() => wrapper.AcquirePointer(ref pointer)); } [Fact] public unsafe void AcquirePointer_Disposed_ThrowsObjectDisposedException() { var buffer = new SubBuffer(true); buffer.Initialize(4); buffer.Dispose(); byte* pointer = (byte*)12345; Assert.Throws<ObjectDisposedException>(() => buffer.AcquirePointer(ref pointer)); Assert.True(pointer is null); } [Fact] public void ReleasePointer_NotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); Assert.Throws<InvalidOperationException>(() => wrapper.ReleasePointer()); } [Fact] public void ReadWrite_NotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); Assert.Throws<InvalidOperationException>(() => wrapper.Read<int>(0)); Assert.Throws<InvalidOperationException>(() => wrapper.Write(0, 2)); } [Theory] [InlineData(4)] [InlineData(3)] [InlineData(ulong.MaxValue)] public void ReadWrite_NotEnoughSpaceInBuffer_ThrowsArgumentException(ulong byteOffset) { var buffer = new SubBuffer(true); buffer.Initialize(4); AssertExtensions.Throws<ArgumentException>(null, () => buffer.Read<int>(byteOffset)); AssertExtensions.Throws<ArgumentException>(null, () => buffer.Write<int>(byteOffset, 2)); } [Fact] public void ReadArray_NullArray_ThrowsArgumentNullException() { var wrapper = new SubBuffer(true); AssertExtensions.Throws<ArgumentNullException>("array", () => wrapper.ReadArray<int>(0, null, 0, 0)); AssertExtensions.Throws<ArgumentNullException>("array", () => wrapper.WriteArray<int>(0, null, 0, 0)); } [Fact] public void ReadWriteSpan_EmptySpan_Passes() { var buffer = new SubBuffer(true); buffer.Initialize(0); buffer.ReadSpan<int>(0, Span<int>.Empty); buffer.WriteSpan<int>(0, ReadOnlySpan<int>.Empty); } [Fact] public void ReadArray_NegativeIndex_ThrowsArgumentOutOfRangeException() { var wrapper = new SubBuffer(true); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => wrapper.ReadArray(0, new int[0], -1, 0)); AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => wrapper.WriteArray(0, new int[0], -1, 0)); } [Fact] public void ReadWriteArray_NegativeCount_ThrowsArgumentOutOfRangeException() { var wrapper = new SubBuffer(true); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => wrapper.ReadArray(0, new int[0], 0, -1)); AssertExtensions.Throws<ArgumentOutOfRangeException>("count", () => wrapper.WriteArray(0, new int[0], 0, -1)); } [Theory] [InlineData(0, 1, 0)] [InlineData(0, 0, 1)] [InlineData(2, 3, 0)] [InlineData(2, 2, 1)] [InlineData(2, 1, 2)] [InlineData(2, 0, 3)] public void ReadWriteArray_NegativeCount_ThrowsArgumentException(int arrayLength, int index, int count) { var wrapper = new SubBuffer(true); AssertExtensions.Throws<ArgumentException>(null, () => wrapper.ReadArray(0, new int[arrayLength], index, count)); AssertExtensions.Throws<ArgumentException>(null, () => wrapper.WriteArray(0, new int[arrayLength], index, count)); } [Fact] public void ReadWriteArray_NotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); Assert.Throws<InvalidOperationException>(() => wrapper.ReadArray(0, new int[0], 0, 0)); Assert.Throws<InvalidOperationException>(() => wrapper.WriteArray(0, new int[0], 0, 0)); } [Fact] public void ByteLength_GetNotInitialized_ThrowsInvalidOperationException() { var wrapper = new SubBuffer(true); Assert.Throws<InvalidOperationException>(() => wrapper.ByteLength); } [Fact] public void ReadWrite_RoundTrip() { using var buffer = new HGlobalBuffer(100); int intValue = 1234; buffer.Write<int>(0, intValue); Assert.Equal(intValue, buffer.Read<int>(0)); double doubleValue = 123.45; buffer.Write<double>(10, doubleValue); Assert.Equal(doubleValue, buffer.Read<double>(10)); TestStruct structValue = new TestStruct { I = 1234, L = 987654321, D = double.MaxValue }; buffer.Write<TestStruct>(0, structValue); Assert.Equal(structValue, buffer.Read<TestStruct>(0)); } [Fact] public void ReadWriteSpanArray_RoundTrip() { using var buffer = new HGlobalBuffer(200); int[] intArray = new int[] { 11, 22, 33, 44 }; TestArray(intArray); TestSpan<int>(intArray); TestStruct[] structArray = new TestStruct[] { new TestStruct { I = 11, L = 22, D = 33 }, new TestStruct { I = 44, L = 55, D = 66 }, new TestStruct { I = 77, L = 88, D = 99 }, new TestStruct { I = 100, L = 200, D = 300 }, }; TestArray(structArray); TestSpan<TestStruct>(structArray); void TestArray<T>(T[] data) where T : struct { T[] destination = new T[data.Length]; buffer.WriteArray(0, data, 0, data.Length); buffer.ReadArray(0, destination, 0, data.Length); Assert.Equal(data, destination); } void TestSpan<T>(ReadOnlySpan<T> data) where T : unmanaged { Span<T> destination = stackalloc T[data.Length]; buffer.WriteSpan(0, data); buffer.ReadSpan(0, destination); for (int i = 0; i < data.Length; i++) Assert.Equal(data[i], destination[i]); } } public class SubBuffer : SafeBuffer { public SubBuffer(bool ownsHandle) : base(ownsHandle) { } protected override bool ReleaseHandle() { throw new NotImplementedException(); } } public class HGlobalBuffer : SafeBuffer { public HGlobalBuffer(int length) : base(true) { SetHandle(Marshal.AllocHGlobal(length)); Initialize((ulong)length); } protected override bool ReleaseHandle() { Marshal.FreeHGlobal(handle); return true; } } public struct TestStruct { public int I; public long L; public double D; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.NamedBitList.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; using System.Diagnostics; using System.Runtime.InteropServices; using System.Security.Cryptography; namespace System.Formats.Asn1 { public static partial class AsnDecoder { /// <summary> /// Reads a NamedBitList from <paramref name="source"/> with a specified tag under /// the specified encoding rules, converting it to the /// [<see cref="FlagsAttribute"/>] enum specified by <typeparamref name="TFlagsEnum"/>. /// </summary> /// <param name="source">The buffer containing encoded data.</param> /// <param name="ruleSet">The encoding constraints to use when interpreting the data.</param> /// <param name="bytesConsumed"> /// When this method returns, the total number of bytes for the encoded value. /// This parameter is treated as uninitialized. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 3). /// </param> /// <typeparam name="TFlagsEnum">Destination enum type</typeparam> /// <returns> /// The NamedBitList value converted to a <typeparamref name="TFlagsEnum"/>. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="ruleSet"/> is not defined. /// </exception> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// /// -or- /// /// the encoded value is too big to fit in a <typeparamref name="TFlagsEnum"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <typeparamref name="TFlagsEnum"/> is not an enum type. /// /// -or- /// /// <typeparamref name="TFlagsEnum"/> was not declared with <see cref="FlagsAttribute"/> /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <remarks> /// The bit alignment performed by this method is to interpret the most significant bit /// in the first byte of the value as the least significant bit in <typeparamref name="TFlagsEnum"/>, /// with bits increasing in value until the least significant bit of the first byte, proceeding /// with the most significant bit of the second byte, and so on. Under this scheme, the following /// ASN.1 type declaration and C# enumeration can be used together: /// /// <code> /// KeyUsage ::= BIT STRING { /// digitalSignature (0), /// nonRepudiation (1), /// keyEncipherment (2), /// dataEncipherment (3), /// keyAgreement (4), /// keyCertSign (5), /// cRLSign (6), /// encipherOnly (7), /// decipherOnly (8) } /// </code> /// /// <code> /// [Flags] /// enum KeyUsage /// { /// None = 0, /// DigitalSignature = 1 &lt;&lt; (0), /// NonRepudiation = 1 &lt;&lt; (1), /// KeyEncipherment = 1 &lt;&lt; (2), /// DataEncipherment = 1 &lt;&lt; (3), /// KeyAgreement = 1 &lt;&lt; (4), /// KeyCertSign = 1 &lt;&lt; (5), /// CrlSign = 1 &lt;&lt; (6), /// EncipherOnly = 1 &lt;&lt; (7), /// DecipherOnly = 1 &lt;&lt; (8), /// } /// </code> /// /// Note that while the example here uses the KeyUsage NamedBitList from /// <a href="https://tools.ietf.org/html/rfc3280#section-4.2.1.3">RFC 3280 (4.2.1.3)</a>, /// the example enum uses values thar are different from /// System.Security.Cryptography.X509Certificates.X509KeyUsageFlags. /// </remarks> public static TFlagsEnum ReadNamedBitListValue<TFlagsEnum>( ReadOnlySpan<byte> source, AsnEncodingRules ruleSet, out int bytesConsumed, Asn1Tag? expectedTag = null) where TFlagsEnum : Enum { Type tFlagsEnum = typeof(TFlagsEnum); TFlagsEnum ret = (TFlagsEnum)Enum.ToObject( tFlagsEnum, ReadNamedBitListValue(source, ruleSet, tFlagsEnum, out int consumed, expectedTag)); // Now that there's nothing left to throw, assign bytesConsumed. bytesConsumed = consumed; return ret; } /// <summary> /// Reads a NamedBitList from <paramref name="source"/> with a specified tag under /// the specified encoding rules, converting it to the /// [<see cref="FlagsAttribute"/>] enum specified by <paramref name="flagsEnumType"/>. /// </summary> /// <param name="source">The buffer containing encoded data.</param> /// <param name="ruleSet">The encoding constraints to use when interpreting the data.</param> /// <param name="flagsEnumType">Type object representing the destination type.</param> /// <param name="bytesConsumed"> /// When this method returns, the total number of bytes for the encoded value. /// This parameter is treated as uninitialized. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 3). /// </param> /// <returns> /// The NamedBitList value converted to a <paramref name="flagsEnumType"/>. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="ruleSet"/> is not defined. /// </exception> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// /// -or- ///- /// the encoded value is too big to fit in a <paramref name="flagsEnumType"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="flagsEnumType"/> is not an enum type. /// /// -or- /// /// <paramref name="flagsEnumType"/> was not declared with <see cref="FlagsAttribute"/> /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="flagsEnumType"/> is <see langword="null" /> /// </exception> /// <seealso cref="ReadNamedBitListValue{TFlagsEnum}"/> public static Enum ReadNamedBitListValue( ReadOnlySpan<byte> source, AsnEncodingRules ruleSet, Type flagsEnumType, out int bytesConsumed, Asn1Tag? expectedTag = null) { if (flagsEnumType == null) throw new ArgumentNullException(nameof(flagsEnumType)); // This will throw an ArgumentException if TEnum isn't an enum type, // so we don't need to validate it. Type backingType = flagsEnumType.GetEnumUnderlyingType(); if (!flagsEnumType.IsDefined(typeof(FlagsAttribute), false)) { throw new ArgumentException( SR.Argument_NamedBitListRequiresFlagsEnum, nameof(flagsEnumType)); } Span<byte> stackSpan = stackalloc byte[sizeof(ulong)]; int sizeLimit = Marshal.SizeOf(backingType); stackSpan = stackSpan.Slice(0, sizeLimit); bool read = TryReadBitString( source, stackSpan, ruleSet, out int unusedBitCount, out int consumed, out int bytesWritten, expectedTag); if (!read) { throw new AsnContentException( SR.Format(SR.ContentException_NamedBitListValueTooBig, flagsEnumType.Name)); } Enum ret; if (bytesWritten == 0) { // The mode isn't relevant, zero is always zero. ret = (Enum)Enum.ToObject(flagsEnumType, 0); bytesConsumed = consumed; return ret; } ReadOnlySpan<byte> valueSpan = stackSpan.Slice(0, bytesWritten); // Now that the 0-bounds check is out of the way: // // T-REC-X.690-201508 sec 11.2.2 if (ruleSet == AsnEncodingRules.DER || ruleSet == AsnEncodingRules.CER) { byte lastByte = valueSpan[bytesWritten - 1]; // No unused bits tests 0x01, 1 is 0x02, 2 is 0x04, etc. // We already know that TryCopyBitStringBytes checked that the // declared unused bits were 0, this checks that the last "used" bit // isn't also zero. byte testBit = (byte)(1 << unusedBitCount); if ((lastByte & testBit) == 0) { throw new AsnContentException(SR.ContentException_InvalidUnderCerOrDer_TryBer); } } // Consider a NamedBitList defined as // // SomeList ::= BIT STRING { // a(0), b(1), c(2), d(3), e(4), f(5), g(6), h(7), i(8), j(9), k(10) // } // // The BIT STRING encoding of (a | j) is // unusedBitCount = 6, // contents: 0x80 0x40 (0b10000000_01000000) // // A the C# exposure of this structure we adhere to is // // [Flags] // enum SomeList // { // A = 1, // B = 1 << 1, // C = 1 << 2, // ... // } // // Which happens to be exactly backwards from how the bits are encoded, but the complexity // only needs to live here. ret = (Enum)Enum.ToObject(flagsEnumType, InterpretNamedBitListReversed(valueSpan)); bytesConsumed = consumed; return ret; } /// <summary> /// Reads a NamedBitList from <paramref name="source"/> with a specified tag under /// the specified encoding rules. /// </summary> /// <param name="source">The buffer containing encoded data.</param> /// <param name="ruleSet">The encoding constraints to use when interpreting the data.</param> /// <param name="bytesConsumed"> /// When this method returns, the total number of bytes for the encoded value. /// This parameter is treated as uninitialized. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 3). /// </param> /// <returns> /// The bits from the encoded value. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="ruleSet"/> is not defined. /// </exception> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <remarks> /// The bit alignment performed by this method is to interpret the most significant bit /// in the first byte of the value as bit 0, /// with bits increasing in value until the least significant bit of the first byte, proceeding /// with the most significant bit of the second byte, and so on. /// This means that the number used in an ASN.1 NamedBitList construction is the index in the /// return value. /// </remarks> public static BitArray ReadNamedBitList( ReadOnlySpan<byte> source, AsnEncodingRules ruleSet, out int bytesConsumed, Asn1Tag? expectedTag = null) { Asn1Tag actualTag = ReadEncodedValue(source, ruleSet, out _, out int contentLength, out _); // Get the last ArgumentException out of the way before we rent arrays if (expectedTag != null) { CheckExpectedTag(actualTag, expectedTag.Value, UniversalTagNumber.BitString); } // The number of interpreted bytes is at most contentLength - 1, just ask for contentLength. byte[] rented = CryptoPool.Rent(contentLength); if (!TryReadBitString( source, rented, ruleSet, out int unusedBitCount, out int consumed, out int written, expectedTag)) { Debug.Fail("TryReadBitString failed with an over-allocated buffer"); throw new InvalidOperationException(); } int validBitCount = checked(written * 8 - unusedBitCount); Span<byte> valueSpan = rented.AsSpan(0, written); ReverseBitsPerByte(valueSpan); BitArray ret = new BitArray(rented); CryptoPool.Return(rented, written); // Trim off all of the unnecessary parts. ret.Length = validBitCount; bytesConsumed = consumed; return ret; } private static long InterpretNamedBitListReversed(ReadOnlySpan<byte> valueSpan) { Debug.Assert(valueSpan.Length <= sizeof(long)); long accum = 0; long currentBitValue = 1; for (int byteIdx = 0; byteIdx < valueSpan.Length; byteIdx++) { byte byteVal = valueSpan[byteIdx]; for (int bitIndex = 7; bitIndex >= 0; bitIndex--) { int test = 1 << bitIndex; if ((byteVal & test) != 0) { accum |= currentBitValue; } currentBitValue <<= 1; } } return accum; } internal static void ReverseBitsPerByte(Span<byte> value) { for (int byteIdx = 0; byteIdx < value.Length; byteIdx++) { byte cur = value[byteIdx]; byte mask = 0b1000_0000; byte next = 0; for (; cur != 0; cur >>= 1, mask >>= 1) { next |= (byte)((cur & 1) * mask); } value[byteIdx] = next; } } } public partial class AsnReader { /// <summary> /// Reads the next value as a NamedBitList with a specified tag, converting it to the /// [<see cref="FlagsAttribute"/>] enum specified by <typeparamref name="TFlagsEnum"/>. /// </summary> /// <param name="expectedTag">The tag to check for before reading.</param> /// <typeparam name="TFlagsEnum">Destination enum type</typeparam> /// <returns> /// The NamedBitList value converted to a <typeparamref name="TFlagsEnum"/>. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// /// -or- /// /// the encoded value is too big to fit in a <typeparamref name="TFlagsEnum"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <typeparamref name="TFlagsEnum"/> is not an enum type. /// /// -or- /// /// <typeparamref name="TFlagsEnum"/> was not declared with <see cref="FlagsAttribute"/> /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <remarks> /// The bit alignment performed by this method is to interpret the most significant bit /// in the first byte of the value as the least significant bit in <typeparamref name="TFlagsEnum"/>, /// with bits increasing in value until the least significant bit of the first byte, proceeding /// with the most significant bit of the second byte, and so on. Under this scheme, the following /// ASN.1 type declaration and C# enumeration can be used together: /// /// <code> /// KeyUsage ::= BIT STRING { /// digitalSignature (0), /// nonRepudiation (1), /// keyEncipherment (2), /// dataEncipherment (3), /// keyAgreement (4), /// keyCertSign (5), /// cRLSign (6), /// encipherOnly (7), /// decipherOnly (8) } /// </code> /// /// <code> /// [Flags] /// enum KeyUsage /// { /// None = 0, /// DigitalSignature = 1 &lt;&lt; (0), /// NonRepudiation = 1 &lt;&lt; (1), /// KeyEncipherment = 1 &lt;&lt; (2), /// DataEncipherment = 1 &lt;&lt; (3), /// KeyAgreement = 1 &lt;&lt; (4), /// KeyCertSign = 1 &lt;&lt; (5), /// CrlSign = 1 &lt;&lt; (6), /// EncipherOnly = 1 &lt;&lt; (7), /// DecipherOnly = 1 &lt;&lt; (8), /// } /// </code> /// /// Note that while the example here uses the KeyUsage NamedBitList from /// <a href="https://tools.ietf.org/html/rfc3280#section-4.2.1.3">RFC 3280 (4.2.1.3)</a>, /// the example enum uses values thar are different from /// System.Security.Cryptography.X509Certificates.X509KeyUsageFlags. /// </remarks> public TFlagsEnum ReadNamedBitListValue<TFlagsEnum>(Asn1Tag? expectedTag = null) where TFlagsEnum : Enum { TFlagsEnum ret = AsnDecoder.ReadNamedBitListValue<TFlagsEnum>( _data.Span, RuleSet, out int consumed, expectedTag); _data = _data.Slice(consumed); return ret; } /// <summary> /// Reads the next value as a NamedBitList with a specified tag, converting it to the /// [<see cref="FlagsAttribute"/>] enum specified by <paramref name="flagsEnumType"/>. /// </summary> /// <param name="expectedTag">The tag to check for before reading.</param> /// <param name="flagsEnumType">Type object representing the destination type.</param> /// <returns> /// The NamedBitList value converted to a <paramref name="flagsEnumType"/>. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// /// -or- /// /// the encoded value is too big to fit in a <paramref name="flagsEnumType"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="flagsEnumType"/> is not an enum type. /// /// -or- /// /// <paramref name="flagsEnumType"/> was not declared with <see cref="FlagsAttribute"/> /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="flagsEnumType"/> is <see langword="null" /> /// </exception> /// <seealso cref="ReadNamedBitListValue{TFlagsEnum}"/> public Enum ReadNamedBitListValue(Type flagsEnumType, Asn1Tag? expectedTag = null) { Enum ret = AsnDecoder.ReadNamedBitListValue( _data.Span, RuleSet, flagsEnumType, out int consumed, expectedTag); _data = _data.Slice(consumed); return ret; } /// <summary> /// Reads the next value as a NamedBitList with a specified tag. /// </summary> /// <param name="expectedTag">The tag to check for before reading.</param> /// <returns> /// The bits from the encoded value. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="ReadNamedBitListValue{TFlagsEnum}"/> public BitArray ReadNamedBitList(Asn1Tag? expectedTag = null) { BitArray ret = AsnDecoder.ReadNamedBitList(_data.Span, RuleSet, out int consumed, expectedTag); _data = _data.Slice(consumed); return ret; } } }
// 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; using System.Diagnostics; using System.Runtime.InteropServices; using System.Security.Cryptography; namespace System.Formats.Asn1 { public static partial class AsnDecoder { /// <summary> /// Reads a NamedBitList from <paramref name="source"/> with a specified tag under /// the specified encoding rules, converting it to the /// [<see cref="FlagsAttribute"/>] enum specified by <typeparamref name="TFlagsEnum"/>. /// </summary> /// <param name="source">The buffer containing encoded data.</param> /// <param name="ruleSet">The encoding constraints to use when interpreting the data.</param> /// <param name="bytesConsumed"> /// When this method returns, the total number of bytes for the encoded value. /// This parameter is treated as uninitialized. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 3). /// </param> /// <typeparam name="TFlagsEnum">Destination enum type</typeparam> /// <returns> /// The NamedBitList value converted to a <typeparamref name="TFlagsEnum"/>. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="ruleSet"/> is not defined. /// </exception> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// /// -or- /// /// the encoded value is too big to fit in a <typeparamref name="TFlagsEnum"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <typeparamref name="TFlagsEnum"/> is not an enum type. /// /// -or- /// /// <typeparamref name="TFlagsEnum"/> was not declared with <see cref="FlagsAttribute"/> /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <remarks> /// The bit alignment performed by this method is to interpret the most significant bit /// in the first byte of the value as the least significant bit in <typeparamref name="TFlagsEnum"/>, /// with bits increasing in value until the least significant bit of the first byte, proceeding /// with the most significant bit of the second byte, and so on. Under this scheme, the following /// ASN.1 type declaration and C# enumeration can be used together: /// /// <code> /// KeyUsage ::= BIT STRING { /// digitalSignature (0), /// nonRepudiation (1), /// keyEncipherment (2), /// dataEncipherment (3), /// keyAgreement (4), /// keyCertSign (5), /// cRLSign (6), /// encipherOnly (7), /// decipherOnly (8) } /// </code> /// /// <code> /// [Flags] /// enum KeyUsage /// { /// None = 0, /// DigitalSignature = 1 &lt;&lt; (0), /// NonRepudiation = 1 &lt;&lt; (1), /// KeyEncipherment = 1 &lt;&lt; (2), /// DataEncipherment = 1 &lt;&lt; (3), /// KeyAgreement = 1 &lt;&lt; (4), /// KeyCertSign = 1 &lt;&lt; (5), /// CrlSign = 1 &lt;&lt; (6), /// EncipherOnly = 1 &lt;&lt; (7), /// DecipherOnly = 1 &lt;&lt; (8), /// } /// </code> /// /// Note that while the example here uses the KeyUsage NamedBitList from /// <a href="https://tools.ietf.org/html/rfc3280#section-4.2.1.3">RFC 3280 (4.2.1.3)</a>, /// the example enum uses values thar are different from /// System.Security.Cryptography.X509Certificates.X509KeyUsageFlags. /// </remarks> public static TFlagsEnum ReadNamedBitListValue<TFlagsEnum>( ReadOnlySpan<byte> source, AsnEncodingRules ruleSet, out int bytesConsumed, Asn1Tag? expectedTag = null) where TFlagsEnum : Enum { Type tFlagsEnum = typeof(TFlagsEnum); TFlagsEnum ret = (TFlagsEnum)Enum.ToObject( tFlagsEnum, ReadNamedBitListValue(source, ruleSet, tFlagsEnum, out int consumed, expectedTag)); // Now that there's nothing left to throw, assign bytesConsumed. bytesConsumed = consumed; return ret; } /// <summary> /// Reads a NamedBitList from <paramref name="source"/> with a specified tag under /// the specified encoding rules, converting it to the /// [<see cref="FlagsAttribute"/>] enum specified by <paramref name="flagsEnumType"/>. /// </summary> /// <param name="source">The buffer containing encoded data.</param> /// <param name="ruleSet">The encoding constraints to use when interpreting the data.</param> /// <param name="flagsEnumType">Type object representing the destination type.</param> /// <param name="bytesConsumed"> /// When this method returns, the total number of bytes for the encoded value. /// This parameter is treated as uninitialized. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 3). /// </param> /// <returns> /// The NamedBitList value converted to a <paramref name="flagsEnumType"/>. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="ruleSet"/> is not defined. /// </exception> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// /// -or- ///- /// the encoded value is too big to fit in a <paramref name="flagsEnumType"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="flagsEnumType"/> is not an enum type. /// /// -or- /// /// <paramref name="flagsEnumType"/> was not declared with <see cref="FlagsAttribute"/> /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="flagsEnumType"/> is <see langword="null" /> /// </exception> /// <seealso cref="ReadNamedBitListValue{TFlagsEnum}"/> public static Enum ReadNamedBitListValue( ReadOnlySpan<byte> source, AsnEncodingRules ruleSet, Type flagsEnumType, out int bytesConsumed, Asn1Tag? expectedTag = null) { if (flagsEnumType == null) throw new ArgumentNullException(nameof(flagsEnumType)); // This will throw an ArgumentException if TEnum isn't an enum type, // so we don't need to validate it. Type backingType = flagsEnumType.GetEnumUnderlyingType(); if (!flagsEnumType.IsDefined(typeof(FlagsAttribute), false)) { throw new ArgumentException( SR.Argument_NamedBitListRequiresFlagsEnum, nameof(flagsEnumType)); } Span<byte> stackSpan = stackalloc byte[sizeof(ulong)]; int sizeLimit = Marshal.SizeOf(backingType); stackSpan = stackSpan.Slice(0, sizeLimit); bool read = TryReadBitString( source, stackSpan, ruleSet, out int unusedBitCount, out int consumed, out int bytesWritten, expectedTag); if (!read) { throw new AsnContentException( SR.Format(SR.ContentException_NamedBitListValueTooBig, flagsEnumType.Name)); } Enum ret; if (bytesWritten == 0) { // The mode isn't relevant, zero is always zero. ret = (Enum)Enum.ToObject(flagsEnumType, 0); bytesConsumed = consumed; return ret; } ReadOnlySpan<byte> valueSpan = stackSpan.Slice(0, bytesWritten); // Now that the 0-bounds check is out of the way: // // T-REC-X.690-201508 sec 11.2.2 if (ruleSet == AsnEncodingRules.DER || ruleSet == AsnEncodingRules.CER) { byte lastByte = valueSpan[bytesWritten - 1]; // No unused bits tests 0x01, 1 is 0x02, 2 is 0x04, etc. // We already know that TryCopyBitStringBytes checked that the // declared unused bits were 0, this checks that the last "used" bit // isn't also zero. byte testBit = (byte)(1 << unusedBitCount); if ((lastByte & testBit) == 0) { throw new AsnContentException(SR.ContentException_InvalidUnderCerOrDer_TryBer); } } // Consider a NamedBitList defined as // // SomeList ::= BIT STRING { // a(0), b(1), c(2), d(3), e(4), f(5), g(6), h(7), i(8), j(9), k(10) // } // // The BIT STRING encoding of (a | j) is // unusedBitCount = 6, // contents: 0x80 0x40 (0b10000000_01000000) // // A the C# exposure of this structure we adhere to is // // [Flags] // enum SomeList // { // A = 1, // B = 1 << 1, // C = 1 << 2, // ... // } // // Which happens to be exactly backwards from how the bits are encoded, but the complexity // only needs to live here. ret = (Enum)Enum.ToObject(flagsEnumType, InterpretNamedBitListReversed(valueSpan)); bytesConsumed = consumed; return ret; } /// <summary> /// Reads a NamedBitList from <paramref name="source"/> with a specified tag under /// the specified encoding rules. /// </summary> /// <param name="source">The buffer containing encoded data.</param> /// <param name="ruleSet">The encoding constraints to use when interpreting the data.</param> /// <param name="bytesConsumed"> /// When this method returns, the total number of bytes for the encoded value. /// This parameter is treated as uninitialized. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 3). /// </param> /// <returns> /// The bits from the encoded value. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="ruleSet"/> is not defined. /// </exception> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <remarks> /// The bit alignment performed by this method is to interpret the most significant bit /// in the first byte of the value as bit 0, /// with bits increasing in value until the least significant bit of the first byte, proceeding /// with the most significant bit of the second byte, and so on. /// This means that the number used in an ASN.1 NamedBitList construction is the index in the /// return value. /// </remarks> public static BitArray ReadNamedBitList( ReadOnlySpan<byte> source, AsnEncodingRules ruleSet, out int bytesConsumed, Asn1Tag? expectedTag = null) { Asn1Tag actualTag = ReadEncodedValue(source, ruleSet, out _, out int contentLength, out _); // Get the last ArgumentException out of the way before we rent arrays if (expectedTag != null) { CheckExpectedTag(actualTag, expectedTag.Value, UniversalTagNumber.BitString); } // The number of interpreted bytes is at most contentLength - 1, just ask for contentLength. byte[] rented = CryptoPool.Rent(contentLength); if (!TryReadBitString( source, rented, ruleSet, out int unusedBitCount, out int consumed, out int written, expectedTag)) { Debug.Fail("TryReadBitString failed with an over-allocated buffer"); throw new InvalidOperationException(); } int validBitCount = checked(written * 8 - unusedBitCount); Span<byte> valueSpan = rented.AsSpan(0, written); ReverseBitsPerByte(valueSpan); BitArray ret = new BitArray(rented); CryptoPool.Return(rented, written); // Trim off all of the unnecessary parts. ret.Length = validBitCount; bytesConsumed = consumed; return ret; } private static long InterpretNamedBitListReversed(ReadOnlySpan<byte> valueSpan) { Debug.Assert(valueSpan.Length <= sizeof(long)); long accum = 0; long currentBitValue = 1; for (int byteIdx = 0; byteIdx < valueSpan.Length; byteIdx++) { byte byteVal = valueSpan[byteIdx]; for (int bitIndex = 7; bitIndex >= 0; bitIndex--) { int test = 1 << bitIndex; if ((byteVal & test) != 0) { accum |= currentBitValue; } currentBitValue <<= 1; } } return accum; } internal static void ReverseBitsPerByte(Span<byte> value) { for (int byteIdx = 0; byteIdx < value.Length; byteIdx++) { byte cur = value[byteIdx]; byte mask = 0b1000_0000; byte next = 0; for (; cur != 0; cur >>= 1, mask >>= 1) { next |= (byte)((cur & 1) * mask); } value[byteIdx] = next; } } } public partial class AsnReader { /// <summary> /// Reads the next value as a NamedBitList with a specified tag, converting it to the /// [<see cref="FlagsAttribute"/>] enum specified by <typeparamref name="TFlagsEnum"/>. /// </summary> /// <param name="expectedTag">The tag to check for before reading.</param> /// <typeparam name="TFlagsEnum">Destination enum type</typeparam> /// <returns> /// The NamedBitList value converted to a <typeparamref name="TFlagsEnum"/>. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// /// -or- /// /// the encoded value is too big to fit in a <typeparamref name="TFlagsEnum"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <typeparamref name="TFlagsEnum"/> is not an enum type. /// /// -or- /// /// <typeparamref name="TFlagsEnum"/> was not declared with <see cref="FlagsAttribute"/> /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <remarks> /// The bit alignment performed by this method is to interpret the most significant bit /// in the first byte of the value as the least significant bit in <typeparamref name="TFlagsEnum"/>, /// with bits increasing in value until the least significant bit of the first byte, proceeding /// with the most significant bit of the second byte, and so on. Under this scheme, the following /// ASN.1 type declaration and C# enumeration can be used together: /// /// <code> /// KeyUsage ::= BIT STRING { /// digitalSignature (0), /// nonRepudiation (1), /// keyEncipherment (2), /// dataEncipherment (3), /// keyAgreement (4), /// keyCertSign (5), /// cRLSign (6), /// encipherOnly (7), /// decipherOnly (8) } /// </code> /// /// <code> /// [Flags] /// enum KeyUsage /// { /// None = 0, /// DigitalSignature = 1 &lt;&lt; (0), /// NonRepudiation = 1 &lt;&lt; (1), /// KeyEncipherment = 1 &lt;&lt; (2), /// DataEncipherment = 1 &lt;&lt; (3), /// KeyAgreement = 1 &lt;&lt; (4), /// KeyCertSign = 1 &lt;&lt; (5), /// CrlSign = 1 &lt;&lt; (6), /// EncipherOnly = 1 &lt;&lt; (7), /// DecipherOnly = 1 &lt;&lt; (8), /// } /// </code> /// /// Note that while the example here uses the KeyUsage NamedBitList from /// <a href="https://tools.ietf.org/html/rfc3280#section-4.2.1.3">RFC 3280 (4.2.1.3)</a>, /// the example enum uses values thar are different from /// System.Security.Cryptography.X509Certificates.X509KeyUsageFlags. /// </remarks> public TFlagsEnum ReadNamedBitListValue<TFlagsEnum>(Asn1Tag? expectedTag = null) where TFlagsEnum : Enum { TFlagsEnum ret = AsnDecoder.ReadNamedBitListValue<TFlagsEnum>( _data.Span, RuleSet, out int consumed, expectedTag); _data = _data.Slice(consumed); return ret; } /// <summary> /// Reads the next value as a NamedBitList with a specified tag, converting it to the /// [<see cref="FlagsAttribute"/>] enum specified by <paramref name="flagsEnumType"/>. /// </summary> /// <param name="expectedTag">The tag to check for before reading.</param> /// <param name="flagsEnumType">Type object representing the destination type.</param> /// <returns> /// The NamedBitList value converted to a <paramref name="flagsEnumType"/>. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// /// -or- /// /// the encoded value is too big to fit in a <paramref name="flagsEnumType"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="flagsEnumType"/> is not an enum type. /// /// -or- /// /// <paramref name="flagsEnumType"/> was not declared with <see cref="FlagsAttribute"/> /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="flagsEnumType"/> is <see langword="null" /> /// </exception> /// <seealso cref="ReadNamedBitListValue{TFlagsEnum}"/> public Enum ReadNamedBitListValue(Type flagsEnumType, Asn1Tag? expectedTag = null) { Enum ret = AsnDecoder.ReadNamedBitListValue( _data.Span, RuleSet, flagsEnumType, out int consumed, expectedTag); _data = _data.Slice(consumed); return ret; } /// <summary> /// Reads the next value as a NamedBitList with a specified tag. /// </summary> /// <param name="expectedTag">The tag to check for before reading.</param> /// <returns> /// The bits from the encoded value. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="ReadNamedBitListValue{TFlagsEnum}"/> public BitArray ReadNamedBitList(Asn1Tag? expectedTag = null) { BitArray ret = AsnDecoder.ReadNamedBitList(_data.Span, RuleSet, out int consumed, expectedTag); _data = _data.Slice(consumed); return ret; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/SubtractHighNarrowingLower.Vector64.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.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 SubtractHighNarrowingLower_Vector64_UInt32() { var test = new SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32(); 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__SubtractHighNarrowingLower_Vector64_UInt32 { 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(UInt64[] inArray1, UInt64[] inArray2, UInt32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt32>(); 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<UInt64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt64, 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<UInt64> _fld1; public Vector128<UInt64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32 testClass) { var result = AdvSimd.SubtractHighNarrowingLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32 testClass) { fixed (Vector128<UInt64>* pFld1 = &_fld1) fixed (Vector128<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(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<UInt64>>() / sizeof(UInt64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt32>>() / sizeof(UInt32); private static UInt64[] _data1 = new UInt64[Op1ElementCount]; private static UInt64[] _data2 = new UInt64[Op2ElementCount]; private static Vector128<UInt64> _clsVar1; private static Vector128<UInt64> _clsVar2; private Vector128<UInt64> _fld1; private Vector128<UInt64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); } public SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } _dataTable = new DataTable(_data1, _data2, new UInt32[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.SubtractHighNarrowingLower( Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt64>>(_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.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((UInt64*)(_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).GetMethod(nameof(AdvSimd.SubtractHighNarrowingLower), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractHighNarrowingLower), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SubtractHighNarrowingLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<UInt64>* pClsVar1 = &_clsVar1) fixed (Vector128<UInt64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(pClsVar1)), AdvSimd.LoadVector128((UInt64*)(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<UInt64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr); var result = AdvSimd.SubtractHighNarrowingLower(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((UInt64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.SubtractHighNarrowingLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32(); var result = AdvSimd.SubtractHighNarrowingLower(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__SubtractHighNarrowingLower_Vector64_UInt32(); fixed (Vector128<UInt64>* pFld1 = &test._fld1) fixed (Vector128<UInt64>* pFld2 = &test._fld2) { var result = AdvSimd.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SubtractHighNarrowingLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<UInt64>* pFld1 = &_fld1) fixed (Vector128<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(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.SubtractHighNarrowingLower(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.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(&test._fld1)), AdvSimd.LoadVector128((UInt64*)(&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<UInt64> op1, Vector128<UInt64> op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt64[] left, UInt64[] right, UInt32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SubtractHighNarrowing(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SubtractHighNarrowingLower)}<UInt32>(Vector128<UInt64>, Vector128<UInt64>): {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 SubtractHighNarrowingLower_Vector64_UInt32() { var test = new SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32(); 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__SubtractHighNarrowingLower_Vector64_UInt32 { 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(UInt64[] inArray1, UInt64[] inArray2, UInt32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<UInt64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt32>(); 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<UInt64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<UInt64, 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<UInt64> _fld1; public Vector128<UInt64> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref testStruct._fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32 testClass) { var result = AdvSimd.SubtractHighNarrowingLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32 testClass) { fixed (Vector128<UInt64>* pFld1 = &_fld1) fixed (Vector128<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(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<UInt64>>() / sizeof(UInt64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<UInt64>>() / sizeof(UInt64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<UInt32>>() / sizeof(UInt32); private static UInt64[] _data1 = new UInt64[Op1ElementCount]; private static UInt64[] _data2 = new UInt64[Op2ElementCount]; private static Vector128<UInt64> _clsVar1; private static Vector128<UInt64> _clsVar2; private Vector128<UInt64> _fld1; private Vector128<UInt64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); } public SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } _dataTable = new DataTable(_data1, _data2, new UInt32[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.SubtractHighNarrowingLower( Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt64>>(_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.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((UInt64*)(_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).GetMethod(nameof(AdvSimd.SubtractHighNarrowingLower), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractHighNarrowingLower), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<UInt32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SubtractHighNarrowingLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<UInt64>* pClsVar1 = &_clsVar1) fixed (Vector128<UInt64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(pClsVar1)), AdvSimd.LoadVector128((UInt64*)(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<UInt64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr); var result = AdvSimd.SubtractHighNarrowingLower(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((UInt64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((UInt64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.SubtractHighNarrowingLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__SubtractHighNarrowingLower_Vector64_UInt32(); var result = AdvSimd.SubtractHighNarrowingLower(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__SubtractHighNarrowingLower_Vector64_UInt32(); fixed (Vector128<UInt64>* pFld1 = &test._fld1) fixed (Vector128<UInt64>* pFld2 = &test._fld2) { var result = AdvSimd.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SubtractHighNarrowingLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<UInt64>* pFld1 = &_fld1) fixed (Vector128<UInt64>* pFld2 = &_fld2) { var result = AdvSimd.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(pFld1)), AdvSimd.LoadVector128((UInt64*)(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.SubtractHighNarrowingLower(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.SubtractHighNarrowingLower( AdvSimd.LoadVector128((UInt64*)(&test._fld1)), AdvSimd.LoadVector128((UInt64*)(&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<UInt64> op1, Vector128<UInt64> op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt64[] inArray1 = new UInt64[Op1ElementCount]; UInt64[] inArray2 = new UInt64[Op2ElementCount]; UInt32[] outArray = new UInt32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<UInt64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<UInt32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt64[] left, UInt64[] right, UInt32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SubtractHighNarrowing(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SubtractHighNarrowingLower)}<UInt32>(Vector128<UInt64>, Vector128<UInt64>): {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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/BuildWasmApps/testassets/AppUsingSkiaSharp/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 SkiaSharp; public class Test { public static int Main() { using SKFileStream skfs = new SKFileStream("mono.png"); using SKImage img = SKImage.FromEncodedData(skfs); Console.WriteLine ($"Size: {skfs.Length} Height: {img.Height}, Width: {img.Width}"); return 0; } }
// 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 SkiaSharp; public class Test { public static int Main() { using SKFileStream skfs = new SKFileStream("mono.png"); using SKImage img = SKImage.FromEncodedData(skfs); Console.WriteLine ($"Size: {skfs.Length} Height: {img.Height}, Width: {img.Width}"); return 0; } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Memory/tests/ParsersAndFormatters/StandardFormatTests.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 Xunit; namespace System.Buffers.Text.Tests { public static partial class StandardFormatTests { [Fact] public static void StandardFormatCtorNegative() { Assert.Throws<ArgumentOutOfRangeException>(() => new StandardFormat((char)256)); Assert.Throws<ArgumentOutOfRangeException>(() => new StandardFormat('D', StandardFormat.MaxPrecision + 1)); } [Theory] [InlineData("G4", 'G', 4)] [InlineData("n0", 'n', 0)] [InlineData("d", 'd', StandardFormat.NoPrecision)] [InlineData("x99", 'x', StandardFormat.MaxPrecision)] [InlineData(null, default(char), default(byte))] [InlineData("", default(char), default(byte))] public static void StandardFormatParseString(string formatString, char expectedSymbol, byte expectedPrecision) { StandardFormat format = StandardFormat.Parse(formatString); Assert.Equal(expectedSymbol, format.Symbol); Assert.Equal(expectedPrecision, format.Precision); } [Theory] [InlineData("G4", 'G', 4)] [InlineData("n0", 'n', 0)] [InlineData("d", 'd', StandardFormat.NoPrecision)] [InlineData("x99", 'x', StandardFormat.MaxPrecision)] [InlineData("", default(char), default(byte))] public static void StandardFormatParseSpan(string formatString, char expectedSymbol, byte expectedPrecision) { ReadOnlySpan<char> span = formatString.AsSpan(); StandardFormat format = StandardFormat.Parse(span); Assert.Equal(expectedSymbol, format.Symbol); Assert.Equal(expectedPrecision, format.Precision); } [Theory] [InlineData("G$")] [InlineData("Ga")] [InlineData("G100")] public static void StandardFormatParseNegative(string badFormatString) { Assert.Throws<FormatException>(() => StandardFormat.Parse(badFormatString)); } [Theory] [InlineData("G4", 'G', 4, true)] [InlineData("n0", 'n', 0, true)] [InlineData("d", 'd', StandardFormat.NoPrecision, true)] [InlineData("x99", 'x', StandardFormat.MaxPrecision, true)] [InlineData(null, default(char), default(byte), true)] [InlineData("", default(char), default(byte), true)] [InlineData("G$", default(char), default(byte), false)] [InlineData("Ga", default(char), default(byte), false)] [InlineData("G100", default(char), default(byte), false)] public static void StandardFormatTryParse(string formatString, char expectedSymbol, byte expectedPrecision, bool expectedResult) { bool result = StandardFormat.TryParse(formatString, out StandardFormat format); Assert.Equal(expectedSymbol, format.Symbol); Assert.Equal(expectedPrecision, format.Precision); Assert.Equal(expectedResult, result); } [Theory] [InlineData('a')] [InlineData('B')] public static void StandardFormatOpImplicitFromChar(char c) { StandardFormat format = c; Assert.Equal(c, format.Symbol); Assert.Equal(StandardFormat.NoPrecision, format.Precision); } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatEquality(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { { bool actual = f1.Equals(f2); Assert.Equal(expectedToBeEqual, actual); } } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatBoxedEquality(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { object boxedf2 = f2; bool actual = f1.Equals(boxedf2); Assert.Equal(expectedToBeEqual, actual); } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatOpEquality(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { { bool actual = f1 == f2; Assert.Equal(expectedToBeEqual, actual); } } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatOpInequality(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { { bool actual = f1 != f2; Assert.NotEqual(expectedToBeEqual, actual); } } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatGetHashCode(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { if (expectedToBeEqual) { int h1 = f1.GetHashCode(); int h2 = f2.GetHashCode(); Assert.Equal(h1, h2); } } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatGetHashCodeIsContentBased(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { _ = f2; _ = expectedToBeEqual; object boxedf1 = f1; object aDifferentBoxedF1 = f1; int h1 = boxedf1.GetHashCode(); int h2 = aDifferentBoxedF1.GetHashCode(); Assert.Equal(h1, h2); } public static IEnumerable<object[]> EqualityTestData { get { yield return new object[] { new StandardFormat('A', 3), new StandardFormat('A', 3), true }; yield return new object[] { new StandardFormat('a', 3), new StandardFormat('A', 3), false }; yield return new object[] { new StandardFormat('A', 3), new StandardFormat('A', 4), false }; yield return new object[] { new StandardFormat('A', 3), new StandardFormat('A', StandardFormat.NoPrecision), false }; } } [Theory] [InlineData("G4", 'G', 4)] [InlineData("n0", 'n', 0)] [InlineData("d", 'd', StandardFormat.NoPrecision)] [InlineData("x99", 'x', StandardFormat.MaxPrecision)] [InlineData("", default(char), default(byte))] public static void StandardFormatToString(string expected, char symbol, byte precision) { StandardFormat format = new StandardFormat(symbol, precision); string actual = format.ToString(); Assert.Equal(expected, actual); } [Fact] public static void StandardFormatToStringOversizedPrecision() { // Code coverage: Precision of 100 is not legal but ToString() isn't allowed to throw an exception for that. // Make sure it doesn't. const byte BadPrecision = 100; StandardFormat format = default; unsafe { // We're aiming for the Precision field but we don't know where it is so nuke 'em all. new Span<byte>(&format, sizeof(StandardFormat)).Fill(BadPrecision); } string s = format.ToString(); Assert.NotNull(s); } } }
// 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 Xunit; namespace System.Buffers.Text.Tests { public static partial class StandardFormatTests { [Fact] public static void StandardFormatCtorNegative() { Assert.Throws<ArgumentOutOfRangeException>(() => new StandardFormat((char)256)); Assert.Throws<ArgumentOutOfRangeException>(() => new StandardFormat('D', StandardFormat.MaxPrecision + 1)); } [Theory] [InlineData("G4", 'G', 4)] [InlineData("n0", 'n', 0)] [InlineData("d", 'd', StandardFormat.NoPrecision)] [InlineData("x99", 'x', StandardFormat.MaxPrecision)] [InlineData(null, default(char), default(byte))] [InlineData("", default(char), default(byte))] public static void StandardFormatParseString(string formatString, char expectedSymbol, byte expectedPrecision) { StandardFormat format = StandardFormat.Parse(formatString); Assert.Equal(expectedSymbol, format.Symbol); Assert.Equal(expectedPrecision, format.Precision); } [Theory] [InlineData("G4", 'G', 4)] [InlineData("n0", 'n', 0)] [InlineData("d", 'd', StandardFormat.NoPrecision)] [InlineData("x99", 'x', StandardFormat.MaxPrecision)] [InlineData("", default(char), default(byte))] public static void StandardFormatParseSpan(string formatString, char expectedSymbol, byte expectedPrecision) { ReadOnlySpan<char> span = formatString.AsSpan(); StandardFormat format = StandardFormat.Parse(span); Assert.Equal(expectedSymbol, format.Symbol); Assert.Equal(expectedPrecision, format.Precision); } [Theory] [InlineData("G$")] [InlineData("Ga")] [InlineData("G100")] public static void StandardFormatParseNegative(string badFormatString) { Assert.Throws<FormatException>(() => StandardFormat.Parse(badFormatString)); } [Theory] [InlineData("G4", 'G', 4, true)] [InlineData("n0", 'n', 0, true)] [InlineData("d", 'd', StandardFormat.NoPrecision, true)] [InlineData("x99", 'x', StandardFormat.MaxPrecision, true)] [InlineData(null, default(char), default(byte), true)] [InlineData("", default(char), default(byte), true)] [InlineData("G$", default(char), default(byte), false)] [InlineData("Ga", default(char), default(byte), false)] [InlineData("G100", default(char), default(byte), false)] public static void StandardFormatTryParse(string formatString, char expectedSymbol, byte expectedPrecision, bool expectedResult) { bool result = StandardFormat.TryParse(formatString, out StandardFormat format); Assert.Equal(expectedSymbol, format.Symbol); Assert.Equal(expectedPrecision, format.Precision); Assert.Equal(expectedResult, result); } [Theory] [InlineData('a')] [InlineData('B')] public static void StandardFormatOpImplicitFromChar(char c) { StandardFormat format = c; Assert.Equal(c, format.Symbol); Assert.Equal(StandardFormat.NoPrecision, format.Precision); } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatEquality(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { { bool actual = f1.Equals(f2); Assert.Equal(expectedToBeEqual, actual); } } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatBoxedEquality(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { object boxedf2 = f2; bool actual = f1.Equals(boxedf2); Assert.Equal(expectedToBeEqual, actual); } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatOpEquality(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { { bool actual = f1 == f2; Assert.Equal(expectedToBeEqual, actual); } } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatOpInequality(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { { bool actual = f1 != f2; Assert.NotEqual(expectedToBeEqual, actual); } } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatGetHashCode(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { if (expectedToBeEqual) { int h1 = f1.GetHashCode(); int h2 = f2.GetHashCode(); Assert.Equal(h1, h2); } } [Theory] [MemberData(nameof(EqualityTestData))] public static void StandardFormatGetHashCodeIsContentBased(StandardFormat f1, StandardFormat f2, bool expectedToBeEqual) { _ = f2; _ = expectedToBeEqual; object boxedf1 = f1; object aDifferentBoxedF1 = f1; int h1 = boxedf1.GetHashCode(); int h2 = aDifferentBoxedF1.GetHashCode(); Assert.Equal(h1, h2); } public static IEnumerable<object[]> EqualityTestData { get { yield return new object[] { new StandardFormat('A', 3), new StandardFormat('A', 3), true }; yield return new object[] { new StandardFormat('a', 3), new StandardFormat('A', 3), false }; yield return new object[] { new StandardFormat('A', 3), new StandardFormat('A', 4), false }; yield return new object[] { new StandardFormat('A', 3), new StandardFormat('A', StandardFormat.NoPrecision), false }; } } [Theory] [InlineData("G4", 'G', 4)] [InlineData("n0", 'n', 0)] [InlineData("d", 'd', StandardFormat.NoPrecision)] [InlineData("x99", 'x', StandardFormat.MaxPrecision)] [InlineData("", default(char), default(byte))] public static void StandardFormatToString(string expected, char symbol, byte precision) { StandardFormat format = new StandardFormat(symbol, precision); string actual = format.ToString(); Assert.Equal(expected, actual); } [Fact] public static void StandardFormatToStringOversizedPrecision() { // Code coverage: Precision of 100 is not legal but ToString() isn't allowed to throw an exception for that. // Make sure it doesn't. const byte BadPrecision = 100; StandardFormat format = default; unsafe { // We're aiming for the Precision field but we don't know where it is so nuke 'em all. new Span<byte>(&format, sizeof(StandardFormat)).Fill(BadPrecision); } string s = format.ToString(); Assert.NotNull(s); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/coreclr/tools/Common/TypeSystem/Sorting/TypeDesc.Sorting.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Internal.TypeSystem { // Functionality related to determinstic ordering of types and members partial class TypeDesc { /// <summary> /// Gets an identifier that is the same for all instances of this <see cref="TypeDesc"/> /// descendant, but different from the <see cref="ClassCode"/> of any other descendant. /// </summary> /// <remarks> /// This is really just a number, ideally produced by "new Random().Next(int.MinValue, int.MaxValue)". /// If two manage to conflict (which is pretty unlikely), just make a new one... /// </remarks> protected internal abstract int ClassCode { get; } // Note to implementers: the type of `other` is actually the same as the type of `this`. protected internal abstract int CompareToImpl(TypeDesc other, TypeSystemComparer comparer); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Internal.TypeSystem { // Functionality related to determinstic ordering of types and members partial class TypeDesc { /// <summary> /// Gets an identifier that is the same for all instances of this <see cref="TypeDesc"/> /// descendant, but different from the <see cref="ClassCode"/> of any other descendant. /// </summary> /// <remarks> /// This is really just a number, ideally produced by "new Random().Next(int.MinValue, int.MaxValue)". /// If two manage to conflict (which is pretty unlikely), just make a new one... /// </remarks> protected internal abstract int ClassCode { get; } // Note to implementers: the type of `other` is actually the same as the type of `this`. protected internal abstract int CompareToImpl(TypeDesc other, TypeSystemComparer comparer); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/Arm/Crc32/ComputeCrc32.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\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 ComputeCrc32_UInt32() { var test = new ScalarBinaryOpTest__ComputeCrc32_UInt32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.ReadUnaligned test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.ReadUnaligned test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.ReadUnaligned 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(); } 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 ScalarBinaryOpTest__ComputeCrc32_UInt32 { private struct TestStruct { public UInt32 _fld1; public UInt32 _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); testStruct._fld1 = 0xFFFFFFFF; testStruct._fld2 = 0x20191113; return testStruct; } public void RunStructFldScenario(ScalarBinaryOpTest__ComputeCrc32_UInt32 testClass) { var result = Crc32.ComputeCrc32(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static UInt32 _data1; private static UInt32 _data2; private static UInt32 _clsVar1; private static UInt32 _clsVar2; private UInt32 _fld1; private UInt32 _fld2; static ScalarBinaryOpTest__ComputeCrc32_UInt32() { _clsVar1 = 0xFFFFFFFF; _clsVar2 = 0x20191113; } public ScalarBinaryOpTest__ComputeCrc32_UInt32() { Succeeded = true; _fld1 = 0xFFFFFFFF; _fld2 = 0x20191113; _data1 = 0xFFFFFFFF; _data2 = 0x20191113; } public bool IsSupported => Crc32.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Crc32.ComputeCrc32( Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data1)), Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data2)) ); ValidateResult(_data1, _data2, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Crc32).GetMethod(nameof(Crc32.ComputeCrc32), new Type[] { typeof(UInt32), typeof(UInt32) }) .Invoke(null, new object[] { Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data1)), Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data2)) }); ValidateResult(_data1, _data2, (UInt32)result); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Crc32.ComputeCrc32( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var data1 = Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data1)); var data2 = Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data2)); var result = Crc32.ComputeCrc32(data1, data2); ValidateResult(data1, data2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new ScalarBinaryOpTest__ComputeCrc32_UInt32(); var result = Crc32.ComputeCrc32(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Crc32.ComputeCrc32(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Crc32.ComputeCrc32(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); } 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(UInt32 left, UInt32 right, UInt32 result, [CallerMemberName] string method = "") { var isUnexpectedResult = false; uint expectedResult = 0x219D9805; isUnexpectedResult = (expectedResult != result); if (isUnexpectedResult) { TestLibrary.TestFramework.LogInformation($"{nameof(Crc32)}.{nameof(Crc32.ComputeCrc32)}<UInt32>(UInt32, UInt32): ComputeCrc32 failed:"); TestLibrary.TestFramework.LogInformation($" left: {left}"); TestLibrary.TestFramework.LogInformation($" right: {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\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 ComputeCrc32_UInt32() { var test = new ScalarBinaryOpTest__ComputeCrc32_UInt32(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.ReadUnaligned test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works, using Unsafe.ReadUnaligned test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.ReadUnaligned 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(); } 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 ScalarBinaryOpTest__ComputeCrc32_UInt32 { private struct TestStruct { public UInt32 _fld1; public UInt32 _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); testStruct._fld1 = 0xFFFFFFFF; testStruct._fld2 = 0x20191113; return testStruct; } public void RunStructFldScenario(ScalarBinaryOpTest__ComputeCrc32_UInt32 testClass) { var result = Crc32.ComputeCrc32(_fld1, _fld2); testClass.ValidateResult(_fld1, _fld2, result); } } private static UInt32 _data1; private static UInt32 _data2; private static UInt32 _clsVar1; private static UInt32 _clsVar2; private UInt32 _fld1; private UInt32 _fld2; static ScalarBinaryOpTest__ComputeCrc32_UInt32() { _clsVar1 = 0xFFFFFFFF; _clsVar2 = 0x20191113; } public ScalarBinaryOpTest__ComputeCrc32_UInt32() { Succeeded = true; _fld1 = 0xFFFFFFFF; _fld2 = 0x20191113; _data1 = 0xFFFFFFFF; _data2 = 0x20191113; } public bool IsSupported => Crc32.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Crc32.ComputeCrc32( Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data1)), Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data2)) ); ValidateResult(_data1, _data2, result); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Crc32).GetMethod(nameof(Crc32.ComputeCrc32), new Type[] { typeof(UInt32), typeof(UInt32) }) .Invoke(null, new object[] { Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data1)), Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data2)) }); ValidateResult(_data1, _data2, (UInt32)result); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Crc32.ComputeCrc32( _clsVar1, _clsVar2 ); ValidateResult(_clsVar1, _clsVar2, result); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var data1 = Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data1)); var data2 = Unsafe.ReadUnaligned<UInt32>(ref Unsafe.As<UInt32, byte>(ref _data2)); var result = Crc32.ComputeCrc32(data1, data2); ValidateResult(data1, data2, result); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new ScalarBinaryOpTest__ComputeCrc32_UInt32(); var result = Crc32.ComputeCrc32(test._fld1, test._fld2); ValidateResult(test._fld1, test._fld2, result); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Crc32.ComputeCrc32(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Crc32.ComputeCrc32(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); } 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(UInt32 left, UInt32 right, UInt32 result, [CallerMemberName] string method = "") { var isUnexpectedResult = false; uint expectedResult = 0x219D9805; isUnexpectedResult = (expectedResult != result); if (isUnexpectedResult) { TestLibrary.TestFramework.LogInformation($"{nameof(Crc32)}.{nameof(Crc32.ComputeCrc32)}<UInt32>(UInt32, UInt32): ComputeCrc32 failed:"); TestLibrary.TestFramework.LogInformation($" left: {left}"); TestLibrary.TestFramework.LogInformation($" right: {right}"); TestLibrary.TestFramework.LogInformation($" result: {result}"); TestLibrary.TestFramework.LogInformation(string.Empty); Succeeded = false; } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Runtime.Serialization.Xml/ref/System.Runtime.Serialization.Xml.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.Runtime.Serialization { public abstract partial class DataContractResolver { protected DataContractResolver() { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract System.Type? ResolveName(string typeName, string? typeNamespace, System.Type? declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract bool TryResolveType(System.Type type, System.Type? declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver, out System.Xml.XmlDictionaryString? typeName, out System.Xml.XmlDictionaryString? typeNamespace); } public sealed partial class DataContractSerializer : System.Runtime.Serialization.XmlObjectSerializer { public DataContractSerializer(System.Type type) { } public DataContractSerializer(System.Type type, System.Collections.Generic.IEnumerable<System.Type>? knownTypes) { } public DataContractSerializer(System.Type type, System.Runtime.Serialization.DataContractSerializerSettings? settings) { } public DataContractSerializer(System.Type type, string rootName, string rootNamespace) { } public DataContractSerializer(System.Type type, string rootName, string rootNamespace, System.Collections.Generic.IEnumerable<System.Type>? knownTypes) { } public DataContractSerializer(System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace) { } public DataContractSerializer(System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, System.Collections.Generic.IEnumerable<System.Type>? knownTypes) { } public System.Runtime.Serialization.DataContractResolver? DataContractResolver { get { throw null; } } public bool IgnoreExtensionDataObject { get { throw null; } } public System.Collections.ObjectModel.ReadOnlyCollection<System.Type> KnownTypes { get { throw null; } } public int MaxItemsInObjectGraph { get { throw null; } } public bool PreserveObjectReferences { get { throw null; } } public bool SerializeReadOnlyTypes { get { throw null; } } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override bool IsStartObject(System.Xml.XmlDictionaryReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override bool IsStartObject(System.Xml.XmlReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override object? ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public object? ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName, System.Runtime.Serialization.DataContractResolver? dataContractResolver) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override object? ReadObject(System.Xml.XmlReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override object? ReadObject(System.Xml.XmlReader reader, bool verifyObjectName) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteEndObject(System.Xml.XmlDictionaryWriter writer) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteEndObject(System.Xml.XmlWriter writer) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public void WriteObject(System.Xml.XmlDictionaryWriter writer, object? graph, System.Runtime.Serialization.DataContractResolver? dataContractResolver) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteObject(System.Xml.XmlWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteObjectContent(System.Xml.XmlWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteStartObject(System.Xml.XmlDictionaryWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteStartObject(System.Xml.XmlWriter writer, object? graph) { } } public static partial class DataContractSerializerExtensions { public static System.Runtime.Serialization.ISerializationSurrogateProvider? GetSerializationSurrogateProvider(this System.Runtime.Serialization.DataContractSerializer serializer) { throw null; } public static void SetSerializationSurrogateProvider(this System.Runtime.Serialization.DataContractSerializer serializer, System.Runtime.Serialization.ISerializationSurrogateProvider? provider) { } } public partial class DataContractSerializerSettings { public DataContractSerializerSettings() { } public System.Runtime.Serialization.DataContractResolver? DataContractResolver { get { throw null; } set { } } public bool IgnoreExtensionDataObject { get { throw null; } set { } } public System.Collections.Generic.IEnumerable<System.Type>? KnownTypes { get { throw null; } set { } } public int MaxItemsInObjectGraph { get { throw null; } set { } } public bool PreserveObjectReferences { get { throw null; } set { } } public System.Xml.XmlDictionaryString? RootName { get { throw null; } set { } } public System.Xml.XmlDictionaryString? RootNamespace { get { throw null; } set { } } public bool SerializeReadOnlyTypes { get { throw null; } set { } } } public partial class ExportOptions { public ExportOptions() { } public System.Collections.ObjectModel.Collection<System.Type> KnownTypes { get { throw null; } } } public sealed partial class ExtensionDataObject { internal ExtensionDataObject() { } } public partial interface IExtensibleDataObject { System.Runtime.Serialization.ExtensionDataObject? ExtensionData { get; set; } } public abstract partial class XmlObjectSerializer { protected XmlObjectSerializer() { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract bool IsStartObject(System.Xml.XmlDictionaryReader reader); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual bool IsStartObject(System.Xml.XmlReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual object? ReadObject(System.IO.Stream stream) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual object? ReadObject(System.Xml.XmlDictionaryReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract object? ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual object? ReadObject(System.Xml.XmlReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual object? ReadObject(System.Xml.XmlReader reader, bool verifyObjectName) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract void WriteEndObject(System.Xml.XmlDictionaryWriter writer); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteEndObject(System.Xml.XmlWriter writer) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteObject(System.IO.Stream stream, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteObject(System.Xml.XmlDictionaryWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteObject(System.Xml.XmlWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object? graph); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteObjectContent(System.Xml.XmlWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract void WriteStartObject(System.Xml.XmlDictionaryWriter writer, object? graph); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteStartObject(System.Xml.XmlWriter writer, object? graph) { } } public static partial class XmlSerializableServices { public static void AddDefaultSchema(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeQName) { } public static System.Xml.XmlNode[] ReadNodes(System.Xml.XmlReader xmlReader) { throw null; } public static void WriteNodes(System.Xml.XmlWriter xmlWriter, System.Xml.XmlNode?[]? nodes) { } } public static partial class XPathQueryGenerator { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public static string CreateFromDataContractSerializer(System.Type type, System.Reflection.MemberInfo[] pathToMember, System.Text.StringBuilder? rootElementXpath, out System.Xml.XmlNamespaceManager namespaces) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public static string CreateFromDataContractSerializer(System.Type type, System.Reflection.MemberInfo[] pathToMember, out System.Xml.XmlNamespaceManager namespaces) { throw null; } } public partial class XsdDataContractExporter { public XsdDataContractExporter() { } public XsdDataContractExporter(System.Xml.Schema.XmlSchemaSet? schemas) { } public System.Runtime.Serialization.ExportOptions? Options { get { throw null; } set { } } public System.Xml.Schema.XmlSchemaSet Schemas { get { throw null; } } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public bool CanExport(System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public bool CanExport(System.Collections.Generic.ICollection<System.Type> types) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public bool CanExport(System.Type type) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public void Export(System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public void Export(System.Collections.Generic.ICollection<System.Type> types) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public void Export(System.Type type) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public System.Xml.XmlQualifiedName? GetRootElementName(System.Type type) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public System.Xml.Schema.XmlSchemaType? GetSchemaType(System.Type type) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public System.Xml.XmlQualifiedName GetSchemaTypeName(System.Type type) { throw null; } } } namespace System.Xml { public partial interface IFragmentCapableXmlDictionaryWriter { bool CanFragment { get; } void EndFragment(); void StartFragment(System.IO.Stream stream, bool generateSelfContainedTextFragment); void WriteFragment(byte[] buffer, int offset, int count); } public partial interface IStreamProvider { System.IO.Stream GetStream(); void ReleaseStream(System.IO.Stream stream); } public partial interface IXmlBinaryReaderInitializer { void SetInput(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session, System.Xml.OnXmlDictionaryReaderClose? onClose); void SetInput(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session, System.Xml.OnXmlDictionaryReaderClose? onClose); } public partial interface IXmlBinaryWriterInitializer { void SetOutput(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlBinaryWriterSession? session, bool ownsStream); } public partial interface IXmlDictionary { bool TryLookup(int key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result); bool TryLookup(string value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result); bool TryLookup(System.Xml.XmlDictionaryString value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result); } public partial interface IXmlTextReaderInitializer { void SetInput(byte[] buffer, int offset, int count, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose); void SetInput(System.IO.Stream stream, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose); } public partial interface IXmlTextWriterInitializer { void SetOutput(System.IO.Stream stream, System.Text.Encoding encoding, bool ownsStream); } public delegate void OnXmlDictionaryReaderClose(System.Xml.XmlDictionaryReader reader); public partial class UniqueId { public UniqueId() { } public UniqueId(byte[] guid) { } public UniqueId(byte[] guid, int offset) { } public UniqueId(char[] chars, int offset, int count) { } public UniqueId(System.Guid guid) { } public UniqueId(string value) { } public int CharArrayLength { get { throw null; } } public bool IsGuid { get { throw null; } } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } public static bool operator ==(System.Xml.UniqueId? id1, System.Xml.UniqueId? id2) { throw null; } public static bool operator !=(System.Xml.UniqueId? id1, System.Xml.UniqueId? id2) { throw null; } public int ToCharArray(char[] chars, int offset) { throw null; } public override string ToString() { throw null; } public bool TryGetGuid(byte[] buffer, int offset) { throw null; } public bool TryGetGuid(out System.Guid guid) { throw null; } } public partial class XmlBinaryReaderSession : System.Xml.IXmlDictionary { public XmlBinaryReaderSession() { } public System.Xml.XmlDictionaryString Add(int id, string value) { throw null; } public void Clear() { } public bool TryLookup(int key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } public bool TryLookup(string value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } public bool TryLookup(System.Xml.XmlDictionaryString value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } } public partial class XmlBinaryWriterSession { public XmlBinaryWriterSession() { } public void Reset() { } public virtual bool TryAdd(System.Xml.XmlDictionaryString value, out int key) { throw null; } } public partial class XmlDictionary : System.Xml.IXmlDictionary { public XmlDictionary() { } public XmlDictionary(int capacity) { } public static System.Xml.IXmlDictionary Empty { get { throw null; } } public virtual System.Xml.XmlDictionaryString Add(string value) { throw null; } public virtual bool TryLookup(int key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } public virtual bool TryLookup(string value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } public virtual bool TryLookup(System.Xml.XmlDictionaryString value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } } public abstract partial class XmlDictionaryReader : System.Xml.XmlReader { protected XmlDictionaryReader() { } public virtual bool CanCanonicalize { get { throw null; } } public virtual System.Xml.XmlDictionaryReaderQuotas Quotas { get { throw null; } } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateDictionaryReader(System.Xml.XmlReader reader) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding[] encodings, string? contentType, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding[] encodings, string? contentType, System.Xml.XmlDictionaryReaderQuotas quotas, int maxBufferSize, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding[] encodings, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding[] encodings, string? contentType, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding[] encodings, string? contentType, System.Xml.XmlDictionaryReaderQuotas quotas, int maxBufferSize, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding[] encodings, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(byte[] buffer, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(System.IO.Stream stream, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(System.IO.Stream stream, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public virtual void EndCanonicalization() { } public virtual string? GetAttribute(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual void GetNonAtomizedNames(out string localName, out string namespaceUri) { throw null; } public virtual int IndexOfLocalName(string[] localNames, string namespaceUri) { throw null; } public virtual int IndexOfLocalName(System.Xml.XmlDictionaryString[] localNames, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual bool IsLocalName(string localName) { throw null; } public virtual bool IsLocalName(System.Xml.XmlDictionaryString localName) { throw null; } public virtual bool IsNamespaceUri(string namespaceUri) { throw null; } public virtual bool IsNamespaceUri(System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual bool IsStartArray([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Type? type) { throw null; } public virtual bool IsStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } protected bool IsTextNode(System.Xml.XmlNodeType nodeType) { throw null; } public virtual void MoveToStartElement() { } public virtual void MoveToStartElement(string name) { } public virtual void MoveToStartElement(string localName, string namespaceUri) { } public virtual void MoveToStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { } public virtual int ReadArray(string localName, string namespaceUri, bool[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, System.DateTime[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, decimal[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, double[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, System.Guid[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, short[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, int[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, long[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, float[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, System.TimeSpan[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, bool[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, System.DateTime[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, decimal[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, double[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, System.Guid[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, short[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, int[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, long[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, float[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, System.TimeSpan[] array, int offset, int count) { throw null; } public virtual bool[] ReadBooleanArray(string localName, string namespaceUri) { throw null; } public virtual bool[] ReadBooleanArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public override object ReadContentAs(System.Type type, System.Xml.IXmlNamespaceResolver? namespaceResolver) { throw null; } public virtual byte[] ReadContentAsBase64() { throw null; } public virtual byte[] ReadContentAsBinHex() { throw null; } protected byte[] ReadContentAsBinHex(int maxByteArrayContentLength) { throw null; } public virtual int ReadContentAsChars(char[] chars, int offset, int count) { throw null; } public override decimal ReadContentAsDecimal() { throw null; } public override float ReadContentAsFloat() { throw null; } public virtual System.Guid ReadContentAsGuid() { throw null; } public virtual void ReadContentAsQualifiedName(out string localName, out string namespaceUri) { throw null; } public override string ReadContentAsString() { throw null; } protected string ReadContentAsString(int maxStringContentLength) { throw null; } public virtual string ReadContentAsString(string[] strings, out int index) { throw null; } public virtual string ReadContentAsString(System.Xml.XmlDictionaryString[] strings, out int index) { throw null; } public virtual System.TimeSpan ReadContentAsTimeSpan() { throw null; } public virtual System.Xml.UniqueId ReadContentAsUniqueId() { throw null; } public virtual System.DateTime[] ReadDateTimeArray(string localName, string namespaceUri) { throw null; } public virtual System.DateTime[] ReadDateTimeArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual decimal[] ReadDecimalArray(string localName, string namespaceUri) { throw null; } public virtual decimal[] ReadDecimalArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual double[] ReadDoubleArray(string localName, string namespaceUri) { throw null; } public virtual double[] ReadDoubleArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual byte[] ReadElementContentAsBase64() { throw null; } public virtual byte[] ReadElementContentAsBinHex() { throw null; } public override bool ReadElementContentAsBoolean() { throw null; } public override System.DateTime ReadElementContentAsDateTime() { throw null; } public override decimal ReadElementContentAsDecimal() { throw null; } public override double ReadElementContentAsDouble() { throw null; } public override float ReadElementContentAsFloat() { throw null; } public virtual System.Guid ReadElementContentAsGuid() { throw null; } public override int ReadElementContentAsInt() { throw null; } public override long ReadElementContentAsLong() { throw null; } public override string ReadElementContentAsString() { throw null; } public virtual System.TimeSpan ReadElementContentAsTimeSpan() { throw null; } public virtual System.Xml.UniqueId ReadElementContentAsUniqueId() { throw null; } public virtual void ReadFullStartElement() { } public virtual void ReadFullStartElement(string name) { } public virtual void ReadFullStartElement(string localName, string namespaceUri) { } public virtual void ReadFullStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { } public virtual System.Guid[] ReadGuidArray(string localName, string namespaceUri) { throw null; } public virtual System.Guid[] ReadGuidArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual short[] ReadInt16Array(string localName, string namespaceUri) { throw null; } public virtual short[] ReadInt16Array(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual int[] ReadInt32Array(string localName, string namespaceUri) { throw null; } public virtual int[] ReadInt32Array(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual long[] ReadInt64Array(string localName, string namespaceUri) { throw null; } public virtual long[] ReadInt64Array(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual float[] ReadSingleArray(string localName, string namespaceUri) { throw null; } public virtual float[] ReadSingleArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual void ReadStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { } public override string ReadString() { throw null; } protected string ReadString(int maxStringContentLength) { throw null; } public virtual System.TimeSpan[] ReadTimeSpanArray(string localName, string namespaceUri) { throw null; } public virtual System.TimeSpan[] ReadTimeSpanArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual int ReadValueAsBase64(byte[] buffer, int offset, int count) { throw null; } public virtual void StartCanonicalization(System.IO.Stream stream, bool includeComments, string[]? inclusivePrefixes) { } public virtual bool TryGetArrayLength(out int count) { throw null; } public virtual bool TryGetBase64ContentLength(out int length) { throw null; } public virtual bool TryGetLocalNameAsDictionaryString([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? localName) { throw null; } public virtual bool TryGetNamespaceUriAsDictionaryString([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? namespaceUri) { throw null; } public virtual bool TryGetValueAsDictionaryString([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? value) { throw null; } } public sealed partial class XmlDictionaryReaderQuotas { public XmlDictionaryReaderQuotas() { } public static System.Xml.XmlDictionaryReaderQuotas Max { get { throw null; } } [System.ComponentModel.DefaultValueAttribute(16384)] public int MaxArrayLength { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(4096)] public int MaxBytesPerRead { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(32)] public int MaxDepth { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(16384)] public int MaxNameTableCharCount { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(8192)] public int MaxStringContentLength { get { throw null; } set { } } public System.Xml.XmlDictionaryReaderQuotaTypes ModifiedQuotas { get { throw null; } } public void CopyTo(System.Xml.XmlDictionaryReaderQuotas quotas) { } } [System.FlagsAttribute] public enum XmlDictionaryReaderQuotaTypes { MaxDepth = 1, MaxStringContentLength = 2, MaxArrayLength = 4, MaxBytesPerRead = 8, MaxNameTableCharCount = 16, } public partial class XmlDictionaryString { public XmlDictionaryString(System.Xml.IXmlDictionary dictionary, string value, int key) { } public System.Xml.IXmlDictionary Dictionary { get { throw null; } } public static System.Xml.XmlDictionaryString Empty { get { throw null; } } public int Key { get { throw null; } } public string Value { get { throw null; } } public override string ToString() { throw null; } } public abstract partial class XmlDictionaryWriter : System.Xml.XmlWriter { protected XmlDictionaryWriter() { } public virtual bool CanCanonicalize { get { throw null; } } public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream) { throw null; } public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary) { throw null; } public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlBinaryWriterSession? session) { throw null; } public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlBinaryWriterSession? session, bool ownsStream) { throw null; } public static System.Xml.XmlDictionaryWriter CreateDictionaryWriter(System.Xml.XmlWriter writer) { throw null; } public static System.Xml.XmlDictionaryWriter CreateMtomWriter(System.IO.Stream stream, System.Text.Encoding encoding, int maxSizeInBytes, string startInfo) { throw null; } public static System.Xml.XmlDictionaryWriter CreateMtomWriter(System.IO.Stream stream, System.Text.Encoding encoding, int maxSizeInBytes, string startInfo, string? boundary, string? startUri, bool writeMessageHeaders, bool ownsStream) { throw null; } public static System.Xml.XmlDictionaryWriter CreateTextWriter(System.IO.Stream stream) { throw null; } public static System.Xml.XmlDictionaryWriter CreateTextWriter(System.IO.Stream stream, System.Text.Encoding encoding) { throw null; } public static System.Xml.XmlDictionaryWriter CreateTextWriter(System.IO.Stream stream, System.Text.Encoding encoding, bool ownsStream) { throw null; } public virtual void EndCanonicalization() { } public virtual void StartCanonicalization(System.IO.Stream stream, bool includeComments, string[]? inclusivePrefixes) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, bool[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, System.DateTime[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, decimal[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, double[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, System.Guid[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, short[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, int[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, long[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, float[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, System.TimeSpan[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, bool[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, System.DateTime[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, decimal[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, double[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, System.Guid[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, short[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, int[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, long[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, float[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, System.TimeSpan[] array, int offset, int count) { } public void WriteAttributeString(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, string? value) { } public void WriteAttributeString(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, string? value) { } public override System.Threading.Tasks.Task WriteBase64Async(byte[] buffer, int index, int count) { throw null; } public void WriteElementString(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, string? value) { } public void WriteElementString(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, string? value) { } public virtual void WriteNode(System.Xml.XmlDictionaryReader reader, bool defattr) { } public override void WriteNode(System.Xml.XmlReader reader, bool defattr) { } public virtual void WriteQualifiedName(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public virtual void WriteStartAttribute(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public void WriteStartAttribute(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public virtual void WriteStartElement(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public void WriteStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public virtual void WriteString(System.Xml.XmlDictionaryString? value) { } protected virtual void WriteTextNode(System.Xml.XmlDictionaryReader reader, bool isAttribute) { } public virtual void WriteValue(System.Guid value) { } public virtual void WriteValue(System.TimeSpan value) { } public virtual void WriteValue(System.Xml.IStreamProvider value) { } public virtual void WriteValue(System.Xml.UniqueId value) { } public virtual void WriteValue(System.Xml.XmlDictionaryString? value) { } public virtual System.Threading.Tasks.Task WriteValueAsync(System.Xml.IStreamProvider value) { throw null; } public virtual void WriteXmlAttribute(string localName, string? value) { } public virtual void WriteXmlAttribute(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? value) { } public virtual void WriteXmlnsAttribute(string? prefix, string namespaceUri) { } public virtual void WriteXmlnsAttribute(string? prefix, System.Xml.XmlDictionaryString namespaceUri) { } } }
// 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.Runtime.Serialization { public abstract partial class DataContractResolver { protected DataContractResolver() { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract System.Type? ResolveName(string typeName, string? typeNamespace, System.Type? declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract bool TryResolveType(System.Type type, System.Type? declaredType, System.Runtime.Serialization.DataContractResolver knownTypeResolver, out System.Xml.XmlDictionaryString? typeName, out System.Xml.XmlDictionaryString? typeNamespace); } public sealed partial class DataContractSerializer : System.Runtime.Serialization.XmlObjectSerializer { public DataContractSerializer(System.Type type) { } public DataContractSerializer(System.Type type, System.Collections.Generic.IEnumerable<System.Type>? knownTypes) { } public DataContractSerializer(System.Type type, System.Runtime.Serialization.DataContractSerializerSettings? settings) { } public DataContractSerializer(System.Type type, string rootName, string rootNamespace) { } public DataContractSerializer(System.Type type, string rootName, string rootNamespace, System.Collections.Generic.IEnumerable<System.Type>? knownTypes) { } public DataContractSerializer(System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace) { } public DataContractSerializer(System.Type type, System.Xml.XmlDictionaryString rootName, System.Xml.XmlDictionaryString rootNamespace, System.Collections.Generic.IEnumerable<System.Type>? knownTypes) { } public System.Runtime.Serialization.DataContractResolver? DataContractResolver { get { throw null; } } public bool IgnoreExtensionDataObject { get { throw null; } } public System.Collections.ObjectModel.ReadOnlyCollection<System.Type> KnownTypes { get { throw null; } } public int MaxItemsInObjectGraph { get { throw null; } } public bool PreserveObjectReferences { get { throw null; } } public bool SerializeReadOnlyTypes { get { throw null; } } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override bool IsStartObject(System.Xml.XmlDictionaryReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override bool IsStartObject(System.Xml.XmlReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override object? ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public object? ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName, System.Runtime.Serialization.DataContractResolver? dataContractResolver) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override object? ReadObject(System.Xml.XmlReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override object? ReadObject(System.Xml.XmlReader reader, bool verifyObjectName) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteEndObject(System.Xml.XmlDictionaryWriter writer) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteEndObject(System.Xml.XmlWriter writer) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public void WriteObject(System.Xml.XmlDictionaryWriter writer, object? graph, System.Runtime.Serialization.DataContractResolver? dataContractResolver) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteObject(System.Xml.XmlWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteObjectContent(System.Xml.XmlWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteStartObject(System.Xml.XmlDictionaryWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public override void WriteStartObject(System.Xml.XmlWriter writer, object? graph) { } } public static partial class DataContractSerializerExtensions { public static System.Runtime.Serialization.ISerializationSurrogateProvider? GetSerializationSurrogateProvider(this System.Runtime.Serialization.DataContractSerializer serializer) { throw null; } public static void SetSerializationSurrogateProvider(this System.Runtime.Serialization.DataContractSerializer serializer, System.Runtime.Serialization.ISerializationSurrogateProvider? provider) { } } public partial class DataContractSerializerSettings { public DataContractSerializerSettings() { } public System.Runtime.Serialization.DataContractResolver? DataContractResolver { get { throw null; } set { } } public bool IgnoreExtensionDataObject { get { throw null; } set { } } public System.Collections.Generic.IEnumerable<System.Type>? KnownTypes { get { throw null; } set { } } public int MaxItemsInObjectGraph { get { throw null; } set { } } public bool PreserveObjectReferences { get { throw null; } set { } } public System.Xml.XmlDictionaryString? RootName { get { throw null; } set { } } public System.Xml.XmlDictionaryString? RootNamespace { get { throw null; } set { } } public bool SerializeReadOnlyTypes { get { throw null; } set { } } } public partial class ExportOptions { public ExportOptions() { } public System.Collections.ObjectModel.Collection<System.Type> KnownTypes { get { throw null; } } } public sealed partial class ExtensionDataObject { internal ExtensionDataObject() { } } public partial interface IExtensibleDataObject { System.Runtime.Serialization.ExtensionDataObject? ExtensionData { get; set; } } public abstract partial class XmlObjectSerializer { protected XmlObjectSerializer() { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract bool IsStartObject(System.Xml.XmlDictionaryReader reader); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual bool IsStartObject(System.Xml.XmlReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual object? ReadObject(System.IO.Stream stream) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual object? ReadObject(System.Xml.XmlDictionaryReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract object? ReadObject(System.Xml.XmlDictionaryReader reader, bool verifyObjectName); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual object? ReadObject(System.Xml.XmlReader reader) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual object? ReadObject(System.Xml.XmlReader reader, bool verifyObjectName) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract void WriteEndObject(System.Xml.XmlDictionaryWriter writer); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteEndObject(System.Xml.XmlWriter writer) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteObject(System.IO.Stream stream, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteObject(System.Xml.XmlDictionaryWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteObject(System.Xml.XmlWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object? graph); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteObjectContent(System.Xml.XmlWriter writer, object? graph) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public abstract void WriteStartObject(System.Xml.XmlDictionaryWriter writer, object? graph); [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public virtual void WriteStartObject(System.Xml.XmlWriter writer, object? graph) { } } public static partial class XmlSerializableServices { public static void AddDefaultSchema(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeQName) { } public static System.Xml.XmlNode[] ReadNodes(System.Xml.XmlReader xmlReader) { throw null; } public static void WriteNodes(System.Xml.XmlWriter xmlWriter, System.Xml.XmlNode?[]? nodes) { } } public static partial class XPathQueryGenerator { [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public static string CreateFromDataContractSerializer(System.Type type, System.Reflection.MemberInfo[] pathToMember, System.Text.StringBuilder? rootElementXpath, out System.Xml.XmlNamespaceManager namespaces) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public static string CreateFromDataContractSerializer(System.Type type, System.Reflection.MemberInfo[] pathToMember, out System.Xml.XmlNamespaceManager namespaces) { throw null; } } public partial class XsdDataContractExporter { public XsdDataContractExporter() { } public XsdDataContractExporter(System.Xml.Schema.XmlSchemaSet? schemas) { } public System.Runtime.Serialization.ExportOptions? Options { get { throw null; } set { } } public System.Xml.Schema.XmlSchemaSet Schemas { get { throw null; } } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public bool CanExport(System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public bool CanExport(System.Collections.Generic.ICollection<System.Type> types) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public bool CanExport(System.Type type) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public void Export(System.Collections.Generic.ICollection<System.Reflection.Assembly> assemblies) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public void Export(System.Collections.Generic.ICollection<System.Type> types) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public void Export(System.Type type) { } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public System.Xml.XmlQualifiedName? GetRootElementName(System.Type type) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public System.Xml.Schema.XmlSchemaType? GetSchemaType(System.Type type) { throw null; } [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")] public System.Xml.XmlQualifiedName GetSchemaTypeName(System.Type type) { throw null; } } } namespace System.Xml { public partial interface IFragmentCapableXmlDictionaryWriter { bool CanFragment { get; } void EndFragment(); void StartFragment(System.IO.Stream stream, bool generateSelfContainedTextFragment); void WriteFragment(byte[] buffer, int offset, int count); } public partial interface IStreamProvider { System.IO.Stream GetStream(); void ReleaseStream(System.IO.Stream stream); } public partial interface IXmlBinaryReaderInitializer { void SetInput(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session, System.Xml.OnXmlDictionaryReaderClose? onClose); void SetInput(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session, System.Xml.OnXmlDictionaryReaderClose? onClose); } public partial interface IXmlBinaryWriterInitializer { void SetOutput(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlBinaryWriterSession? session, bool ownsStream); } public partial interface IXmlDictionary { bool TryLookup(int key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result); bool TryLookup(string value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result); bool TryLookup(System.Xml.XmlDictionaryString value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result); } public partial interface IXmlTextReaderInitializer { void SetInput(byte[] buffer, int offset, int count, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose); void SetInput(System.IO.Stream stream, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose); } public partial interface IXmlTextWriterInitializer { void SetOutput(System.IO.Stream stream, System.Text.Encoding encoding, bool ownsStream); } public delegate void OnXmlDictionaryReaderClose(System.Xml.XmlDictionaryReader reader); public partial class UniqueId { public UniqueId() { } public UniqueId(byte[] guid) { } public UniqueId(byte[] guid, int offset) { } public UniqueId(char[] chars, int offset, int count) { } public UniqueId(System.Guid guid) { } public UniqueId(string value) { } public int CharArrayLength { get { throw null; } } public bool IsGuid { get { throw null; } } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } public override int GetHashCode() { throw null; } public static bool operator ==(System.Xml.UniqueId? id1, System.Xml.UniqueId? id2) { throw null; } public static bool operator !=(System.Xml.UniqueId? id1, System.Xml.UniqueId? id2) { throw null; } public int ToCharArray(char[] chars, int offset) { throw null; } public override string ToString() { throw null; } public bool TryGetGuid(byte[] buffer, int offset) { throw null; } public bool TryGetGuid(out System.Guid guid) { throw null; } } public partial class XmlBinaryReaderSession : System.Xml.IXmlDictionary { public XmlBinaryReaderSession() { } public System.Xml.XmlDictionaryString Add(int id, string value) { throw null; } public void Clear() { } public bool TryLookup(int key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } public bool TryLookup(string value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } public bool TryLookup(System.Xml.XmlDictionaryString value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } } public partial class XmlBinaryWriterSession { public XmlBinaryWriterSession() { } public void Reset() { } public virtual bool TryAdd(System.Xml.XmlDictionaryString value, out int key) { throw null; } } public partial class XmlDictionary : System.Xml.IXmlDictionary { public XmlDictionary() { } public XmlDictionary(int capacity) { } public static System.Xml.IXmlDictionary Empty { get { throw null; } } public virtual System.Xml.XmlDictionaryString Add(string value) { throw null; } public virtual bool TryLookup(int key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } public virtual bool TryLookup(string value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } public virtual bool TryLookup(System.Xml.XmlDictionaryString value, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? result) { throw null; } } public abstract partial class XmlDictionaryReader : System.Xml.XmlReader { protected XmlDictionaryReader() { } public virtual bool CanCanonicalize { get { throw null; } } public virtual System.Xml.XmlDictionaryReaderQuotas Quotas { get { throw null; } } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(byte[] buffer, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.XmlBinaryReaderSession? session, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateBinaryReader(System.IO.Stream stream, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateDictionaryReader(System.Xml.XmlReader reader) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding[] encodings, string? contentType, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding[] encodings, string? contentType, System.Xml.XmlDictionaryReaderQuotas quotas, int maxBufferSize, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, System.Text.Encoding[] encodings, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding[] encodings, string? contentType, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding[] encodings, string? contentType, System.Xml.XmlDictionaryReaderQuotas quotas, int maxBufferSize, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateMtomReader(System.IO.Stream stream, System.Text.Encoding[] encodings, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(byte[] buffer, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(System.IO.Stream stream, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose) { throw null; } public static System.Xml.XmlDictionaryReader CreateTextReader(System.IO.Stream stream, System.Xml.XmlDictionaryReaderQuotas quotas) { throw null; } public virtual void EndCanonicalization() { } public virtual string? GetAttribute(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual void GetNonAtomizedNames(out string localName, out string namespaceUri) { throw null; } public virtual int IndexOfLocalName(string[] localNames, string namespaceUri) { throw null; } public virtual int IndexOfLocalName(System.Xml.XmlDictionaryString[] localNames, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual bool IsLocalName(string localName) { throw null; } public virtual bool IsLocalName(System.Xml.XmlDictionaryString localName) { throw null; } public virtual bool IsNamespaceUri(string namespaceUri) { throw null; } public virtual bool IsNamespaceUri(System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual bool IsStartArray([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Type? type) { throw null; } public virtual bool IsStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } protected bool IsTextNode(System.Xml.XmlNodeType nodeType) { throw null; } public virtual void MoveToStartElement() { } public virtual void MoveToStartElement(string name) { } public virtual void MoveToStartElement(string localName, string namespaceUri) { } public virtual void MoveToStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { } public virtual int ReadArray(string localName, string namespaceUri, bool[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, System.DateTime[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, decimal[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, double[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, System.Guid[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, short[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, int[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, long[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, float[] array, int offset, int count) { throw null; } public virtual int ReadArray(string localName, string namespaceUri, System.TimeSpan[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, bool[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, System.DateTime[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, decimal[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, double[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, System.Guid[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, short[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, int[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, long[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, float[] array, int offset, int count) { throw null; } public virtual int ReadArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri, System.TimeSpan[] array, int offset, int count) { throw null; } public virtual bool[] ReadBooleanArray(string localName, string namespaceUri) { throw null; } public virtual bool[] ReadBooleanArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public override object ReadContentAs(System.Type type, System.Xml.IXmlNamespaceResolver? namespaceResolver) { throw null; } public virtual byte[] ReadContentAsBase64() { throw null; } public virtual byte[] ReadContentAsBinHex() { throw null; } protected byte[] ReadContentAsBinHex(int maxByteArrayContentLength) { throw null; } public virtual int ReadContentAsChars(char[] chars, int offset, int count) { throw null; } public override decimal ReadContentAsDecimal() { throw null; } public override float ReadContentAsFloat() { throw null; } public virtual System.Guid ReadContentAsGuid() { throw null; } public virtual void ReadContentAsQualifiedName(out string localName, out string namespaceUri) { throw null; } public override string ReadContentAsString() { throw null; } protected string ReadContentAsString(int maxStringContentLength) { throw null; } public virtual string ReadContentAsString(string[] strings, out int index) { throw null; } public virtual string ReadContentAsString(System.Xml.XmlDictionaryString[] strings, out int index) { throw null; } public virtual System.TimeSpan ReadContentAsTimeSpan() { throw null; } public virtual System.Xml.UniqueId ReadContentAsUniqueId() { throw null; } public virtual System.DateTime[] ReadDateTimeArray(string localName, string namespaceUri) { throw null; } public virtual System.DateTime[] ReadDateTimeArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual decimal[] ReadDecimalArray(string localName, string namespaceUri) { throw null; } public virtual decimal[] ReadDecimalArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual double[] ReadDoubleArray(string localName, string namespaceUri) { throw null; } public virtual double[] ReadDoubleArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual byte[] ReadElementContentAsBase64() { throw null; } public virtual byte[] ReadElementContentAsBinHex() { throw null; } public override bool ReadElementContentAsBoolean() { throw null; } public override System.DateTime ReadElementContentAsDateTime() { throw null; } public override decimal ReadElementContentAsDecimal() { throw null; } public override double ReadElementContentAsDouble() { throw null; } public override float ReadElementContentAsFloat() { throw null; } public virtual System.Guid ReadElementContentAsGuid() { throw null; } public override int ReadElementContentAsInt() { throw null; } public override long ReadElementContentAsLong() { throw null; } public override string ReadElementContentAsString() { throw null; } public virtual System.TimeSpan ReadElementContentAsTimeSpan() { throw null; } public virtual System.Xml.UniqueId ReadElementContentAsUniqueId() { throw null; } public virtual void ReadFullStartElement() { } public virtual void ReadFullStartElement(string name) { } public virtual void ReadFullStartElement(string localName, string namespaceUri) { } public virtual void ReadFullStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { } public virtual System.Guid[] ReadGuidArray(string localName, string namespaceUri) { throw null; } public virtual System.Guid[] ReadGuidArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual short[] ReadInt16Array(string localName, string namespaceUri) { throw null; } public virtual short[] ReadInt16Array(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual int[] ReadInt32Array(string localName, string namespaceUri) { throw null; } public virtual int[] ReadInt32Array(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual long[] ReadInt64Array(string localName, string namespaceUri) { throw null; } public virtual long[] ReadInt64Array(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual float[] ReadSingleArray(string localName, string namespaceUri) { throw null; } public virtual float[] ReadSingleArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual void ReadStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { } public override string ReadString() { throw null; } protected string ReadString(int maxStringContentLength) { throw null; } public virtual System.TimeSpan[] ReadTimeSpanArray(string localName, string namespaceUri) { throw null; } public virtual System.TimeSpan[] ReadTimeSpanArray(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString namespaceUri) { throw null; } public virtual int ReadValueAsBase64(byte[] buffer, int offset, int count) { throw null; } public virtual void StartCanonicalization(System.IO.Stream stream, bool includeComments, string[]? inclusivePrefixes) { } public virtual bool TryGetArrayLength(out int count) { throw null; } public virtual bool TryGetBase64ContentLength(out int length) { throw null; } public virtual bool TryGetLocalNameAsDictionaryString([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? localName) { throw null; } public virtual bool TryGetNamespaceUriAsDictionaryString([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? namespaceUri) { throw null; } public virtual bool TryGetValueAsDictionaryString([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Xml.XmlDictionaryString? value) { throw null; } } public sealed partial class XmlDictionaryReaderQuotas { public XmlDictionaryReaderQuotas() { } public static System.Xml.XmlDictionaryReaderQuotas Max { get { throw null; } } [System.ComponentModel.DefaultValueAttribute(16384)] public int MaxArrayLength { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(4096)] public int MaxBytesPerRead { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(32)] public int MaxDepth { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(16384)] public int MaxNameTableCharCount { get { throw null; } set { } } [System.ComponentModel.DefaultValueAttribute(8192)] public int MaxStringContentLength { get { throw null; } set { } } public System.Xml.XmlDictionaryReaderQuotaTypes ModifiedQuotas { get { throw null; } } public void CopyTo(System.Xml.XmlDictionaryReaderQuotas quotas) { } } [System.FlagsAttribute] public enum XmlDictionaryReaderQuotaTypes { MaxDepth = 1, MaxStringContentLength = 2, MaxArrayLength = 4, MaxBytesPerRead = 8, MaxNameTableCharCount = 16, } public partial class XmlDictionaryString { public XmlDictionaryString(System.Xml.IXmlDictionary dictionary, string value, int key) { } public System.Xml.IXmlDictionary Dictionary { get { throw null; } } public static System.Xml.XmlDictionaryString Empty { get { throw null; } } public int Key { get { throw null; } } public string Value { get { throw null; } } public override string ToString() { throw null; } } public abstract partial class XmlDictionaryWriter : System.Xml.XmlWriter { protected XmlDictionaryWriter() { } public virtual bool CanCanonicalize { get { throw null; } } public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream) { throw null; } public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary) { throw null; } public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlBinaryWriterSession? session) { throw null; } public static System.Xml.XmlDictionaryWriter CreateBinaryWriter(System.IO.Stream stream, System.Xml.IXmlDictionary? dictionary, System.Xml.XmlBinaryWriterSession? session, bool ownsStream) { throw null; } public static System.Xml.XmlDictionaryWriter CreateDictionaryWriter(System.Xml.XmlWriter writer) { throw null; } public static System.Xml.XmlDictionaryWriter CreateMtomWriter(System.IO.Stream stream, System.Text.Encoding encoding, int maxSizeInBytes, string startInfo) { throw null; } public static System.Xml.XmlDictionaryWriter CreateMtomWriter(System.IO.Stream stream, System.Text.Encoding encoding, int maxSizeInBytes, string startInfo, string? boundary, string? startUri, bool writeMessageHeaders, bool ownsStream) { throw null; } public static System.Xml.XmlDictionaryWriter CreateTextWriter(System.IO.Stream stream) { throw null; } public static System.Xml.XmlDictionaryWriter CreateTextWriter(System.IO.Stream stream, System.Text.Encoding encoding) { throw null; } public static System.Xml.XmlDictionaryWriter CreateTextWriter(System.IO.Stream stream, System.Text.Encoding encoding, bool ownsStream) { throw null; } public virtual void EndCanonicalization() { } public virtual void StartCanonicalization(System.IO.Stream stream, bool includeComments, string[]? inclusivePrefixes) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, bool[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, System.DateTime[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, decimal[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, double[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, System.Guid[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, short[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, int[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, long[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, float[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, string localName, string? namespaceUri, System.TimeSpan[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, bool[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, System.DateTime[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, decimal[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, double[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, System.Guid[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, short[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, int[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, long[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, float[] array, int offset, int count) { } public virtual void WriteArray(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, System.TimeSpan[] array, int offset, int count) { } public void WriteAttributeString(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, string? value) { } public void WriteAttributeString(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, string? value) { } public override System.Threading.Tasks.Task WriteBase64Async(byte[] buffer, int index, int count) { throw null; } public void WriteElementString(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, string? value) { } public void WriteElementString(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri, string? value) { } public virtual void WriteNode(System.Xml.XmlDictionaryReader reader, bool defattr) { } public override void WriteNode(System.Xml.XmlReader reader, bool defattr) { } public virtual void WriteQualifiedName(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public virtual void WriteStartAttribute(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public void WriteStartAttribute(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public virtual void WriteStartElement(string? prefix, System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public void WriteStartElement(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? namespaceUri) { } public virtual void WriteString(System.Xml.XmlDictionaryString? value) { } protected virtual void WriteTextNode(System.Xml.XmlDictionaryReader reader, bool isAttribute) { } public virtual void WriteValue(System.Guid value) { } public virtual void WriteValue(System.TimeSpan value) { } public virtual void WriteValue(System.Xml.IStreamProvider value) { } public virtual void WriteValue(System.Xml.UniqueId value) { } public virtual void WriteValue(System.Xml.XmlDictionaryString? value) { } public virtual System.Threading.Tasks.Task WriteValueAsync(System.Xml.IStreamProvider value) { throw null; } public virtual void WriteXmlAttribute(string localName, string? value) { } public virtual void WriteXmlAttribute(System.Xml.XmlDictionaryString localName, System.Xml.XmlDictionaryString? value) { } public virtual void WriteXmlnsAttribute(string? prefix, string namespaceUri) { } public virtual void WriteXmlnsAttribute(string? prefix, System.Xml.XmlDictionaryString namespaceUri) { } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/shims/mscorlib.forwards.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // The types in this file are internal types that need to have type-forwards from full facade assemblies such as mscorlib. // Many of these types are required by various components used by the C++/CLI compiler to live in mscorlib. // These types are required to support the C++/CLI compiler's usage of alink for metadata linking. [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AssemblyAttributesGoHere))] [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AssemblyAttributesGoHereS))] [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AssemblyAttributesGoHereM))] [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AssemblyAttributesGoHereSM))] [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.SuppressMergeCheckAttribute))]
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // The types in this file are internal types that need to have type-forwards from full facade assemblies such as mscorlib. // Many of these types are required by various components used by the C++/CLI compiler to live in mscorlib. // These types are required to support the C++/CLI compiler's usage of alink for metadata linking. [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AssemblyAttributesGoHere))] [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AssemblyAttributesGoHereS))] [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AssemblyAttributesGoHereM))] [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.AssemblyAttributesGoHereSM))] [assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.CompilerServices.SuppressMergeCheckAttribute))]
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/Common/XUnitWrapperLibrary/TestOutputRecorder.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.Text; using System.Threading; namespace XUnitWrapperLibrary; public sealed class TestOutputRecorder : TextWriter { private TextWriter _inner; private ThreadLocal<StringBuilder> _testOutput = new(() => new StringBuilder()); public TestOutputRecorder(TextWriter inner) { _inner = inner; } public override void Write(char value) { _inner.Write(value); _testOutput.Value!.Append(value); } public override Encoding Encoding => _inner.Encoding; public void ResetTestOutput() => _testOutput.Value!.Clear(); public string GetTestOutput() => _testOutput.Value!.ToString(); }
// 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.Text; using System.Threading; namespace XUnitWrapperLibrary; public sealed class TestOutputRecorder : TextWriter { private TextWriter _inner; private ThreadLocal<StringBuilder> _testOutput = new(() => new StringBuilder()); public TestOutputRecorder(TextWriter inner) { _inner = inner; } public override void Write(char value) { _inner.Write(value); _testOutput.Value!.Append(value); } public override Encoding Encoding => _inner.Encoding; public void ResetTestOutput() => _testOutput.Value!.Clear(); public string GetTestOutput() => _testOutput.Value!.ToString(); }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressInformation.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.Net.NetworkInformation { /// <summary> /// Provides information about a network interface address. /// </summary> public abstract class IPAddressInformation { /// <summary> /// Gets the Internet Protocol (IP) address. /// </summary> public abstract IPAddress Address { get; } /// <summary> /// Gets a bool value that indicates whether the Internet Protocol (IP) address is legal to appear in a Domain Name System (DNS) server database. /// </summary> public abstract bool IsDnsEligible { get; } /// <summary> /// Gets a bool value that indicates whether the Internet Protocol (IP) address is transient. /// </summary> public abstract bool IsTransient { get; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Net.NetworkInformation { /// <summary> /// Provides information about a network interface address. /// </summary> public abstract class IPAddressInformation { /// <summary> /// Gets the Internet Protocol (IP) address. /// </summary> public abstract IPAddress Address { get; } /// <summary> /// Gets a bool value that indicates whether the Internet Protocol (IP) address is legal to appear in a Domain Name System (DNS) server database. /// </summary> public abstract bool IsDnsEligible { get; } /// <summary> /// Gets a bool value that indicates whether the Internet Protocol (IP) address is transient. /// </summary> public abstract bool IsTransient { get; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Text.Json/gen/Reflection/MethodInfoWrapper.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.Globalization; using System.Reflection; using Microsoft.CodeAnalysis; namespace System.Text.Json.Reflection { internal class MethodInfoWrapper : MethodInfo { private readonly IMethodSymbol _method; private readonly MetadataLoadContextInternal _metadataLoadContext; public MethodInfoWrapper(IMethodSymbol method, MetadataLoadContextInternal metadataLoadContext) { _method = method; _metadataLoadContext = metadataLoadContext; } public override ICustomAttributeProvider ReturnTypeCustomAttributes => throw new NotImplementedException(); private MethodAttributes? _attributes; public override MethodAttributes Attributes => _attributes ??= _method.GetMethodAttributes(); public override RuntimeMethodHandle MethodHandle => throw new NotSupportedException(); public override Type DeclaringType => _method.ContainingType.AsType(_metadataLoadContext); public override Type ReturnType => _method.ReturnType.AsType(_metadataLoadContext); public override string Name => _method.Name; public override bool IsGenericMethod => _method.IsGenericMethod; public bool IsInitOnly => _method.IsInitOnly; public override Type ReflectedType => throw new NotImplementedException(); public override IList<CustomAttributeData> GetCustomAttributesData() { var attributes = new List<CustomAttributeData>(); foreach (AttributeData a in _method.GetAttributes()) { attributes.Add(new CustomAttributeDataWrapper(a, _metadataLoadContext)); } return attributes; } public override MethodInfo GetBaseDefinition() { throw new NotImplementedException(); } public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(); } public override Type[] GetGenericArguments() { var typeArguments = new List<Type>(); foreach (ITypeSymbol t in _method.TypeArguments) { typeArguments.Add(t.AsType(_metadataLoadContext)); } return typeArguments.ToArray(); } public override MethodImplAttributes GetMethodImplementationFlags() { throw new NotImplementedException(); } public override ParameterInfo[] GetParameters() { var parameters = new List<ParameterInfo>(); foreach (IParameterSymbol p in _method.Parameters) { parameters.Add(new ParameterInfoWrapper(p, _metadataLoadContext)); } return parameters.ToArray(); } public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(); } public override bool IsDefined(Type attributeType, bool inherit) { throw new NotImplementedException(); } } }
// 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.Globalization; using System.Reflection; using Microsoft.CodeAnalysis; namespace System.Text.Json.Reflection { internal class MethodInfoWrapper : MethodInfo { private readonly IMethodSymbol _method; private readonly MetadataLoadContextInternal _metadataLoadContext; public MethodInfoWrapper(IMethodSymbol method, MetadataLoadContextInternal metadataLoadContext) { _method = method; _metadataLoadContext = metadataLoadContext; } public override ICustomAttributeProvider ReturnTypeCustomAttributes => throw new NotImplementedException(); private MethodAttributes? _attributes; public override MethodAttributes Attributes => _attributes ??= _method.GetMethodAttributes(); public override RuntimeMethodHandle MethodHandle => throw new NotSupportedException(); public override Type DeclaringType => _method.ContainingType.AsType(_metadataLoadContext); public override Type ReturnType => _method.ReturnType.AsType(_metadataLoadContext); public override string Name => _method.Name; public override bool IsGenericMethod => _method.IsGenericMethod; public bool IsInitOnly => _method.IsInitOnly; public override Type ReflectedType => throw new NotImplementedException(); public override IList<CustomAttributeData> GetCustomAttributesData() { var attributes = new List<CustomAttributeData>(); foreach (AttributeData a in _method.GetAttributes()) { attributes.Add(new CustomAttributeDataWrapper(a, _metadataLoadContext)); } return attributes; } public override MethodInfo GetBaseDefinition() { throw new NotImplementedException(); } public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(); } public override Type[] GetGenericArguments() { var typeArguments = new List<Type>(); foreach (ITypeSymbol t in _method.TypeArguments) { typeArguments.Add(t.AsType(_metadataLoadContext)); } return typeArguments.ToArray(); } public override MethodImplAttributes GetMethodImplementationFlags() { throw new NotImplementedException(); } public override ParameterInfo[] GetParameters() { var parameters = new List<ParameterInfo>(); foreach (IParameterSymbol p in _method.Parameters) { parameters.Add(new ParameterInfoWrapper(p, _metadataLoadContext)); } return parameters.ToArray(); } public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(); } public override bool IsDefined(Type attributeType, bool inherit) { throw new NotImplementedException(); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.UtcTime.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; using System.Security.Cryptography; namespace System.Formats.Asn1 { public static partial class AsnDecoder { /// <summary> /// Reads a UtcTime value from <paramref name="source"/> with a specified tag under /// the specified encoding rules. /// </summary> /// <param name="source">The buffer containing encoded data.</param> /// <param name="ruleSet">The encoding constraints to use when interpreting the data.</param> /// <param name="bytesConsumed"> /// When this method returns, the total number of bytes for the encoded value. /// This parameter is treated as uninitialized. /// </param> /// <param name="twoDigitYearMax"> /// The largest year to represent with this value. /// The default value, 2049, represents the 1950-2049 range for X.509 certificates. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 24). /// </param> /// <returns> /// The decoded value. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="ruleSet"/> is not defined. /// /// -or- /// /// <paramref name="twoDigitYearMax"/> is not in the range [99, 9999]. /// </exception> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="System.Globalization.Calendar.TwoDigitYearMax"/> public static DateTimeOffset ReadUtcTime( ReadOnlySpan<byte> source, AsnEncodingRules ruleSet, out int bytesConsumed, int twoDigitYearMax = 2049, Asn1Tag? expectedTag = null) { if (twoDigitYearMax < 1 || twoDigitYearMax > 9999) { throw new ArgumentOutOfRangeException(nameof(twoDigitYearMax)); } // T-REC-X.680-201510 sec 47.3 says it is IMPLICIT VisibleString, which means // that BER is allowed to do complex constructed forms. // The full allowed formats (T-REC-X.680-201510 sec 47.3) // YYMMDDhhmmZ (a, b1, c1) // YYMMDDhhmm+hhmm (a, b1, c2+) // YYMMDDhhmm-hhmm (a, b1, c2-) // YYMMDDhhmmssZ (a, b2, c1) // YYMMDDhhmmss+hhmm (a, b2, c2+) // YYMMDDhhmmss-hhmm (a, b2, c2-) // CER and DER are restricted to YYMMDDhhmmssZ // T-REC-X.690-201510 sec 11.8 // The longest format is 17 bytes. Span<byte> tmpSpace = stackalloc byte[17]; byte[]? rented = null; ReadOnlySpan<byte> contents = GetOctetStringContents( source, ruleSet, expectedTag ?? Asn1Tag.UtcTime, UniversalTagNumber.UtcTime, out int bytesRead, ref rented, tmpSpace); DateTimeOffset value = ParseUtcTime(contents, ruleSet, twoDigitYearMax); if (rented != null) { Debug.Fail($"UtcTime did not fit in tmpSpace ({contents.Length} total)"); CryptoPool.Return(rented, contents.Length); } bytesConsumed = bytesRead; return value; } private static DateTimeOffset ParseUtcTime( ReadOnlySpan<byte> contentOctets, AsnEncodingRules ruleSet, int twoDigitYearMax) { // The full allowed formats (T-REC-X.680-201510 sec 47.3) // a) YYMMDD // b1) hhmm // b2) hhmmss // c1) Z // c2) {+|-}hhmm // // YYMMDDhhmmZ (a, b1, c1) // YYMMDDhhmm+hhmm (a, b1, c2+) // YYMMDDhhmm-hhmm (a, b1, c2-) // YYMMDDhhmmssZ (a, b2, c1) // YYMMDDhhmmss+hhmm (a, b2, c2+) // YYMMDDhhmmss-hhmm (a, b2, c2-) const int NoSecondsZulu = 11; const int NoSecondsOffset = 15; const int HasSecondsZulu = 13; const int HasSecondsOffset = 17; // T-REC-X.690-201510 sec 11.8 if (ruleSet == AsnEncodingRules.DER || ruleSet == AsnEncodingRules.CER) { if (contentOctets.Length != HasSecondsZulu) { throw new AsnContentException(SR.ContentException_InvalidUnderCerOrDer_TryBer); } } // 11, 13, 15, 17 are legal. // Range check + odd. if (contentOctets.Length < NoSecondsZulu || contentOctets.Length > HasSecondsOffset || (contentOctets.Length & 1) != 1) { throw new AsnContentException(); } ReadOnlySpan<byte> contents = contentOctets; int year = ParseNonNegativeIntAndSlice(ref contents, 2); int month = ParseNonNegativeIntAndSlice(ref contents, 2); int day = ParseNonNegativeIntAndSlice(ref contents, 2); int hour = ParseNonNegativeIntAndSlice(ref contents, 2); int minute = ParseNonNegativeIntAndSlice(ref contents, 2); int second = 0; int offsetHour = 0; int offsetMinute = 0; bool minus = false; if (contentOctets.Length == HasSecondsOffset || contentOctets.Length == HasSecondsZulu) { second = ParseNonNegativeIntAndSlice(ref contents, 2); } if (contentOctets.Length == NoSecondsZulu || contentOctets.Length == HasSecondsZulu) { if (contents[0] != 'Z') { throw new AsnContentException(); } } else { Debug.Assert( contentOctets.Length == NoSecondsOffset || contentOctets.Length == HasSecondsOffset); if (contents[0] == '-') { minus = true; } else if (contents[0] != '+') { throw new AsnContentException(); } contents = contents.Slice(1); offsetHour = ParseNonNegativeIntAndSlice(ref contents, 2); offsetMinute = ParseNonNegativeIntAndSlice(ref contents, 2); Debug.Assert(contents.IsEmpty); } // ISO 8601:2004 4.2.1 restricts a "minute" value to [00,59]. // The "hour" value is effectively bound to [00,23] by the same section, but // is bound to [00,14] by DateTimeOffset, so no additional check is required here. if (offsetMinute > 59) { throw new AsnContentException(); } TimeSpan offset = new TimeSpan(offsetHour, offsetMinute, 0); if (minus) { offset = -offset; } // Apply the twoDigitYearMax value. // Example: year=50, TDYM=2049 // century = 20 // year > 49 => century = 19 // scaledYear = 1900 + 50 = 1950 // // Example: year=49, TDYM=2049 // century = 20 // year is not > 49 => century = 20 // scaledYear = 2000 + 49 = 2049 int century = twoDigitYearMax / 100; if (year > twoDigitYearMax % 100) { century--; } int scaledYear = century * 100 + year; try { return new DateTimeOffset(scaledYear, month, day, hour, minute, second, offset); } catch (Exception e) { throw new AsnContentException(SR.ContentException_DefaultMessage, e); } } } public partial class AsnReader { /// <summary> /// Reads the next value as a UTCTime with a specified tag using the /// <see cref="AsnReaderOptions.UtcTimeTwoDigitYearMax"/> value from options passed to /// the constructor (with a default of 2049). /// </summary> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 23). /// </param> /// <returns> /// The decoded value. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="ReadUtcTime(int,Nullable{Asn1Tag})"/> public DateTimeOffset ReadUtcTime(Asn1Tag? expectedTag = null) { DateTimeOffset ret = AsnDecoder.ReadUtcTime( _data.Span, RuleSet, out int consumed, _options.UtcTimeTwoDigitYearMax, expectedTag); _data = _data.Slice(consumed); return ret; } /// <summary> /// Reads the next value as a UTCTime with a specified tag. /// </summary> /// <param name="twoDigitYearMax"> /// The largest year to represent with this value. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 23). /// </param> /// <returns> /// The decoded value. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="ReadUtcTime(Nullable{Asn1Tag})"/> /// <seealso cref="System.Globalization.Calendar.TwoDigitYearMax"/> public DateTimeOffset ReadUtcTime(int twoDigitYearMax, Asn1Tag? expectedTag = null) { DateTimeOffset ret = AsnDecoder.ReadUtcTime(_data.Span, RuleSet, out int consumed, twoDigitYearMax, expectedTag); _data = _data.Slice(consumed); return ret; } } }
// 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; using System.Security.Cryptography; namespace System.Formats.Asn1 { public static partial class AsnDecoder { /// <summary> /// Reads a UtcTime value from <paramref name="source"/> with a specified tag under /// the specified encoding rules. /// </summary> /// <param name="source">The buffer containing encoded data.</param> /// <param name="ruleSet">The encoding constraints to use when interpreting the data.</param> /// <param name="bytesConsumed"> /// When this method returns, the total number of bytes for the encoded value. /// This parameter is treated as uninitialized. /// </param> /// <param name="twoDigitYearMax"> /// The largest year to represent with this value. /// The default value, 2049, represents the 1950-2049 range for X.509 certificates. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 24). /// </param> /// <returns> /// The decoded value. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="ruleSet"/> is not defined. /// /// -or- /// /// <paramref name="twoDigitYearMax"/> is not in the range [99, 9999]. /// </exception> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="System.Globalization.Calendar.TwoDigitYearMax"/> public static DateTimeOffset ReadUtcTime( ReadOnlySpan<byte> source, AsnEncodingRules ruleSet, out int bytesConsumed, int twoDigitYearMax = 2049, Asn1Tag? expectedTag = null) { if (twoDigitYearMax < 1 || twoDigitYearMax > 9999) { throw new ArgumentOutOfRangeException(nameof(twoDigitYearMax)); } // T-REC-X.680-201510 sec 47.3 says it is IMPLICIT VisibleString, which means // that BER is allowed to do complex constructed forms. // The full allowed formats (T-REC-X.680-201510 sec 47.3) // YYMMDDhhmmZ (a, b1, c1) // YYMMDDhhmm+hhmm (a, b1, c2+) // YYMMDDhhmm-hhmm (a, b1, c2-) // YYMMDDhhmmssZ (a, b2, c1) // YYMMDDhhmmss+hhmm (a, b2, c2+) // YYMMDDhhmmss-hhmm (a, b2, c2-) // CER and DER are restricted to YYMMDDhhmmssZ // T-REC-X.690-201510 sec 11.8 // The longest format is 17 bytes. Span<byte> tmpSpace = stackalloc byte[17]; byte[]? rented = null; ReadOnlySpan<byte> contents = GetOctetStringContents( source, ruleSet, expectedTag ?? Asn1Tag.UtcTime, UniversalTagNumber.UtcTime, out int bytesRead, ref rented, tmpSpace); DateTimeOffset value = ParseUtcTime(contents, ruleSet, twoDigitYearMax); if (rented != null) { Debug.Fail($"UtcTime did not fit in tmpSpace ({contents.Length} total)"); CryptoPool.Return(rented, contents.Length); } bytesConsumed = bytesRead; return value; } private static DateTimeOffset ParseUtcTime( ReadOnlySpan<byte> contentOctets, AsnEncodingRules ruleSet, int twoDigitYearMax) { // The full allowed formats (T-REC-X.680-201510 sec 47.3) // a) YYMMDD // b1) hhmm // b2) hhmmss // c1) Z // c2) {+|-}hhmm // // YYMMDDhhmmZ (a, b1, c1) // YYMMDDhhmm+hhmm (a, b1, c2+) // YYMMDDhhmm-hhmm (a, b1, c2-) // YYMMDDhhmmssZ (a, b2, c1) // YYMMDDhhmmss+hhmm (a, b2, c2+) // YYMMDDhhmmss-hhmm (a, b2, c2-) const int NoSecondsZulu = 11; const int NoSecondsOffset = 15; const int HasSecondsZulu = 13; const int HasSecondsOffset = 17; // T-REC-X.690-201510 sec 11.8 if (ruleSet == AsnEncodingRules.DER || ruleSet == AsnEncodingRules.CER) { if (contentOctets.Length != HasSecondsZulu) { throw new AsnContentException(SR.ContentException_InvalidUnderCerOrDer_TryBer); } } // 11, 13, 15, 17 are legal. // Range check + odd. if (contentOctets.Length < NoSecondsZulu || contentOctets.Length > HasSecondsOffset || (contentOctets.Length & 1) != 1) { throw new AsnContentException(); } ReadOnlySpan<byte> contents = contentOctets; int year = ParseNonNegativeIntAndSlice(ref contents, 2); int month = ParseNonNegativeIntAndSlice(ref contents, 2); int day = ParseNonNegativeIntAndSlice(ref contents, 2); int hour = ParseNonNegativeIntAndSlice(ref contents, 2); int minute = ParseNonNegativeIntAndSlice(ref contents, 2); int second = 0; int offsetHour = 0; int offsetMinute = 0; bool minus = false; if (contentOctets.Length == HasSecondsOffset || contentOctets.Length == HasSecondsZulu) { second = ParseNonNegativeIntAndSlice(ref contents, 2); } if (contentOctets.Length == NoSecondsZulu || contentOctets.Length == HasSecondsZulu) { if (contents[0] != 'Z') { throw new AsnContentException(); } } else { Debug.Assert( contentOctets.Length == NoSecondsOffset || contentOctets.Length == HasSecondsOffset); if (contents[0] == '-') { minus = true; } else if (contents[0] != '+') { throw new AsnContentException(); } contents = contents.Slice(1); offsetHour = ParseNonNegativeIntAndSlice(ref contents, 2); offsetMinute = ParseNonNegativeIntAndSlice(ref contents, 2); Debug.Assert(contents.IsEmpty); } // ISO 8601:2004 4.2.1 restricts a "minute" value to [00,59]. // The "hour" value is effectively bound to [00,23] by the same section, but // is bound to [00,14] by DateTimeOffset, so no additional check is required here. if (offsetMinute > 59) { throw new AsnContentException(); } TimeSpan offset = new TimeSpan(offsetHour, offsetMinute, 0); if (minus) { offset = -offset; } // Apply the twoDigitYearMax value. // Example: year=50, TDYM=2049 // century = 20 // year > 49 => century = 19 // scaledYear = 1900 + 50 = 1950 // // Example: year=49, TDYM=2049 // century = 20 // year is not > 49 => century = 20 // scaledYear = 2000 + 49 = 2049 int century = twoDigitYearMax / 100; if (year > twoDigitYearMax % 100) { century--; } int scaledYear = century * 100 + year; try { return new DateTimeOffset(scaledYear, month, day, hour, minute, second, offset); } catch (Exception e) { throw new AsnContentException(SR.ContentException_DefaultMessage, e); } } } public partial class AsnReader { /// <summary> /// Reads the next value as a UTCTime with a specified tag using the /// <see cref="AsnReaderOptions.UtcTimeTwoDigitYearMax"/> value from options passed to /// the constructor (with a default of 2049). /// </summary> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 23). /// </param> /// <returns> /// The decoded value. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="ReadUtcTime(int,Nullable{Asn1Tag})"/> public DateTimeOffset ReadUtcTime(Asn1Tag? expectedTag = null) { DateTimeOffset ret = AsnDecoder.ReadUtcTime( _data.Span, RuleSet, out int consumed, _options.UtcTimeTwoDigitYearMax, expectedTag); _data = _data.Slice(consumed); return ret; } /// <summary> /// Reads the next value as a UTCTime with a specified tag. /// </summary> /// <param name="twoDigitYearMax"> /// The largest year to represent with this value. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 23). /// </param> /// <returns> /// The decoded value. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="ReadUtcTime(Nullable{Asn1Tag})"/> /// <seealso cref="System.Globalization.Calendar.TwoDigitYearMax"/> public DateTimeOffset ReadUtcTime(int twoDigitYearMax, Asn1Tag? expectedTag = null) { DateTimeOffset ret = AsnDecoder.ReadUtcTime(_data.Span, RuleSet, out int consumed, twoDigitYearMax, expectedTag); _data = _data.Slice(consumed); return ret; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/X86/Sse41/ConvertToVector128Int32.Int16.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.Reflection; 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 ConvertToVector128Int32Int16() { var test = new SimpleUnaryOpTest__ConvertToVector128Int32Int16(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates basic functionality works, using the pointer overload test.RunBasicScenario_Ptr(); if (Sse2.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(); // Validates calling via reflection works, using the pointer overload test.RunReflectionScenario_Ptr(); if (Sse2.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(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.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 works test.RunLclFldScenario(); // Validates passing an instance member works test.RunFldScenario(); } 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__ConvertToVector128Int32Int16 { private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); private static Int16[] _data = new Int16[Op1ElementCount]; private static Vector128<Int16> _clsVar; private Vector128<Int16> _fld; private SimpleUnaryOpTest__DataTable<Int32, Int16> _dataTable; static SimpleUnaryOpTest__ConvertToVector128Int32Int16() { var random = new Random(); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); } public SimpleUnaryOpTest__ConvertToVector128Int32Int16() { Succeeded = true; var random = new Random(); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } _dataTable = new SimpleUnaryOpTest__DataTable<Int32, Int16>(_data, new Int32[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { var result = Sse41.ConvertToVector128Int32( Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_Ptr() { var result = Sse41.ConvertToVector128Int32( (Int16*)(_dataTable.inArrayPtr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.ConvertToVector128Int32( Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.ConvertToVector128Int32( Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { var result = typeof(Sse41).GetMethod(nameof(Sse41.ConvertToVector128Int32), new Type[] { typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Ptr() { var result = typeof(Sse41).GetMethod(nameof(Sse41.ConvertToVector128Int32), new Type[] { typeof(Int16*) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.inArrayPtr, typeof(Int16*)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { var result = typeof(Sse41).GetMethod(nameof(Sse41.ConvertToVector128Int32), new Type[] { typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { var result = typeof(Sse41).GetMethod(nameof(Sse41.ConvertToVector128Int32), new Type[] { typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.ConvertToVector128Int32( _clsVar ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr); var result = Sse41.ConvertToVector128Int32(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)); var result = Sse41.ConvertToVector128Int32(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)); var result = Sse41.ConvertToVector128Int32(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclFldScenario() { var test = new SimpleUnaryOpTest__ConvertToVector128Int32Int16(); var result = Sse41.ConvertToVector128Int32(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunFldScenario() { var result = Sse41.ConvertToVector128Int32(_fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld, _dataTable.outArrayPtr); } public void RunUnsupportedScenario() { Succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { Succeeded = true; } } private void ValidateResult(Vector128<Int16> firstOp, void* result, [CallerMemberName] string method = "") { Int16[] inArray = new Int16[Op1ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), firstOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") { Int16[] inArray = new Int16[Op1ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(Int16[] firstOp, Int32[] result, [CallerMemberName] string method = "") { if (result[0] != firstOp[0]) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != firstOp[i]) { Succeeded = false; break; } } } if (!Succeeded) { Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.ConvertToVector128Int32)}<Int32>(Vector128<Int16>): {method} failed:"); Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } } }
// 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.Reflection; 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 ConvertToVector128Int32Int16() { var test = new SimpleUnaryOpTest__ConvertToVector128Int32Int16(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); // Validates basic functionality works, using the pointer overload test.RunBasicScenario_Ptr(); if (Sse2.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(); // Validates calling via reflection works, using the pointer overload test.RunReflectionScenario_Ptr(); if (Sse2.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(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.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 works test.RunLclFldScenario(); // Validates passing an instance member works test.RunFldScenario(); } 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__ConvertToVector128Int32Int16 { private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Int16>>() / sizeof(Int16); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Int32>>() / sizeof(Int32); private static Int16[] _data = new Int16[Op1ElementCount]; private static Vector128<Int16> _clsVar; private Vector128<Int16> _fld; private SimpleUnaryOpTest__DataTable<Int32, Int16> _dataTable; static SimpleUnaryOpTest__ConvertToVector128Int32Int16() { var random = new Random(); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); } public SimpleUnaryOpTest__ConvertToVector128Int32Int16() { Succeeded = true; var random = new Random(); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld), ref Unsafe.As<Int16, byte>(ref _data[0]), (uint)Unsafe.SizeOf<Vector128<Int16>>()); for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } _dataTable = new SimpleUnaryOpTest__DataTable<Int32, Int16>(_data, new Int32[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { var result = Sse41.ConvertToVector128Int32( Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_Ptr() { var result = Sse41.ConvertToVector128Int32( (Int16*)(_dataTable.inArrayPtr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.ConvertToVector128Int32( Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.ConvertToVector128Int32( Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { var result = typeof(Sse41).GetMethod(nameof(Sse41.ConvertToVector128Int32), new Type[] { typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Ptr() { var result = typeof(Sse41).GetMethod(nameof(Sse41.ConvertToVector128Int32), new Type[] { typeof(Int16*) }) .Invoke(null, new object[] { Pointer.Box(_dataTable.inArrayPtr, typeof(Int16*)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { var result = typeof(Sse41).GetMethod(nameof(Sse41.ConvertToVector128Int32), new Type[] { typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { var result = typeof(Sse41).GetMethod(nameof(Sse41.ConvertToVector128Int32), new Type[] { typeof(Vector128<Int16>) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Int32>)(result)); ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.ConvertToVector128Int32( _clsVar ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read<Vector128<Int16>>(_dataTable.inArrayPtr); var result = Sse41.ConvertToVector128Int32(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)); var result = Sse41.ConvertToVector128Int32(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)); var result = Sse41.ConvertToVector128Int32(firstOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclFldScenario() { var test = new SimpleUnaryOpTest__ConvertToVector128Int32Int16(); var result = Sse41.ConvertToVector128Int32(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } public void RunFldScenario() { var result = Sse41.ConvertToVector128Int32(_fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld, _dataTable.outArrayPtr); } public void RunUnsupportedScenario() { Succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { Succeeded = true; } } private void ValidateResult(Vector128<Int16> firstOp, void* result, [CallerMemberName] string method = "") { Int16[] inArray = new Int16[Op1ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), firstOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") { Int16[] inArray = new Int16[Op1ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<Int16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Int32>>()); ValidateResult(inArray, outArray, method); } private void ValidateResult(Int16[] firstOp, Int32[] result, [CallerMemberName] string method = "") { if (result[0] != firstOp[0]) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != firstOp[i]) { Succeeded = false; break; } } } if (!Succeeded) { Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.ConvertToVector128Int32)}<Int32>(Vector128<Int16>): {method} failed:"); Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.IO.FileSystem/tests/FileInfo/Open.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.IO.Tests { public class FileInfo_Open_fm : FileStream_ctor_str_fm { protected override FileStream CreateFileStream(string path, FileMode mode) { return new FileInfo(path).Open(mode); } public override void FileModeAppend(string streamSpecifier) { using (FileStream fs = CreateFileStream(GetTestFilePath() + streamSpecifier, FileMode.Append)) { Assert.False(fs.CanRead); Assert.True(fs.CanWrite); } } public override void FileModeAppendExisting(string streamSpecifier) { string fileName = GetTestFilePath() + streamSpecifier; using (FileStream fs = CreateFileStream(fileName, FileMode.Create)) { fs.WriteByte(0); } using (FileStream fs = CreateFileStream(fileName, FileMode.Append)) { // Ensure that the file was re-opened and position set to end Assert.Equal(1L, fs.Length); Assert.Equal(1L, fs.Position); Assert.False(fs.CanRead); Assert.True(fs.CanSeek); Assert.True(fs.CanWrite); Assert.Throws<IOException>(() => fs.Seek(-1, SeekOrigin.Current)); Assert.Throws<NotSupportedException>(() => fs.ReadByte()); } } } public class FileInfo_Open_fm_fa : FileStream_ctor_str_fm_fa { protected override FileStream CreateFileStream(string path, FileMode mode) { return new FileInfo(path).Open(mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access) { return new FileInfo(path).Open(mode, access); } } public class FileInfo_Open_fm_fa_fs : FileStream_ctor_str_fm_fa_fs { protected override FileStream CreateFileStream(string path, FileMode mode) { return new FileInfo(path).Open(mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access) { return new FileInfo(path).Open(mode, access, FileShare.ReadWrite | FileShare.Delete); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access, FileShare share) { return new FileInfo(path).Open(mode, access, share); } } public class FileInfo_Open_options : FileStream_ctor_options { protected override FileStream CreateFileStream(string path, FileMode mode) { return new FileInfo(path).Open( new FileStreamOptions { Mode = mode, Access = mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite }); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access) { return new FileInfo(path).Open( new FileStreamOptions { Mode = mode, Access = access }); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options) { return new FileInfo(path).Open( new FileStreamOptions { Mode = mode, Access = access, Share = share, Options = options, BufferSize = bufferSize }); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize) { return new FileInfo(path).Open( new FileStreamOptions { Mode = mode, Access = access, Share = share, Options = options, BufferSize = bufferSize, PreallocationSize = preallocationSize }); } } public class FileInfo_OpenSpecial : FileStream_ctor_str_fm_fa_fs { protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access) { if (mode == FileMode.Open && access == FileAccess.Read) return new FileInfo(path).OpenRead(); else if (mode == FileMode.OpenOrCreate && access == FileAccess.Write) return new FileInfo(path).OpenWrite(); else return new FileInfo(path).Open(mode, access); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access, FileShare share) { if (mode == FileMode.Open && access == FileAccess.Read && share == FileShare.Read) return new FileInfo(path).OpenRead(); else if (mode == FileMode.OpenOrCreate && access == FileAccess.Write && share == FileShare.None) return new FileInfo(path).OpenWrite(); else return new FileInfo(path).Open(mode, access, share); } } public class FileInfo_CreateText : File_ReadWriteAllText { protected override void Write(string path, string content) { var writer = new FileInfo(path).CreateText(); writer.Write(content); writer.Dispose(); } } public class FileInfo_OpenText : File_ReadWriteAllText { protected override string Read(string path) { using (var reader = new FileInfo(path).OpenText()) return reader.ReadToEnd(); } } }
// 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.IO.Tests { public class FileInfo_Open_fm : FileStream_ctor_str_fm { protected override FileStream CreateFileStream(string path, FileMode mode) { return new FileInfo(path).Open(mode); } public override void FileModeAppend(string streamSpecifier) { using (FileStream fs = CreateFileStream(GetTestFilePath() + streamSpecifier, FileMode.Append)) { Assert.False(fs.CanRead); Assert.True(fs.CanWrite); } } public override void FileModeAppendExisting(string streamSpecifier) { string fileName = GetTestFilePath() + streamSpecifier; using (FileStream fs = CreateFileStream(fileName, FileMode.Create)) { fs.WriteByte(0); } using (FileStream fs = CreateFileStream(fileName, FileMode.Append)) { // Ensure that the file was re-opened and position set to end Assert.Equal(1L, fs.Length); Assert.Equal(1L, fs.Position); Assert.False(fs.CanRead); Assert.True(fs.CanSeek); Assert.True(fs.CanWrite); Assert.Throws<IOException>(() => fs.Seek(-1, SeekOrigin.Current)); Assert.Throws<NotSupportedException>(() => fs.ReadByte()); } } } public class FileInfo_Open_fm_fa : FileStream_ctor_str_fm_fa { protected override FileStream CreateFileStream(string path, FileMode mode) { return new FileInfo(path).Open(mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access) { return new FileInfo(path).Open(mode, access); } } public class FileInfo_Open_fm_fa_fs : FileStream_ctor_str_fm_fa_fs { protected override FileStream CreateFileStream(string path, FileMode mode) { return new FileInfo(path).Open(mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access) { return new FileInfo(path).Open(mode, access, FileShare.ReadWrite | FileShare.Delete); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access, FileShare share) { return new FileInfo(path).Open(mode, access, share); } } public class FileInfo_Open_options : FileStream_ctor_options { protected override FileStream CreateFileStream(string path, FileMode mode) { return new FileInfo(path).Open( new FileStreamOptions { Mode = mode, Access = mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite }); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access) { return new FileInfo(path).Open( new FileStreamOptions { Mode = mode, Access = access }); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options) { return new FileInfo(path).Open( new FileStreamOptions { Mode = mode, Access = access, Share = share, Options = options, BufferSize = bufferSize }); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize) { return new FileInfo(path).Open( new FileStreamOptions { Mode = mode, Access = access, Share = share, Options = options, BufferSize = bufferSize, PreallocationSize = preallocationSize }); } } public class FileInfo_OpenSpecial : FileStream_ctor_str_fm_fa_fs { protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access) { if (mode == FileMode.Open && access == FileAccess.Read) return new FileInfo(path).OpenRead(); else if (mode == FileMode.OpenOrCreate && access == FileAccess.Write) return new FileInfo(path).OpenWrite(); else return new FileInfo(path).Open(mode, access); } protected override FileStream CreateFileStream(string path, FileMode mode, FileAccess access, FileShare share) { if (mode == FileMode.Open && access == FileAccess.Read && share == FileShare.Read) return new FileInfo(path).OpenRead(); else if (mode == FileMode.OpenOrCreate && access == FileAccess.Write && share == FileShare.None) return new FileInfo(path).OpenWrite(); else return new FileInfo(path).Open(mode, access, share); } } public class FileInfo_CreateText : File_ReadWriteAllText { protected override void Write(string path, string content) { var writer = new FileInfo(path).CreateText(); writer.Write(content); writer.Dispose(); } } public class FileInfo_OpenText : File_ReadWriteAllText { protected override string Read(string path) { using (var reader = new FileInfo(path).OpenText()) return reader.ReadToEnd(); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/Interop/DisabledRuntimeMarshalling/PInvokeAssemblyMarshallingDisabled/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.PInvokeAssemblyMarshallingDisabled; public unsafe class DelegatesFromExternalAssembly { [Fact] public static void StructWithDefaultNonBlittableFields_DoesNotMarshal() { short s = 42; bool b = true; var callback = Marshal.GetDelegateForFunctionPointer<CheckStructWithShortAndBoolCallback>((IntPtr)DisabledRuntimeMarshallingNative.GetStructWithShortAndBoolCallback()); Assert.True(callback(new StructWithShortAndBool(s, b), s, b)); } [Fact] public static void StructWithDefaultNonBlittableFields_IgnoresMarshalAsInfo() { short s = 41; bool b = true; var callback = Marshal.GetDelegateForFunctionPointer<CheckStructWithShortAndBoolWithVariantBoolCallback>((IntPtr)DisabledRuntimeMarshallingNative.GetStructWithShortAndBoolWithVariantBoolCallback()); Assert.False(callback(new StructWithShortAndBool(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.PInvokeAssemblyMarshallingDisabled; public unsafe class DelegatesFromExternalAssembly { [Fact] public static void StructWithDefaultNonBlittableFields_DoesNotMarshal() { short s = 42; bool b = true; var callback = Marshal.GetDelegateForFunctionPointer<CheckStructWithShortAndBoolCallback>((IntPtr)DisabledRuntimeMarshallingNative.GetStructWithShortAndBoolCallback()); Assert.True(callback(new StructWithShortAndBool(s, b), s, b)); } [Fact] public static void StructWithDefaultNonBlittableFields_IgnoresMarshalAsInfo() { short s = 41; bool b = true; var callback = Marshal.GetDelegateForFunctionPointer<CheckStructWithShortAndBoolWithVariantBoolCallback>((IntPtr)DisabledRuntimeMarshallingNative.GetStructWithShortAndBoolWithVariantBoolCallback()); Assert.False(callback(new StructWithShortAndBool(s, b), s, b)); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Data.Common/src/System/Data/Common/SQLConvert.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.Data.SqlTypes; using System.Xml; using System.Diagnostics; namespace System.Data.Common { internal static class SqlConvert { public static SqlByte ConvertToSqlByte(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlByte"); if ((value == DBNull.Value)) { // null is not valid, SqlByte is struct return SqlByte.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlByte)), }; } public static SqlInt16 ConvertToSqlInt16(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlInt16"); if (value == DBNull.Value) { return SqlInt16.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.Byte => (byte)value, StorageType.Int16 => (short)value, StorageType.SqlByte => (SqlByte)value, StorageType.SqlInt16 => (SqlInt16)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlInt16)), }; } public static SqlInt32 ConvertToSqlInt32(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlInt32"); if (value == DBNull.Value) { return SqlInt32.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlInt32)), }; } public static SqlInt64 ConvertToSqlInt64(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlInt64"); if (value == DBNull.Value) { return SqlInt32.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlInt64)), }; } public static SqlDouble ConvertToSqlDouble(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlDouble"); if (value == DBNull.Value) { return SqlDouble.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlDouble => (SqlDouble)value, StorageType.Double => (double)value, StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.UInt64 => (ulong)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, StorageType.SqlSingle => (SqlSingle)value, StorageType.Single => (float)value, StorageType.SqlMoney => (SqlMoney)value, StorageType.SqlDecimal => (SqlDecimal)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlDouble)), }; } public static SqlDecimal ConvertToSqlDecimal(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlDecimal"); if (value == DBNull.Value) { return SqlDecimal.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlDecimal => (SqlDecimal)value, StorageType.Decimal => (decimal)value, StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.UInt64 => (ulong)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, StorageType.SqlMoney => (SqlMoney)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlDecimal)), }; } public static SqlSingle ConvertToSqlSingle(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlSingle"); if (value == DBNull.Value) { return SqlSingle.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlSingle => (SqlSingle)value, StorageType.Single => (float)value, StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.UInt64 => (ulong)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, StorageType.SqlMoney => (SqlMoney)value, StorageType.SqlDecimal => (SqlDecimal)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlSingle)), }; } public static SqlMoney ConvertToSqlMoney(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlMoney"); if (value == DBNull.Value) { return SqlMoney.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlMoney => (SqlMoney)value, StorageType.Decimal => (decimal)value, StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.UInt64 => (ulong)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlMoney)), }; } public static SqlDateTime ConvertToSqlDateTime(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlDateTime"); if (value == DBNull.Value) { return SqlDateTime.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlDateTime => (SqlDateTime)value, StorageType.DateTime => (DateTime)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlDateTime)), }; } public static SqlBoolean ConvertToSqlBoolean(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlBoolean"); if ((value == DBNull.Value) || (value == null)) { return SqlBoolean.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlBoolean => (SqlBoolean)value, StorageType.Boolean => (bool)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlBoolean)), }; } public static SqlGuid ConvertToSqlGuid(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlGuid"); if (value == DBNull.Value) { return SqlGuid.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlGuid => (SqlGuid)value, StorageType.Guid => (Guid)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlGuid)), }; } public static SqlBinary ConvertToSqlBinary(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlBinary"); if (value == DBNull.Value) { return SqlBinary.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlBinary => (SqlBinary)value, StorageType.ByteArray => (byte[])value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlBinary)), }; } public static SqlString ConvertToSqlString(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlString"); if ((value == DBNull.Value) || (value == null)) { return SqlString.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlString => (SqlString)value, StorageType.String => (string)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlString)), }; } public static SqlChars ConvertToSqlChars(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlChars"); if (value == DBNull.Value) { return SqlChars.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlChars => (SqlChars)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlChars)), }; } public static SqlBytes ConvertToSqlBytes(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlBytes"); if (value == DBNull.Value) { return SqlBytes.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlBytes => (SqlBytes)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlBytes)), }; } public static DateTimeOffset ConvertStringToDateTimeOffset(string value, IFormatProvider formatProvider) { return DateTimeOffset.Parse(value, formatProvider); } // this should not be called for XmlSerialization public static object ChangeTypeForDefaultValue(object value, Type type, IFormatProvider formatProvider) { if (type == typeof(System.Numerics.BigInteger)) { if ((DBNull.Value == value) || (null == value)) { return DBNull.Value; } return BigIntegerStorage.ConvertToBigInteger(value, formatProvider); } else if (value is System.Numerics.BigInteger) { return BigIntegerStorage.ConvertFromBigInteger((System.Numerics.BigInteger)value, type, formatProvider); } return ChangeType2(value, DataStorage.GetStorageType(type), type, formatProvider); } // this should not be called for XmlSerialization public static object ChangeType2(object value, StorageType stype, Type type, IFormatProvider formatProvider) { switch (stype) { // if destination is SQL type case StorageType.SqlBinary: return (SqlConvert.ConvertToSqlBinary(value)); case StorageType.SqlBoolean: return (SqlConvert.ConvertToSqlBoolean(value)); case StorageType.SqlByte: return (SqlConvert.ConvertToSqlByte(value)); case StorageType.SqlBytes: return (SqlConvert.ConvertToSqlBytes(value)); case StorageType.SqlChars: return (SqlConvert.ConvertToSqlChars(value)); case StorageType.SqlDateTime: return (SqlConvert.ConvertToSqlDateTime(value)); case StorageType.SqlDecimal: return (SqlConvert.ConvertToSqlDecimal(value)); case StorageType.SqlDouble: return (SqlConvert.ConvertToSqlDouble(value)); case StorageType.SqlGuid: return (SqlConvert.ConvertToSqlGuid(value)); case StorageType.SqlInt16: return (SqlConvert.ConvertToSqlInt16(value)); case StorageType.SqlInt32: return (SqlConvert.ConvertToSqlInt32(value)); case StorageType.SqlInt64: return (SqlConvert.ConvertToSqlInt64(value)); case StorageType.SqlMoney: return (SqlConvert.ConvertToSqlMoney(value)); case StorageType.SqlSingle: return (SqlConvert.ConvertToSqlSingle(value)); case StorageType.SqlString: return (SqlConvert.ConvertToSqlString(value)); /* case StorageType.SqlXml: if (DataStorage.IsObjectNull(value)) { return SqlXml.Null; } goto default; */ default: // destination is CLR if ((DBNull.Value == value) || (null == value)) { return DBNull.Value; } Type valueType = value.GetType(); StorageType vtype = DataStorage.GetStorageType(valueType); // destination is CLR switch (vtype) {// and source is SQL type case StorageType.SqlBinary: case StorageType.SqlBoolean: case StorageType.SqlByte: case StorageType.SqlBytes: case StorageType.SqlChars: case StorageType.SqlDateTime: case StorageType.SqlDecimal: case StorageType.SqlDouble: case StorageType.SqlGuid: case StorageType.SqlInt16: case StorageType.SqlInt32: case StorageType.SqlInt64: case StorageType.SqlMoney: case StorageType.SqlSingle: case StorageType.SqlString: throw ExceptionBuilder.ConvertFailed(valueType, type); default: // source is CLR type if (StorageType.String == stype) { // destination is string switch (vtype) { // source's type case StorageType.Boolean: return ((IConvertible)(bool)value).ToString(formatProvider); case StorageType.Char: return ((IConvertible)(char)value).ToString(formatProvider); case StorageType.SByte: return ((sbyte)value).ToString(formatProvider); case StorageType.Byte: return ((byte)value).ToString(formatProvider); case StorageType.Int16: return ((short)value).ToString(formatProvider); case StorageType.UInt16: return ((ushort)value).ToString(formatProvider); case StorageType.Int32: return ((int)value).ToString(formatProvider); case StorageType.UInt32: return ((uint)value).ToString(formatProvider); case StorageType.Int64: return ((long)value).ToString(formatProvider); case StorageType.UInt64: return ((ulong)value).ToString(formatProvider); case StorageType.Single: return ((float)value).ToString(formatProvider); case StorageType.Double: return ((double)value).ToString(formatProvider); case StorageType.Decimal: return ((decimal)value).ToString(formatProvider); case StorageType.DateTime: return ((DateTime)value).ToString(formatProvider); //return XmlConvert.ToString((DateTime) value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.TimeSpan: return XmlConvert.ToString((TimeSpan)value); case StorageType.Guid: return XmlConvert.ToString((Guid)value); case StorageType.String: return (string)value; case StorageType.CharArray: return new string((char[])value); case StorageType.DateTimeOffset: return ((DateTimeOffset)value).ToString(formatProvider); case StorageType.BigInteger: break; default: IConvertible? iconvertible = (value as IConvertible); if (null != iconvertible) { return iconvertible.ToString(formatProvider); } // catch additional classes like Guid IFormattable? iformattable = (value as IFormattable); if (null != iformattable) { return iformattable.ToString(null, formatProvider); } return value.ToString()!; } } else if (StorageType.TimeSpan == stype) { // destination is TimeSpan return vtype switch { StorageType.String => XmlConvert.ToTimeSpan((string)value), StorageType.Int32 => new TimeSpan((int)value), StorageType.Int64 => new TimeSpan((long)value), _ => (TimeSpan)value, }; } else if (StorageType.DateTimeOffset == stype) { // destination is DateTimeOffset return (DateTimeOffset)value; } else if (StorageType.String == vtype) { // if source is string switch (stype) { // type of destination case StorageType.String: return (string)value; case StorageType.Boolean: if ("1" == (string)value) return true; if ("0" == (string)value) return false; break; case StorageType.Char: return ((IConvertible)(string)value).ToChar(formatProvider); case StorageType.SByte: return ((IConvertible)(string)value).ToSByte(formatProvider); case StorageType.Byte: return ((IConvertible)(string)value).ToByte(formatProvider); case StorageType.Int16: return ((IConvertible)(string)value).ToInt16(formatProvider); case StorageType.UInt16: return ((IConvertible)(string)value).ToUInt16(formatProvider); case StorageType.Int32: return ((IConvertible)(string)value).ToInt32(formatProvider); case StorageType.UInt32: return ((IConvertible)(string)value).ToUInt32(formatProvider); case StorageType.Int64: return ((IConvertible)(string)value).ToInt64(formatProvider); case StorageType.UInt64: return ((IConvertible)(string)value).ToUInt64(formatProvider); case StorageType.Single: return ((IConvertible)(string)value).ToSingle(formatProvider); case StorageType.Double: return ((IConvertible)(string)value).ToDouble(formatProvider); case StorageType.Decimal: return ((IConvertible)(string)value).ToDecimal(formatProvider); case StorageType.DateTime: return ((IConvertible)(string)value).ToDateTime(formatProvider); //return XmlConvert.ToDateTime((string) value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.TimeSpan: return XmlConvert.ToTimeSpan((string)value); case StorageType.Guid: return XmlConvert.ToGuid((string)value); case StorageType.Uri: return new Uri((string)value); default: // other clr types, break; } } return Convert.ChangeType(value, type, formatProvider); } } } // this should be called for XmlSerialization public static object ChangeTypeForXML(object value, Type type) { Debug.Assert(value is string || type == typeof(string), "invalid call to ChangeTypeForXML"); StorageType destinationType = DataStorage.GetStorageType(type); Type valueType = value.GetType(); StorageType vtype = DataStorage.GetStorageType(valueType); switch (destinationType) { // if destination is not string case StorageType.SqlBinary: return new SqlBinary(Convert.FromBase64String((string)value)); case StorageType.SqlBoolean: return new SqlBoolean(XmlConvert.ToBoolean((string)value)); case StorageType.SqlByte: return new SqlByte(XmlConvert.ToByte((string)value)); case StorageType.SqlBytes: return new SqlBytes(Convert.FromBase64String((string)value)); case StorageType.SqlChars: return new SqlChars(((string)value).ToCharArray()); case StorageType.SqlDateTime: return new SqlDateTime(XmlConvert.ToDateTime((string)value, XmlDateTimeSerializationMode.RoundtripKind)); case StorageType.SqlDecimal: return SqlDecimal.Parse((string)value); // parses invariant format and is larger has larger range then Decimal case StorageType.SqlDouble: return new SqlDouble(XmlConvert.ToDouble((string)value)); case StorageType.SqlGuid: return new SqlGuid(XmlConvert.ToGuid((string)value)); case StorageType.SqlInt16: return new SqlInt16(XmlConvert.ToInt16((string)value)); case StorageType.SqlInt32: return new SqlInt32(XmlConvert.ToInt32((string)value)); case StorageType.SqlInt64: return new SqlInt64(XmlConvert.ToInt64((string)value)); case StorageType.SqlMoney: return new SqlMoney(XmlConvert.ToDecimal((string)value)); case StorageType.SqlSingle: return new SqlSingle(XmlConvert.ToSingle((string)value)); case StorageType.SqlString: return new SqlString((string)value); // case StorageType.SqlXml: // What to do // if (DataStorage.IsObjectNull(value)) { // return SqlXml.Null; // } // goto default; case StorageType.Boolean: if ("1" == (string)value) return true; if ("0" == (string)value) return false; return XmlConvert.ToBoolean((string)value); case StorageType.Char: return XmlConvert.ToChar((string)value); case StorageType.SByte: return XmlConvert.ToSByte((string)value); case StorageType.Byte: return XmlConvert.ToByte((string)value); case StorageType.Int16: return XmlConvert.ToInt16((string)value); case StorageType.UInt16: return XmlConvert.ToUInt16((string)value); case StorageType.Int32: return XmlConvert.ToInt32((string)value); case StorageType.UInt32: return XmlConvert.ToUInt32((string)value); case StorageType.Int64: return XmlConvert.ToInt64((string)value); case StorageType.UInt64: return XmlConvert.ToUInt64((string)value); case StorageType.Single: return XmlConvert.ToSingle((string)value); case StorageType.Double: return XmlConvert.ToDouble((string)value); case StorageType.Decimal: return XmlConvert.ToDecimal((string)value); case StorageType.DateTime: return XmlConvert.ToDateTime((string)value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.Guid: return XmlConvert.ToGuid((string)value); case StorageType.Uri: return new Uri((string)value); case StorageType.DateTimeOffset: return XmlConvert.ToDateTimeOffset((string)value); case StorageType.TimeSpan: return vtype switch { StorageType.String => XmlConvert.ToTimeSpan((string)value), StorageType.Int32 => new TimeSpan((int)value), StorageType.Int64 => new TimeSpan((long)value), _ => (TimeSpan)value, }; default: { if ((DBNull.Value == value) || (null == value)) { return DBNull.Value; } switch (vtype) { // To String case StorageType.SqlBinary: return Convert.ToBase64String(((SqlBinary)value).Value); case StorageType.SqlBoolean: return XmlConvert.ToString(((SqlBoolean)value).Value); case StorageType.SqlByte: return XmlConvert.ToString(((SqlByte)value).Value); case StorageType.SqlBytes: return Convert.ToBase64String(((SqlBytes)value).Value); case StorageType.SqlChars: return new string(((SqlChars)value).Value); case StorageType.SqlDateTime: return XmlConvert.ToString(((SqlDateTime)value).Value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.SqlDecimal: return ((SqlDecimal)value).ToString(); // converts using invariant format and is larger has larger range then Decimal case StorageType.SqlDouble: return XmlConvert.ToString(((SqlDouble)value).Value); case StorageType.SqlGuid: return XmlConvert.ToString(((SqlGuid)value).Value); case StorageType.SqlInt16: return XmlConvert.ToString(((SqlInt16)value).Value); case StorageType.SqlInt32: return XmlConvert.ToString(((SqlInt32)value).Value); case StorageType.SqlInt64: return XmlConvert.ToString(((SqlInt64)value).Value); case StorageType.SqlMoney: return XmlConvert.ToString(((SqlMoney)value).Value); case StorageType.SqlSingle: return XmlConvert.ToString(((SqlSingle)value).Value); case StorageType.SqlString: return ((SqlString)value).Value; case StorageType.Boolean: return XmlConvert.ToString((bool)value); case StorageType.Char: return XmlConvert.ToString((char)value); case StorageType.SByte: return XmlConvert.ToString((sbyte)value); case StorageType.Byte: return XmlConvert.ToString((byte)value); case StorageType.Int16: return XmlConvert.ToString((short)value); case StorageType.UInt16: return XmlConvert.ToString((ushort)value); case StorageType.Int32: return XmlConvert.ToString((int)value); case StorageType.UInt32: return XmlConvert.ToString((uint)value); case StorageType.Int64: return XmlConvert.ToString((long)value); case StorageType.UInt64: return XmlConvert.ToString((ulong)value); case StorageType.Single: return XmlConvert.ToString((float)value); case StorageType.Double: return XmlConvert.ToString((double)value); case StorageType.Decimal: return XmlConvert.ToString((decimal)value); case StorageType.DateTime: return XmlConvert.ToString((DateTime)value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.TimeSpan: return XmlConvert.ToString((TimeSpan)value); case StorageType.Guid: return XmlConvert.ToString((Guid)value); case StorageType.String: return (string)value; case StorageType.CharArray: return new string((char[])value); case StorageType.DateTimeOffset: return XmlConvert.ToString((DateTimeOffset)value); default: IConvertible? iconvertible = (value as IConvertible); if (null != iconvertible) { return iconvertible.ToString(System.Globalization.CultureInfo.InvariantCulture); } // catch additional classes like Guid IFormattable? iformattable = (value as IFormattable); if (null != iformattable) { return iformattable.ToString(null, System.Globalization.CultureInfo.InvariantCulture); } return value.ToString()!; } } } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Data.SqlTypes; using System.Xml; using System.Diagnostics; namespace System.Data.Common { internal static class SqlConvert { public static SqlByte ConvertToSqlByte(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlByte"); if ((value == DBNull.Value)) { // null is not valid, SqlByte is struct return SqlByte.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlByte)), }; } public static SqlInt16 ConvertToSqlInt16(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlInt16"); if (value == DBNull.Value) { return SqlInt16.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.Byte => (byte)value, StorageType.Int16 => (short)value, StorageType.SqlByte => (SqlByte)value, StorageType.SqlInt16 => (SqlInt16)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlInt16)), }; } public static SqlInt32 ConvertToSqlInt32(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlInt32"); if (value == DBNull.Value) { return SqlInt32.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlInt32)), }; } public static SqlInt64 ConvertToSqlInt64(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlInt64"); if (value == DBNull.Value) { return SqlInt32.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlInt64)), }; } public static SqlDouble ConvertToSqlDouble(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlDouble"); if (value == DBNull.Value) { return SqlDouble.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlDouble => (SqlDouble)value, StorageType.Double => (double)value, StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.UInt64 => (ulong)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, StorageType.SqlSingle => (SqlSingle)value, StorageType.Single => (float)value, StorageType.SqlMoney => (SqlMoney)value, StorageType.SqlDecimal => (SqlDecimal)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlDouble)), }; } public static SqlDecimal ConvertToSqlDecimal(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlDecimal"); if (value == DBNull.Value) { return SqlDecimal.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlDecimal => (SqlDecimal)value, StorageType.Decimal => (decimal)value, StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.UInt64 => (ulong)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, StorageType.SqlMoney => (SqlMoney)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlDecimal)), }; } public static SqlSingle ConvertToSqlSingle(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlSingle"); if (value == DBNull.Value) { return SqlSingle.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlSingle => (SqlSingle)value, StorageType.Single => (float)value, StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.UInt64 => (ulong)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, StorageType.SqlMoney => (SqlMoney)value, StorageType.SqlDecimal => (SqlDecimal)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlSingle)), }; } public static SqlMoney ConvertToSqlMoney(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlMoney"); if (value == DBNull.Value) { return SqlMoney.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlMoney => (SqlMoney)value, StorageType.Decimal => (decimal)value, StorageType.SqlInt64 => (SqlInt64)value, StorageType.Int64 => (long)value, StorageType.UInt64 => (ulong)value, StorageType.SqlInt16 => (SqlInt16)value, StorageType.Int16 => (short)value, StorageType.UInt16 => (ushort)value, StorageType.SqlInt32 => (SqlInt32)value, StorageType.Int32 => (int)value, StorageType.UInt32 => (uint)value, StorageType.SqlByte => (SqlByte)value, StorageType.Byte => (byte)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlMoney)), }; } public static SqlDateTime ConvertToSqlDateTime(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlDateTime"); if (value == DBNull.Value) { return SqlDateTime.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlDateTime => (SqlDateTime)value, StorageType.DateTime => (DateTime)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlDateTime)), }; } public static SqlBoolean ConvertToSqlBoolean(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlBoolean"); if ((value == DBNull.Value) || (value == null)) { return SqlBoolean.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlBoolean => (SqlBoolean)value, StorageType.Boolean => (bool)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlBoolean)), }; } public static SqlGuid ConvertToSqlGuid(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlGuid"); if (value == DBNull.Value) { return SqlGuid.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlGuid => (SqlGuid)value, StorageType.Guid => (Guid)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlGuid)), }; } public static SqlBinary ConvertToSqlBinary(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlBinary"); if (value == DBNull.Value) { return SqlBinary.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlBinary => (SqlBinary)value, StorageType.ByteArray => (byte[])value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlBinary)), }; } public static SqlString ConvertToSqlString(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlString"); if ((value == DBNull.Value) || (value == null)) { return SqlString.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlString => (SqlString)value, StorageType.String => (string)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlString)), }; } public static SqlChars ConvertToSqlChars(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlChars"); if (value == DBNull.Value) { return SqlChars.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlChars => (SqlChars)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlChars)), }; } public static SqlBytes ConvertToSqlBytes(object value) { Debug.Assert(value != null, "null argument in ConvertToSqlBytes"); if (value == DBNull.Value) { return SqlBytes.Null; } Type valueType = value.GetType(); StorageType stype = DataStorage.GetStorageType(valueType); return stype switch { StorageType.SqlBytes => (SqlBytes)value, _ => throw ExceptionBuilder.ConvertFailed(valueType, typeof(SqlBytes)), }; } public static DateTimeOffset ConvertStringToDateTimeOffset(string value, IFormatProvider formatProvider) { return DateTimeOffset.Parse(value, formatProvider); } // this should not be called for XmlSerialization public static object ChangeTypeForDefaultValue(object value, Type type, IFormatProvider formatProvider) { if (type == typeof(System.Numerics.BigInteger)) { if ((DBNull.Value == value) || (null == value)) { return DBNull.Value; } return BigIntegerStorage.ConvertToBigInteger(value, formatProvider); } else if (value is System.Numerics.BigInteger) { return BigIntegerStorage.ConvertFromBigInteger((System.Numerics.BigInteger)value, type, formatProvider); } return ChangeType2(value, DataStorage.GetStorageType(type), type, formatProvider); } // this should not be called for XmlSerialization public static object ChangeType2(object value, StorageType stype, Type type, IFormatProvider formatProvider) { switch (stype) { // if destination is SQL type case StorageType.SqlBinary: return (SqlConvert.ConvertToSqlBinary(value)); case StorageType.SqlBoolean: return (SqlConvert.ConvertToSqlBoolean(value)); case StorageType.SqlByte: return (SqlConvert.ConvertToSqlByte(value)); case StorageType.SqlBytes: return (SqlConvert.ConvertToSqlBytes(value)); case StorageType.SqlChars: return (SqlConvert.ConvertToSqlChars(value)); case StorageType.SqlDateTime: return (SqlConvert.ConvertToSqlDateTime(value)); case StorageType.SqlDecimal: return (SqlConvert.ConvertToSqlDecimal(value)); case StorageType.SqlDouble: return (SqlConvert.ConvertToSqlDouble(value)); case StorageType.SqlGuid: return (SqlConvert.ConvertToSqlGuid(value)); case StorageType.SqlInt16: return (SqlConvert.ConvertToSqlInt16(value)); case StorageType.SqlInt32: return (SqlConvert.ConvertToSqlInt32(value)); case StorageType.SqlInt64: return (SqlConvert.ConvertToSqlInt64(value)); case StorageType.SqlMoney: return (SqlConvert.ConvertToSqlMoney(value)); case StorageType.SqlSingle: return (SqlConvert.ConvertToSqlSingle(value)); case StorageType.SqlString: return (SqlConvert.ConvertToSqlString(value)); /* case StorageType.SqlXml: if (DataStorage.IsObjectNull(value)) { return SqlXml.Null; } goto default; */ default: // destination is CLR if ((DBNull.Value == value) || (null == value)) { return DBNull.Value; } Type valueType = value.GetType(); StorageType vtype = DataStorage.GetStorageType(valueType); // destination is CLR switch (vtype) {// and source is SQL type case StorageType.SqlBinary: case StorageType.SqlBoolean: case StorageType.SqlByte: case StorageType.SqlBytes: case StorageType.SqlChars: case StorageType.SqlDateTime: case StorageType.SqlDecimal: case StorageType.SqlDouble: case StorageType.SqlGuid: case StorageType.SqlInt16: case StorageType.SqlInt32: case StorageType.SqlInt64: case StorageType.SqlMoney: case StorageType.SqlSingle: case StorageType.SqlString: throw ExceptionBuilder.ConvertFailed(valueType, type); default: // source is CLR type if (StorageType.String == stype) { // destination is string switch (vtype) { // source's type case StorageType.Boolean: return ((IConvertible)(bool)value).ToString(formatProvider); case StorageType.Char: return ((IConvertible)(char)value).ToString(formatProvider); case StorageType.SByte: return ((sbyte)value).ToString(formatProvider); case StorageType.Byte: return ((byte)value).ToString(formatProvider); case StorageType.Int16: return ((short)value).ToString(formatProvider); case StorageType.UInt16: return ((ushort)value).ToString(formatProvider); case StorageType.Int32: return ((int)value).ToString(formatProvider); case StorageType.UInt32: return ((uint)value).ToString(formatProvider); case StorageType.Int64: return ((long)value).ToString(formatProvider); case StorageType.UInt64: return ((ulong)value).ToString(formatProvider); case StorageType.Single: return ((float)value).ToString(formatProvider); case StorageType.Double: return ((double)value).ToString(formatProvider); case StorageType.Decimal: return ((decimal)value).ToString(formatProvider); case StorageType.DateTime: return ((DateTime)value).ToString(formatProvider); //return XmlConvert.ToString((DateTime) value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.TimeSpan: return XmlConvert.ToString((TimeSpan)value); case StorageType.Guid: return XmlConvert.ToString((Guid)value); case StorageType.String: return (string)value; case StorageType.CharArray: return new string((char[])value); case StorageType.DateTimeOffset: return ((DateTimeOffset)value).ToString(formatProvider); case StorageType.BigInteger: break; default: IConvertible? iconvertible = (value as IConvertible); if (null != iconvertible) { return iconvertible.ToString(formatProvider); } // catch additional classes like Guid IFormattable? iformattable = (value as IFormattable); if (null != iformattable) { return iformattable.ToString(null, formatProvider); } return value.ToString()!; } } else if (StorageType.TimeSpan == stype) { // destination is TimeSpan return vtype switch { StorageType.String => XmlConvert.ToTimeSpan((string)value), StorageType.Int32 => new TimeSpan((int)value), StorageType.Int64 => new TimeSpan((long)value), _ => (TimeSpan)value, }; } else if (StorageType.DateTimeOffset == stype) { // destination is DateTimeOffset return (DateTimeOffset)value; } else if (StorageType.String == vtype) { // if source is string switch (stype) { // type of destination case StorageType.String: return (string)value; case StorageType.Boolean: if ("1" == (string)value) return true; if ("0" == (string)value) return false; break; case StorageType.Char: return ((IConvertible)(string)value).ToChar(formatProvider); case StorageType.SByte: return ((IConvertible)(string)value).ToSByte(formatProvider); case StorageType.Byte: return ((IConvertible)(string)value).ToByte(formatProvider); case StorageType.Int16: return ((IConvertible)(string)value).ToInt16(formatProvider); case StorageType.UInt16: return ((IConvertible)(string)value).ToUInt16(formatProvider); case StorageType.Int32: return ((IConvertible)(string)value).ToInt32(formatProvider); case StorageType.UInt32: return ((IConvertible)(string)value).ToUInt32(formatProvider); case StorageType.Int64: return ((IConvertible)(string)value).ToInt64(formatProvider); case StorageType.UInt64: return ((IConvertible)(string)value).ToUInt64(formatProvider); case StorageType.Single: return ((IConvertible)(string)value).ToSingle(formatProvider); case StorageType.Double: return ((IConvertible)(string)value).ToDouble(formatProvider); case StorageType.Decimal: return ((IConvertible)(string)value).ToDecimal(formatProvider); case StorageType.DateTime: return ((IConvertible)(string)value).ToDateTime(formatProvider); //return XmlConvert.ToDateTime((string) value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.TimeSpan: return XmlConvert.ToTimeSpan((string)value); case StorageType.Guid: return XmlConvert.ToGuid((string)value); case StorageType.Uri: return new Uri((string)value); default: // other clr types, break; } } return Convert.ChangeType(value, type, formatProvider); } } } // this should be called for XmlSerialization public static object ChangeTypeForXML(object value, Type type) { Debug.Assert(value is string || type == typeof(string), "invalid call to ChangeTypeForXML"); StorageType destinationType = DataStorage.GetStorageType(type); Type valueType = value.GetType(); StorageType vtype = DataStorage.GetStorageType(valueType); switch (destinationType) { // if destination is not string case StorageType.SqlBinary: return new SqlBinary(Convert.FromBase64String((string)value)); case StorageType.SqlBoolean: return new SqlBoolean(XmlConvert.ToBoolean((string)value)); case StorageType.SqlByte: return new SqlByte(XmlConvert.ToByte((string)value)); case StorageType.SqlBytes: return new SqlBytes(Convert.FromBase64String((string)value)); case StorageType.SqlChars: return new SqlChars(((string)value).ToCharArray()); case StorageType.SqlDateTime: return new SqlDateTime(XmlConvert.ToDateTime((string)value, XmlDateTimeSerializationMode.RoundtripKind)); case StorageType.SqlDecimal: return SqlDecimal.Parse((string)value); // parses invariant format and is larger has larger range then Decimal case StorageType.SqlDouble: return new SqlDouble(XmlConvert.ToDouble((string)value)); case StorageType.SqlGuid: return new SqlGuid(XmlConvert.ToGuid((string)value)); case StorageType.SqlInt16: return new SqlInt16(XmlConvert.ToInt16((string)value)); case StorageType.SqlInt32: return new SqlInt32(XmlConvert.ToInt32((string)value)); case StorageType.SqlInt64: return new SqlInt64(XmlConvert.ToInt64((string)value)); case StorageType.SqlMoney: return new SqlMoney(XmlConvert.ToDecimal((string)value)); case StorageType.SqlSingle: return new SqlSingle(XmlConvert.ToSingle((string)value)); case StorageType.SqlString: return new SqlString((string)value); // case StorageType.SqlXml: // What to do // if (DataStorage.IsObjectNull(value)) { // return SqlXml.Null; // } // goto default; case StorageType.Boolean: if ("1" == (string)value) return true; if ("0" == (string)value) return false; return XmlConvert.ToBoolean((string)value); case StorageType.Char: return XmlConvert.ToChar((string)value); case StorageType.SByte: return XmlConvert.ToSByte((string)value); case StorageType.Byte: return XmlConvert.ToByte((string)value); case StorageType.Int16: return XmlConvert.ToInt16((string)value); case StorageType.UInt16: return XmlConvert.ToUInt16((string)value); case StorageType.Int32: return XmlConvert.ToInt32((string)value); case StorageType.UInt32: return XmlConvert.ToUInt32((string)value); case StorageType.Int64: return XmlConvert.ToInt64((string)value); case StorageType.UInt64: return XmlConvert.ToUInt64((string)value); case StorageType.Single: return XmlConvert.ToSingle((string)value); case StorageType.Double: return XmlConvert.ToDouble((string)value); case StorageType.Decimal: return XmlConvert.ToDecimal((string)value); case StorageType.DateTime: return XmlConvert.ToDateTime((string)value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.Guid: return XmlConvert.ToGuid((string)value); case StorageType.Uri: return new Uri((string)value); case StorageType.DateTimeOffset: return XmlConvert.ToDateTimeOffset((string)value); case StorageType.TimeSpan: return vtype switch { StorageType.String => XmlConvert.ToTimeSpan((string)value), StorageType.Int32 => new TimeSpan((int)value), StorageType.Int64 => new TimeSpan((long)value), _ => (TimeSpan)value, }; default: { if ((DBNull.Value == value) || (null == value)) { return DBNull.Value; } switch (vtype) { // To String case StorageType.SqlBinary: return Convert.ToBase64String(((SqlBinary)value).Value); case StorageType.SqlBoolean: return XmlConvert.ToString(((SqlBoolean)value).Value); case StorageType.SqlByte: return XmlConvert.ToString(((SqlByte)value).Value); case StorageType.SqlBytes: return Convert.ToBase64String(((SqlBytes)value).Value); case StorageType.SqlChars: return new string(((SqlChars)value).Value); case StorageType.SqlDateTime: return XmlConvert.ToString(((SqlDateTime)value).Value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.SqlDecimal: return ((SqlDecimal)value).ToString(); // converts using invariant format and is larger has larger range then Decimal case StorageType.SqlDouble: return XmlConvert.ToString(((SqlDouble)value).Value); case StorageType.SqlGuid: return XmlConvert.ToString(((SqlGuid)value).Value); case StorageType.SqlInt16: return XmlConvert.ToString(((SqlInt16)value).Value); case StorageType.SqlInt32: return XmlConvert.ToString(((SqlInt32)value).Value); case StorageType.SqlInt64: return XmlConvert.ToString(((SqlInt64)value).Value); case StorageType.SqlMoney: return XmlConvert.ToString(((SqlMoney)value).Value); case StorageType.SqlSingle: return XmlConvert.ToString(((SqlSingle)value).Value); case StorageType.SqlString: return ((SqlString)value).Value; case StorageType.Boolean: return XmlConvert.ToString((bool)value); case StorageType.Char: return XmlConvert.ToString((char)value); case StorageType.SByte: return XmlConvert.ToString((sbyte)value); case StorageType.Byte: return XmlConvert.ToString((byte)value); case StorageType.Int16: return XmlConvert.ToString((short)value); case StorageType.UInt16: return XmlConvert.ToString((ushort)value); case StorageType.Int32: return XmlConvert.ToString((int)value); case StorageType.UInt32: return XmlConvert.ToString((uint)value); case StorageType.Int64: return XmlConvert.ToString((long)value); case StorageType.UInt64: return XmlConvert.ToString((ulong)value); case StorageType.Single: return XmlConvert.ToString((float)value); case StorageType.Double: return XmlConvert.ToString((double)value); case StorageType.Decimal: return XmlConvert.ToString((decimal)value); case StorageType.DateTime: return XmlConvert.ToString((DateTime)value, XmlDateTimeSerializationMode.RoundtripKind); case StorageType.TimeSpan: return XmlConvert.ToString((TimeSpan)value); case StorageType.Guid: return XmlConvert.ToString((Guid)value); case StorageType.String: return (string)value; case StorageType.CharArray: return new string((char[])value); case StorageType.DateTimeOffset: return XmlConvert.ToString((DateTimeOffset)value); default: IConvertible? iconvertible = (value as IConvertible); if (null != iconvertible) { return iconvertible.ToString(System.Globalization.CultureInfo.InvariantCulture); } // catch additional classes like Guid IFormattable? iformattable = (value as IFormattable); if (null != iformattable) { return iformattable.ToString(null, System.Globalization.CultureInfo.InvariantCulture); } return value.ToString()!; } } } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // //NOTE: //Structures containing collection of another structures are defined without //embedded structure which will ensure proper marshalling in case collection //count is zero and there is no embedded structure. Marshalling code read the //embedded structure appropriately for non-zero collection count. // //E.g. //Unmanaged structure DS_REPL_CURSORS_3 is defind as //typedef struct { // DWORD cNumCursors; // DWORD dwEnumerationContext; // DS_REPL_CURSOR_3 rgCursor[1]; //} DS_REPL_CURSORS_3; // //Here it has been defined as (without embedded structure DS_REPL_CURSOR_3) // //internal sealed class DS_REPL_CURSORS_3 //{ // public int cNumCursors; // public int dwEnumerationContext; //} using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; namespace System.DirectoryServices.ActiveDirectory { internal enum DS_REPL_INFO_TYPE { DS_REPL_INFO_NEIGHBORS = 0, DS_REPL_INFO_CURSORS_FOR_NC = 1, DS_REPL_INFO_METADATA_FOR_OBJ = 2, DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES = 3, DS_REPL_INFO_KCC_DSA_LINK_FAILURES = 4, DS_REPL_INFO_PENDING_OPS = 5, DS_REPL_INFO_METADATA_FOR_ATTR_VALUE = 6, DS_REPL_INFO_CURSORS_2_FOR_NC = 7, DS_REPL_INFO_CURSORS_3_FOR_NC = 8, DS_REPL_INFO_METADATA_2_FOR_OBJ = 9, DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE = 10 } public enum ReplicationOperationType { Sync = 0, Add = 1, Delete = 2, Modify = 3, UpdateReference = 4 } internal enum DS_NAME_ERROR { DS_NAME_NO_ERROR = 0, DS_NAME_ERROR_RESOLVING = 1, DS_NAME_ERROR_NOT_FOUND = 2, DS_NAME_ERROR_NOT_UNIQUE = 3, DS_NAME_ERROR_NO_MAPPING = 4, DS_NAME_ERROR_DOMAIN_ONLY = 5, DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6, DS_NAME_ERROR_TRUST_REFERRAL = 7 } [Flags] internal enum DS_DOMAINTRUST_FLAG { DS_DOMAIN_IN_FOREST = 0x0001, DS_DOMAIN_DIRECT_OUTBOUND = 0x0002, DS_DOMAIN_TREE_ROOT = 0x0004, DS_DOMAIN_PRIMARY = 0x0008, DS_DOMAIN_NATIVE_MODE = 0x0010, DS_DOMAIN_DIRECT_INBOUND = 0x0020 } internal enum LSA_FOREST_TRUST_RECORD_TYPE { ForestTrustTopLevelName, ForestTrustTopLevelNameEx, ForestTrustDomainInfo, ForestTrustRecordTypeLast } public enum ForestTrustCollisionType { TopLevelName, Domain, Other } [Flags] public enum TopLevelNameCollisionOptions { None = 0, NewlyCreated = 1, DisabledByAdmin = 2, DisabledByConflict = 4 } [Flags] public enum DomainCollisionOptions { None = 0, SidDisabledByAdmin = 1, SidDisabledByConflict = 2, NetBiosNameDisabledByAdmin = 4, NetBiosNameDisabledByConflict = 8 } /* typedef enum { DsRole_RoleStandaloneWorkstation, DsRole_RoleMemberWorkstation, DsRole_RoleStandaloneServer, DsRole_RoleMemberServer, DsRole_RoleBackupDomainController, DsRole_RolePrimaryDomainController, DsRole_WorkstationWithSharedAccountDomain, DsRole_ServerWithSharedAccountDomain, DsRole_MemberWorkstationWithSharedAccountDomain, DsRole_MemberServerWithSharedAccountDomain }DSROLE_MACHINE_ROLE; */ internal enum DSROLE_MACHINE_ROLE { DsRole_RoleStandaloneWorkstation, DsRole_RoleMemberWorkstation, DsRole_RoleStandaloneServer, DsRole_RoleMemberServer, DsRole_RoleBackupDomainController, DsRole_RolePrimaryDomainController, DsRole_WorkstationWithSharedAccountDomain, DsRole_ServerWithSharedAccountDomain, DsRole_MemberWorkstationWithSharedAccountDomain, DsRole_MemberServerWithSharedAccountDomain } /* typedef enum { DsRolePrimaryDomainInfoBasic, DsRoleUpgradeStatus, DsRoleOperationState, DsRolePrimaryDomainInfoBasicEx }DSROLE_PRIMARY_DOMAIN_INFO_LEVEL; */ internal enum DSROLE_PRIMARY_DOMAIN_INFO_LEVEL { DsRolePrimaryDomainInfoBasic = 1, DsRoleUpgradeStatus = 2, DsRoleOperationState = 3, DsRolePrimaryDomainInfoBasicEx = 4 } [StructLayout(LayoutKind.Sequential)] internal sealed class FileTime { public int lower; public int higher; } [StructLayout(LayoutKind.Sequential)] internal sealed class SystemTime { public ushort wYear; public ushort wMonth; public ushort wDayOfWeek; public ushort wDay; public ushort wHour; public ushort wMinute; public ushort wSecond; public ushort wMilliseconds; } //Without embedded structure DS_REPL_CURSOR_3. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_CURSORS_3 { public int cNumCursors; public int dwEnumerationContext; } //Without embedded structure DS_REPL_CURSOR. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_CURSORS { public int cNumCursors; public int reserved; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_CURSOR_3 { public Guid uuidSourceDsaInvocationID; public long usnAttributeFilter; public long ftimeLastSyncSuccess; public IntPtr pszSourceDsaDN; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_CURSOR { public Guid uuidSourceDsaInvocationID; public long usnAttributeFilter; } //Without embedded structure DS_REPL_OP. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_PENDING_OPS { public long ftimeCurrentOpStarted; public int cNumPendingOps; } [StructLayout(LayoutKind.Sequential, Pack = 4)] internal sealed class DS_REPL_OP { public long ftimeEnqueued; public int ulSerialNumber; public int ulPriority; public ReplicationOperationType OpType; public int ulOptions; public IntPtr pszNamingContext; public IntPtr pszDsaDN; public IntPtr pszDsaAddress; public Guid uuidNamingContextObjGuid; public Guid uuidDsaObjGuid; } //Without embedded structure DS_REPL_NEIGHBOR. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_NEIGHBORS { public int cNumNeighbors; public int dwReserved; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_NEIGHBOR { public IntPtr pszNamingContext; public IntPtr pszSourceDsaDN; public IntPtr pszSourceDsaAddress; public IntPtr pszAsyncIntersiteTransportDN; public int dwReplicaFlags; public int dwReserved; public Guid uuidNamingContextObjGuid; public Guid uuidSourceDsaObjGuid; public Guid uuidSourceDsaInvocationID; public Guid uuidAsyncIntersiteTransportObjGuid; public long usnLastObjChangeSynced; public long usnAttributeFilter; public long ftimeLastSyncSuccess; public long ftimeLastSyncAttempt; public int dwLastSyncResult; public int cNumConsecutiveSyncFailures; } //Without embedded structure DS_REPL_KCC_DSA_FAILURE. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_KCC_DSA_FAILURES { public int cNumEntries; public int dwReserved; } [StructLayout(LayoutKind.Sequential, Pack = 4)] internal sealed class DS_REPL_KCC_DSA_FAILURE { public IntPtr pszDsaDN; public Guid uuidDsaObjGuid; public long ftimeFirstFailure; public int cNumFailures; public int dwLastResult; } //Without embedded structure DS_REPL_ATTR_META_DATA_2. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_OBJ_META_DATA_2 { public int cNumEntries; public int dwReserved; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_ATTR_META_DATA_2 { public IntPtr pszAttributeName; public int dwVersion; // using two int to replace long to prevent managed code packing it public int ftimeLastOriginatingChange1; public int ftimeLastOriginatingChange2; public Guid uuidLastOriginatingDsaInvocationID; public long usnOriginatingChange; public long usnLocalChange; public IntPtr pszLastOriginatingDsaDN; } //Without embedded structure DS_REPL_ATTR_META_DATA. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_OBJ_META_DATA { public int cNumEntries; public int dwReserved; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_ATTR_META_DATA { public IntPtr pszAttributeName; public int dwVersion; // using two int to replace long to prevent managed code packing it public int ftimeLastOriginatingChange1; public int ftimeLastOriginatingChange2; public Guid uuidLastOriginatingDsaInvocationID; public long usnOriginatingChange; public long usnLocalChange; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPSYNCALL_UPDATE { public SyncFromAllServersEvent eventType; public IntPtr pErrInfo; public IntPtr pSync; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPSYNCALL_ERRINFO { public IntPtr pszSvrId; public SyncFromAllServersErrorCategory error; public int dwWin32Err; public IntPtr pszSrcId; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPSYNCALL_SYNC { public IntPtr pszSrcId; public IntPtr pszDstId; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_NAME_RESULT_ITEM { public DS_NAME_ERROR status; public IntPtr pDomain; public IntPtr pName; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_NAME_RESULT { public int cItems; public IntPtr rItems; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_DOMAIN_TRUSTS { public IntPtr NetbiosDomainName; public IntPtr DnsDomainName; public int Flags; public int ParentIndex; public int TrustType; public int TrustAttributes; public IntPtr DomainSid; public Guid DomainGuid; } internal sealed class TrustObject { public string? NetbiosDomainName; public string? DnsDomainName; public int Flags; public int ParentIndex; public TrustType TrustType; public int TrustAttributes; public int OriginalIndex; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_INFORMATION { public int RecordCount; public IntPtr Entries; } [StructLayout(LayoutKind.Explicit)] internal sealed class LSA_FOREST_TRUST_RECORD { [FieldOffset(0)] public int Flags; [FieldOffset(4)] public LSA_FOREST_TRUST_RECORD_TYPE ForestTrustType; [FieldOffset(8)] public LARGE_INTEGER Time = null!; [FieldOffset(16)] public global::Interop.UNICODE_STRING TopLevelName; [FieldOffset(16)] public LSA_FOREST_TRUST_BINARY_DATA Data = null!; [FieldOffset(16)] public LSA_FOREST_TRUST_DOMAIN_INFO? DomainInfo; } [StructLayout(LayoutKind.Sequential)] internal sealed class LARGE_INTEGER { public int lowPart; public int highPart; public LARGE_INTEGER() { lowPart = 0; highPart = 0; } } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_DOMAIN_INFO { public IntPtr sid; public short DNSNameLength; public short DNSNameMaximumLength; public IntPtr DNSNameBuffer; public short NetBIOSNameLength; public short NetBIOSNameMaximumLength; public IntPtr NetBIOSNameBuffer; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_BINARY_DATA { public int Length; public IntPtr Buffer; } [StructLayout(LayoutKind.Sequential)] internal struct TRUSTED_DOMAIN_INFORMATION_EX { public global::Interop.UNICODE_STRING Name; public global::Interop.UNICODE_STRING FlatName; public IntPtr Sid; public int TrustDirection; public int TrustType; public TRUST_ATTRIBUTE TrustAttributes; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_COLLISION_INFORMATION { public int RecordCount; public IntPtr Entries; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_COLLISION_RECORD { public int Index; public ForestTrustCollisionType Type; public int Flags; public global::Interop.UNICODE_STRING Name; } [StructLayout(LayoutKind.Sequential)] internal sealed class NETLOGON_INFO_2 { public int netlog2_flags; // // If NETLOGON_VERIFY_STATUS_RETURNED bit is set in // netlog2_flags, the following field will return // the status of trust verification. Otherwise, // the field will return the status of the secure // channel to the primary domain of the machine // (useful for BDCs only). // public int netlog2_pdc_connection_status; public IntPtr netlog2_trusted_dc_name; public int netlog2_tc_connection_status; } [StructLayout(LayoutKind.Sequential)] internal struct TRUSTED_DOMAIN_AUTH_INFORMATION { public int IncomingAuthInfos; public IntPtr IncomingAuthenticationInformation; public IntPtr IncomingPreviousAuthenticationInformation; public int OutgoingAuthInfos; public IntPtr OutgoingAuthenticationInformation; public IntPtr OutgoingPreviousAuthenticationInformation; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_AUTH_INFORMATION { public LARGE_INTEGER? LastUpdateTime; public int AuthType; public int AuthInfoLength; public IntPtr AuthInfo; } [StructLayout(LayoutKind.Sequential)] internal sealed class POLICY_DNS_DOMAIN_INFO { public global::Interop.UNICODE_STRING Name; public global::Interop.UNICODE_STRING DnsDomainName; public global::Interop.UNICODE_STRING DnsForestName; public Guid DomainGuid; public IntPtr Sid; } [StructLayout(LayoutKind.Sequential)] internal sealed class TRUSTED_POSIX_OFFSET_INFO { internal int Offset; } [StructLayout(LayoutKind.Sequential)] internal sealed class TRUSTED_DOMAIN_FULL_INFORMATION { public TRUSTED_DOMAIN_INFORMATION_EX Information; internal TRUSTED_POSIX_OFFSET_INFO? PosixOffset; public TRUSTED_DOMAIN_AUTH_INFORMATION? AuthInformation; } /* typedef struct _DSROLE_PRIMARY_DOMAIN_INFO_BASIC { DSROLE_MACHINE_ROLE MachineRole; ULONG Flags; LPWSTR DomainNameFlat; LPWSTR DomainNameDns; LPWSTR DomainForestName; GUID DomainGuid; } DSROLE_PRIMARY_DOMAIN_INFO_BASIC, *PDSROLE_PRIMARY_DOMAIN_INFO_BASIC; */ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal sealed class DSROLE_PRIMARY_DOMAIN_INFO_BASIC { public DSROLE_MACHINE_ROLE MachineRole; public uint Flags; [MarshalAs(UnmanagedType.LPWStr)] public string? DomainNameFlat; [MarshalAs(UnmanagedType.LPWStr)] public string? DomainNameDns; [MarshalAs(UnmanagedType.LPWStr)] public string? DomainForestName; public Guid DomainGuid; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct POLICY_ACCOUNT_DOMAIN_INFO { public global::Interop.UNICODE_STRING DomainName; public IntPtr DomainSid; } internal static partial class UnsafeNativeMethods { [GeneratedDllImport(global::Interop.Libraries.Activeds, EntryPoint = "ADsEncodeBinaryData", StringMarshalling = StringMarshalling.Utf16)] public static partial int ADsEncodeBinaryData(byte[] data, int length, ref IntPtr result); [GeneratedDllImport(global::Interop.Libraries.Activeds, EntryPoint = "FreeADsMem")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool FreeADsMem(IntPtr pVoid); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetSiteNameW", StringMarshalling = StringMarshalling.Utf16)] public static partial int DsGetSiteName(string? dcName, ref IntPtr ptr); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsEnumerateDomainTrustsW", StringMarshalling = StringMarshalling.Utf16)] public static partial int DsEnumerateDomainTrustsW(string serverName, int flags, out IntPtr domains, out int count); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "NetApiBufferFree")] public static partial int NetApiBufferFree(IntPtr buffer); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaSetForestTrustInformation")] public static partial uint LsaSetForestTrustInformation(SafeLsaPolicyHandle handle, in global::Interop.UNICODE_STRING target, IntPtr forestTrustInfo, int checkOnly, out IntPtr collisionInfo); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaQueryForestTrustInformation")] public static partial uint LsaQueryForestTrustInformation(SafeLsaPolicyHandle handle, in global::Interop.UNICODE_STRING target, ref IntPtr ForestTrustInfo); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaQueryTrustedDomainInfoByName")] public static partial uint LsaQueryTrustedDomainInfoByName(SafeLsaPolicyHandle handle, in global::Interop.UNICODE_STRING trustedDomain, TRUSTED_INFORMATION_CLASS infoClass, ref IntPtr buffer); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaSetTrustedDomainInfoByName")] public static partial uint LsaSetTrustedDomainInfoByName(SafeLsaPolicyHandle handle, in global::Interop.UNICODE_STRING trustedDomain, TRUSTED_INFORMATION_CLASS infoClass, IntPtr buffer); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaDeleteTrustedDomain")] public static partial uint LsaDeleteTrustedDomain(SafeLsaPolicyHandle handle, IntPtr pSid); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "I_NetLogonControl2", StringMarshalling = StringMarshalling.Utf16)] public static partial int I_NetLogonControl2(string serverName, int FunctionCode, int QueryLevel, IntPtr data, out IntPtr buffer); [GeneratedDllImport(global::Interop.Libraries.Kernel32, EntryPoint = "GetSystemTimeAsFileTime")] public static partial void GetSystemTimeAsFileTime(IntPtr fileTime); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaCreateTrustedDomainEx")] public static partial uint LsaCreateTrustedDomainEx(SafeLsaPolicyHandle handle, in TRUSTED_DOMAIN_INFORMATION_EX domainEx, in TRUSTED_DOMAIN_AUTH_INFORMATION authInfo, int classInfo, out IntPtr domainHandle); [GeneratedDllImport(global::Interop.Libraries.Kernel32, EntryPoint = "OpenThread", SetLastError = true)] public static partial IntPtr OpenThread(uint desiredAccess, [MarshalAs(UnmanagedType.Bool)] bool inheirted, int threadID); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "ImpersonateAnonymousToken", SetLastError = true)] public static partial int ImpersonateAnonymousToken(IntPtr token); [GeneratedDllImport(global::Interop.Libraries.NtDll, EntryPoint = "RtlInitUnicodeString")] public static partial int RtlInitUnicodeString(out global::Interop.UNICODE_STRING result, IntPtr s); /* DWORD DsRoleGetPrimaryDomainInformation( LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, PBYTE* Buffer ); */ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsRoleGetPrimaryDomainInformation", StringMarshalling = StringMarshalling.Utf16)] public static partial int DsRoleGetPrimaryDomainInformation( [MarshalAs(UnmanagedType.LPTStr)] string lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, out IntPtr Buffer); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsRoleGetPrimaryDomainInformation", StringMarshalling = StringMarshalling.Utf16)] public static partial int DsRoleGetPrimaryDomainInformation( IntPtr lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, out IntPtr Buffer); /* void DsRoleFreeMemory( PVOID Buffer ); */ [GeneratedDllImport(global::Interop.Libraries.Netapi32)] public static partial int DsRoleFreeMemory( IntPtr buffer); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // //NOTE: //Structures containing collection of another structures are defined without //embedded structure which will ensure proper marshalling in case collection //count is zero and there is no embedded structure. Marshalling code read the //embedded structure appropriately for non-zero collection count. // //E.g. //Unmanaged structure DS_REPL_CURSORS_3 is defind as //typedef struct { // DWORD cNumCursors; // DWORD dwEnumerationContext; // DS_REPL_CURSOR_3 rgCursor[1]; //} DS_REPL_CURSORS_3; // //Here it has been defined as (without embedded structure DS_REPL_CURSOR_3) // //internal sealed class DS_REPL_CURSORS_3 //{ // public int cNumCursors; // public int dwEnumerationContext; //} using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; namespace System.DirectoryServices.ActiveDirectory { internal enum DS_REPL_INFO_TYPE { DS_REPL_INFO_NEIGHBORS = 0, DS_REPL_INFO_CURSORS_FOR_NC = 1, DS_REPL_INFO_METADATA_FOR_OBJ = 2, DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES = 3, DS_REPL_INFO_KCC_DSA_LINK_FAILURES = 4, DS_REPL_INFO_PENDING_OPS = 5, DS_REPL_INFO_METADATA_FOR_ATTR_VALUE = 6, DS_REPL_INFO_CURSORS_2_FOR_NC = 7, DS_REPL_INFO_CURSORS_3_FOR_NC = 8, DS_REPL_INFO_METADATA_2_FOR_OBJ = 9, DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE = 10 } public enum ReplicationOperationType { Sync = 0, Add = 1, Delete = 2, Modify = 3, UpdateReference = 4 } internal enum DS_NAME_ERROR { DS_NAME_NO_ERROR = 0, DS_NAME_ERROR_RESOLVING = 1, DS_NAME_ERROR_NOT_FOUND = 2, DS_NAME_ERROR_NOT_UNIQUE = 3, DS_NAME_ERROR_NO_MAPPING = 4, DS_NAME_ERROR_DOMAIN_ONLY = 5, DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6, DS_NAME_ERROR_TRUST_REFERRAL = 7 } [Flags] internal enum DS_DOMAINTRUST_FLAG { DS_DOMAIN_IN_FOREST = 0x0001, DS_DOMAIN_DIRECT_OUTBOUND = 0x0002, DS_DOMAIN_TREE_ROOT = 0x0004, DS_DOMAIN_PRIMARY = 0x0008, DS_DOMAIN_NATIVE_MODE = 0x0010, DS_DOMAIN_DIRECT_INBOUND = 0x0020 } internal enum LSA_FOREST_TRUST_RECORD_TYPE { ForestTrustTopLevelName, ForestTrustTopLevelNameEx, ForestTrustDomainInfo, ForestTrustRecordTypeLast } public enum ForestTrustCollisionType { TopLevelName, Domain, Other } [Flags] public enum TopLevelNameCollisionOptions { None = 0, NewlyCreated = 1, DisabledByAdmin = 2, DisabledByConflict = 4 } [Flags] public enum DomainCollisionOptions { None = 0, SidDisabledByAdmin = 1, SidDisabledByConflict = 2, NetBiosNameDisabledByAdmin = 4, NetBiosNameDisabledByConflict = 8 } /* typedef enum { DsRole_RoleStandaloneWorkstation, DsRole_RoleMemberWorkstation, DsRole_RoleStandaloneServer, DsRole_RoleMemberServer, DsRole_RoleBackupDomainController, DsRole_RolePrimaryDomainController, DsRole_WorkstationWithSharedAccountDomain, DsRole_ServerWithSharedAccountDomain, DsRole_MemberWorkstationWithSharedAccountDomain, DsRole_MemberServerWithSharedAccountDomain }DSROLE_MACHINE_ROLE; */ internal enum DSROLE_MACHINE_ROLE { DsRole_RoleStandaloneWorkstation, DsRole_RoleMemberWorkstation, DsRole_RoleStandaloneServer, DsRole_RoleMemberServer, DsRole_RoleBackupDomainController, DsRole_RolePrimaryDomainController, DsRole_WorkstationWithSharedAccountDomain, DsRole_ServerWithSharedAccountDomain, DsRole_MemberWorkstationWithSharedAccountDomain, DsRole_MemberServerWithSharedAccountDomain } /* typedef enum { DsRolePrimaryDomainInfoBasic, DsRoleUpgradeStatus, DsRoleOperationState, DsRolePrimaryDomainInfoBasicEx }DSROLE_PRIMARY_DOMAIN_INFO_LEVEL; */ internal enum DSROLE_PRIMARY_DOMAIN_INFO_LEVEL { DsRolePrimaryDomainInfoBasic = 1, DsRoleUpgradeStatus = 2, DsRoleOperationState = 3, DsRolePrimaryDomainInfoBasicEx = 4 } [StructLayout(LayoutKind.Sequential)] internal sealed class FileTime { public int lower; public int higher; } [StructLayout(LayoutKind.Sequential)] internal sealed class SystemTime { public ushort wYear; public ushort wMonth; public ushort wDayOfWeek; public ushort wDay; public ushort wHour; public ushort wMinute; public ushort wSecond; public ushort wMilliseconds; } //Without embedded structure DS_REPL_CURSOR_3. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_CURSORS_3 { public int cNumCursors; public int dwEnumerationContext; } //Without embedded structure DS_REPL_CURSOR. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_CURSORS { public int cNumCursors; public int reserved; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_CURSOR_3 { public Guid uuidSourceDsaInvocationID; public long usnAttributeFilter; public long ftimeLastSyncSuccess; public IntPtr pszSourceDsaDN; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_CURSOR { public Guid uuidSourceDsaInvocationID; public long usnAttributeFilter; } //Without embedded structure DS_REPL_OP. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_PENDING_OPS { public long ftimeCurrentOpStarted; public int cNumPendingOps; } [StructLayout(LayoutKind.Sequential, Pack = 4)] internal sealed class DS_REPL_OP { public long ftimeEnqueued; public int ulSerialNumber; public int ulPriority; public ReplicationOperationType OpType; public int ulOptions; public IntPtr pszNamingContext; public IntPtr pszDsaDN; public IntPtr pszDsaAddress; public Guid uuidNamingContextObjGuid; public Guid uuidDsaObjGuid; } //Without embedded structure DS_REPL_NEIGHBOR. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_NEIGHBORS { public int cNumNeighbors; public int dwReserved; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_NEIGHBOR { public IntPtr pszNamingContext; public IntPtr pszSourceDsaDN; public IntPtr pszSourceDsaAddress; public IntPtr pszAsyncIntersiteTransportDN; public int dwReplicaFlags; public int dwReserved; public Guid uuidNamingContextObjGuid; public Guid uuidSourceDsaObjGuid; public Guid uuidSourceDsaInvocationID; public Guid uuidAsyncIntersiteTransportObjGuid; public long usnLastObjChangeSynced; public long usnAttributeFilter; public long ftimeLastSyncSuccess; public long ftimeLastSyncAttempt; public int dwLastSyncResult; public int cNumConsecutiveSyncFailures; } //Without embedded structure DS_REPL_KCC_DSA_FAILURE. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_KCC_DSA_FAILURES { public int cNumEntries; public int dwReserved; } [StructLayout(LayoutKind.Sequential, Pack = 4)] internal sealed class DS_REPL_KCC_DSA_FAILURE { public IntPtr pszDsaDN; public Guid uuidDsaObjGuid; public long ftimeFirstFailure; public int cNumFailures; public int dwLastResult; } //Without embedded structure DS_REPL_ATTR_META_DATA_2. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_OBJ_META_DATA_2 { public int cNumEntries; public int dwReserved; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_ATTR_META_DATA_2 { public IntPtr pszAttributeName; public int dwVersion; // using two int to replace long to prevent managed code packing it public int ftimeLastOriginatingChange1; public int ftimeLastOriginatingChange2; public Guid uuidLastOriginatingDsaInvocationID; public long usnOriginatingChange; public long usnLocalChange; public IntPtr pszLastOriginatingDsaDN; } //Without embedded structure DS_REPL_ATTR_META_DATA. //See NOTE at the top of this file for more details [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_OBJ_META_DATA { public int cNumEntries; public int dwReserved; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPL_ATTR_META_DATA { public IntPtr pszAttributeName; public int dwVersion; // using two int to replace long to prevent managed code packing it public int ftimeLastOriginatingChange1; public int ftimeLastOriginatingChange2; public Guid uuidLastOriginatingDsaInvocationID; public long usnOriginatingChange; public long usnLocalChange; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPSYNCALL_UPDATE { public SyncFromAllServersEvent eventType; public IntPtr pErrInfo; public IntPtr pSync; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPSYNCALL_ERRINFO { public IntPtr pszSvrId; public SyncFromAllServersErrorCategory error; public int dwWin32Err; public IntPtr pszSrcId; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_REPSYNCALL_SYNC { public IntPtr pszSrcId; public IntPtr pszDstId; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_NAME_RESULT_ITEM { public DS_NAME_ERROR status; public IntPtr pDomain; public IntPtr pName; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_NAME_RESULT { public int cItems; public IntPtr rItems; } [StructLayout(LayoutKind.Sequential)] internal sealed class DS_DOMAIN_TRUSTS { public IntPtr NetbiosDomainName; public IntPtr DnsDomainName; public int Flags; public int ParentIndex; public int TrustType; public int TrustAttributes; public IntPtr DomainSid; public Guid DomainGuid; } internal sealed class TrustObject { public string? NetbiosDomainName; public string? DnsDomainName; public int Flags; public int ParentIndex; public TrustType TrustType; public int TrustAttributes; public int OriginalIndex; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_INFORMATION { public int RecordCount; public IntPtr Entries; } [StructLayout(LayoutKind.Explicit)] internal sealed class LSA_FOREST_TRUST_RECORD { [FieldOffset(0)] public int Flags; [FieldOffset(4)] public LSA_FOREST_TRUST_RECORD_TYPE ForestTrustType; [FieldOffset(8)] public LARGE_INTEGER Time = null!; [FieldOffset(16)] public global::Interop.UNICODE_STRING TopLevelName; [FieldOffset(16)] public LSA_FOREST_TRUST_BINARY_DATA Data = null!; [FieldOffset(16)] public LSA_FOREST_TRUST_DOMAIN_INFO? DomainInfo; } [StructLayout(LayoutKind.Sequential)] internal sealed class LARGE_INTEGER { public int lowPart; public int highPart; public LARGE_INTEGER() { lowPart = 0; highPart = 0; } } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_DOMAIN_INFO { public IntPtr sid; public short DNSNameLength; public short DNSNameMaximumLength; public IntPtr DNSNameBuffer; public short NetBIOSNameLength; public short NetBIOSNameMaximumLength; public IntPtr NetBIOSNameBuffer; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_BINARY_DATA { public int Length; public IntPtr Buffer; } [StructLayout(LayoutKind.Sequential)] internal struct TRUSTED_DOMAIN_INFORMATION_EX { public global::Interop.UNICODE_STRING Name; public global::Interop.UNICODE_STRING FlatName; public IntPtr Sid; public int TrustDirection; public int TrustType; public TRUST_ATTRIBUTE TrustAttributes; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_COLLISION_INFORMATION { public int RecordCount; public IntPtr Entries; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_FOREST_TRUST_COLLISION_RECORD { public int Index; public ForestTrustCollisionType Type; public int Flags; public global::Interop.UNICODE_STRING Name; } [StructLayout(LayoutKind.Sequential)] internal sealed class NETLOGON_INFO_2 { public int netlog2_flags; // // If NETLOGON_VERIFY_STATUS_RETURNED bit is set in // netlog2_flags, the following field will return // the status of trust verification. Otherwise, // the field will return the status of the secure // channel to the primary domain of the machine // (useful for BDCs only). // public int netlog2_pdc_connection_status; public IntPtr netlog2_trusted_dc_name; public int netlog2_tc_connection_status; } [StructLayout(LayoutKind.Sequential)] internal struct TRUSTED_DOMAIN_AUTH_INFORMATION { public int IncomingAuthInfos; public IntPtr IncomingAuthenticationInformation; public IntPtr IncomingPreviousAuthenticationInformation; public int OutgoingAuthInfos; public IntPtr OutgoingAuthenticationInformation; public IntPtr OutgoingPreviousAuthenticationInformation; } [StructLayout(LayoutKind.Sequential)] internal sealed class LSA_AUTH_INFORMATION { public LARGE_INTEGER? LastUpdateTime; public int AuthType; public int AuthInfoLength; public IntPtr AuthInfo; } [StructLayout(LayoutKind.Sequential)] internal sealed class POLICY_DNS_DOMAIN_INFO { public global::Interop.UNICODE_STRING Name; public global::Interop.UNICODE_STRING DnsDomainName; public global::Interop.UNICODE_STRING DnsForestName; public Guid DomainGuid; public IntPtr Sid; } [StructLayout(LayoutKind.Sequential)] internal sealed class TRUSTED_POSIX_OFFSET_INFO { internal int Offset; } [StructLayout(LayoutKind.Sequential)] internal sealed class TRUSTED_DOMAIN_FULL_INFORMATION { public TRUSTED_DOMAIN_INFORMATION_EX Information; internal TRUSTED_POSIX_OFFSET_INFO? PosixOffset; public TRUSTED_DOMAIN_AUTH_INFORMATION? AuthInformation; } /* typedef struct _DSROLE_PRIMARY_DOMAIN_INFO_BASIC { DSROLE_MACHINE_ROLE MachineRole; ULONG Flags; LPWSTR DomainNameFlat; LPWSTR DomainNameDns; LPWSTR DomainForestName; GUID DomainGuid; } DSROLE_PRIMARY_DOMAIN_INFO_BASIC, *PDSROLE_PRIMARY_DOMAIN_INFO_BASIC; */ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal sealed class DSROLE_PRIMARY_DOMAIN_INFO_BASIC { public DSROLE_MACHINE_ROLE MachineRole; public uint Flags; [MarshalAs(UnmanagedType.LPWStr)] public string? DomainNameFlat; [MarshalAs(UnmanagedType.LPWStr)] public string? DomainNameDns; [MarshalAs(UnmanagedType.LPWStr)] public string? DomainForestName; public Guid DomainGuid; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct POLICY_ACCOUNT_DOMAIN_INFO { public global::Interop.UNICODE_STRING DomainName; public IntPtr DomainSid; } internal static partial class UnsafeNativeMethods { [GeneratedDllImport(global::Interop.Libraries.Activeds, EntryPoint = "ADsEncodeBinaryData", StringMarshalling = StringMarshalling.Utf16)] public static partial int ADsEncodeBinaryData(byte[] data, int length, ref IntPtr result); [GeneratedDllImport(global::Interop.Libraries.Activeds, EntryPoint = "FreeADsMem")] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool FreeADsMem(IntPtr pVoid); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsGetSiteNameW", StringMarshalling = StringMarshalling.Utf16)] public static partial int DsGetSiteName(string? dcName, ref IntPtr ptr); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsEnumerateDomainTrustsW", StringMarshalling = StringMarshalling.Utf16)] public static partial int DsEnumerateDomainTrustsW(string serverName, int flags, out IntPtr domains, out int count); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "NetApiBufferFree")] public static partial int NetApiBufferFree(IntPtr buffer); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaSetForestTrustInformation")] public static partial uint LsaSetForestTrustInformation(SafeLsaPolicyHandle handle, in global::Interop.UNICODE_STRING target, IntPtr forestTrustInfo, int checkOnly, out IntPtr collisionInfo); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaQueryForestTrustInformation")] public static partial uint LsaQueryForestTrustInformation(SafeLsaPolicyHandle handle, in global::Interop.UNICODE_STRING target, ref IntPtr ForestTrustInfo); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaQueryTrustedDomainInfoByName")] public static partial uint LsaQueryTrustedDomainInfoByName(SafeLsaPolicyHandle handle, in global::Interop.UNICODE_STRING trustedDomain, TRUSTED_INFORMATION_CLASS infoClass, ref IntPtr buffer); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaSetTrustedDomainInfoByName")] public static partial uint LsaSetTrustedDomainInfoByName(SafeLsaPolicyHandle handle, in global::Interop.UNICODE_STRING trustedDomain, TRUSTED_INFORMATION_CLASS infoClass, IntPtr buffer); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaDeleteTrustedDomain")] public static partial uint LsaDeleteTrustedDomain(SafeLsaPolicyHandle handle, IntPtr pSid); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "I_NetLogonControl2", StringMarshalling = StringMarshalling.Utf16)] public static partial int I_NetLogonControl2(string serverName, int FunctionCode, int QueryLevel, IntPtr data, out IntPtr buffer); [GeneratedDllImport(global::Interop.Libraries.Kernel32, EntryPoint = "GetSystemTimeAsFileTime")] public static partial void GetSystemTimeAsFileTime(IntPtr fileTime); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "LsaCreateTrustedDomainEx")] public static partial uint LsaCreateTrustedDomainEx(SafeLsaPolicyHandle handle, in TRUSTED_DOMAIN_INFORMATION_EX domainEx, in TRUSTED_DOMAIN_AUTH_INFORMATION authInfo, int classInfo, out IntPtr domainHandle); [GeneratedDllImport(global::Interop.Libraries.Kernel32, EntryPoint = "OpenThread", SetLastError = true)] public static partial IntPtr OpenThread(uint desiredAccess, [MarshalAs(UnmanagedType.Bool)] bool inheirted, int threadID); [GeneratedDllImport(global::Interop.Libraries.Advapi32, EntryPoint = "ImpersonateAnonymousToken", SetLastError = true)] public static partial int ImpersonateAnonymousToken(IntPtr token); [GeneratedDllImport(global::Interop.Libraries.NtDll, EntryPoint = "RtlInitUnicodeString")] public static partial int RtlInitUnicodeString(out global::Interop.UNICODE_STRING result, IntPtr s); /* DWORD DsRoleGetPrimaryDomainInformation( LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, PBYTE* Buffer ); */ [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsRoleGetPrimaryDomainInformation", StringMarshalling = StringMarshalling.Utf16)] public static partial int DsRoleGetPrimaryDomainInformation( [MarshalAs(UnmanagedType.LPTStr)] string lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, out IntPtr Buffer); [GeneratedDllImport(global::Interop.Libraries.Netapi32, EntryPoint = "DsRoleGetPrimaryDomainInformation", StringMarshalling = StringMarshalling.Utf16)] public static partial int DsRoleGetPrimaryDomainInformation( IntPtr lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, out IntPtr Buffer); /* void DsRoleFreeMemory( PVOID Buffer ); */ [GeneratedDllImport(global::Interop.Libraries.Netapi32)] public static partial int DsRoleFreeMemory( IntPtr buffer); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Speech/src/Internal/SrgsCompiler/Item.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.Speech.Internal.SrgsParser; namespace System.Speech.Internal.SrgsCompiler { internal sealed class Item : ParseElementCollection, IItem { #region Constructors internal Item(Backend backend, Rule rule, int minRepeat, int maxRepeat, float repeatProbability, float weigth) : base(backend, rule) { // Validated by the caller _minRepeat = minRepeat; _maxRepeat = maxRepeat; _repeatProbability = repeatProbability; } #endregion #region Internal Method /// <summary> /// Process the '/item' element. /// </summary> void IElement.PostParse(IElement parentElement) { // Special case of no words but only tags. Returns an error as the result is ambiguous // <tag>var res= 1;</tag> // <item repeat="2-2"> // <tag>res= res * 2;</tag> // </item> // Should the result be 2 or 4 if (_maxRepeat != _minRepeat && _startArc != null && _startArc == _endArc && _endArc.IsEpsilonTransition && !_endArc.IsPropertylessTransition) { XmlParser.ThrowSrgsException((SRID.InvalidTagInAnEmptyItem)); } // empty <item> or repeat count == 0 if (_startArc == null || _maxRepeat == 0) { // Special Case: _maxRepeat = 0 => Epsilon transition. if (_maxRepeat == 0 && _startArc != null && _startArc.End != null) { // Delete contents of Item. Otherwise, we will end up with states disconnected to the rest of the rule. State endState = _startArc.End; _startArc.End = null; _backend.DeleteSubGraph(endState); } // empty item, just add an epsilon transition. _startArc = _endArc = _backend.EpsilonTransition(_repeatProbability); } else { // Hard case if repeat count is not one if (_minRepeat != 1 || _maxRepeat != 1) { // Duplicate the states/transitions graph as many times as repeat count //Add a state before the start to be able to duplicate the graph _startArc = InsertState(_startArc, _repeatProbability, Position.Before); State startState = _startArc.End; // If _maxRepeat = Infinite, add epsilon transition loop back to the start of this if (_maxRepeat == int.MaxValue && _minRepeat == 1) { _endArc = InsertState(_endArc, 1.0f, Position.After); AddEpsilonTransition(_endArc.Start, startState, 1 - _repeatProbability); } else { State currentStartState = startState; // For each additional repeat count, clone a new subgraph and connect with appropriate transitions. for (uint cnt = 1; cnt < _maxRepeat && cnt < 255; cnt++) { // Prepare to clone a new subgraph matching the <item> content. State newStartState = _backend.CreateNewState(_endArc.Start.Rule); // Clone subgraphs and update CurrentEndState. State newEndState = _backend.CloneSubGraph(currentStartState, _endArc.Start, newStartState); // Connect the last state with the first state //_endArc.Start.OutArcs.Add (_endArc); _endArc.End = newStartState; // reset the _endArc System.Diagnostics.Debug.Assert(newEndState.OutArcs.CountIsOne && Arc.CompareContent(_endArc, newEndState.OutArcs.First) == 0); _endArc = newEndState.OutArcs.First; if (_maxRepeat == int.MaxValue) { // If we are beyond _minRepeat, add epsilon transition from startState with (1-_repeatProbability). if (cnt == _minRepeat - 1) { // Create a new state and attach the last Arc to add _endArc = InsertState(_endArc, 1.0f, Position.After); AddEpsilonTransition(_endArc.Start, newStartState, 1 - _repeatProbability); break; } } else if (cnt <= _maxRepeat - _minRepeat) { // If we are beyond _minRepeat, add epsilon transition from startState with (1-_repeatProbability). AddEpsilonTransition(startState, newStartState, 1 - _repeatProbability); } // reset the current start state currentStartState = newStartState; } } // If _minRepeat == 0, add epsilon transition from currentEndState to FinalState with (1-_repeatProbability). // but do not do it if the only transition is an epsilon if (_minRepeat == 0 && (_startArc != _endArc || !_startArc.IsEpsilonTransition)) { if (!_endArc.IsEpsilonTransition || _endArc.SemanticTagCount > 0) { _endArc = InsertState(_endArc, 1.0f, Position.After); } AddEpsilonTransition(startState, _endArc.Start, 1 - _repeatProbability); } // Remove the added startState if possible _startArc = TrimStart(_startArc, _backend); } } // Add this item to the parent list base.PostParse((ParseElementCollection)parentElement); } #endregion #region Private Methods private void AddEpsilonTransition(State start, State end, float weight) { Arc epsilon = _backend.EpsilonTransition(weight); epsilon.Start = start; epsilon.End = end; } #endregion #region Private Fields private float _repeatProbability = 0.5f; private int _minRepeat = NotSet; private int _maxRepeat = NotSet; private const int NotSet = -1; #endregion } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Speech.Internal.SrgsParser; namespace System.Speech.Internal.SrgsCompiler { internal sealed class Item : ParseElementCollection, IItem { #region Constructors internal Item(Backend backend, Rule rule, int minRepeat, int maxRepeat, float repeatProbability, float weigth) : base(backend, rule) { // Validated by the caller _minRepeat = minRepeat; _maxRepeat = maxRepeat; _repeatProbability = repeatProbability; } #endregion #region Internal Method /// <summary> /// Process the '/item' element. /// </summary> void IElement.PostParse(IElement parentElement) { // Special case of no words but only tags. Returns an error as the result is ambiguous // <tag>var res= 1;</tag> // <item repeat="2-2"> // <tag>res= res * 2;</tag> // </item> // Should the result be 2 or 4 if (_maxRepeat != _minRepeat && _startArc != null && _startArc == _endArc && _endArc.IsEpsilonTransition && !_endArc.IsPropertylessTransition) { XmlParser.ThrowSrgsException((SRID.InvalidTagInAnEmptyItem)); } // empty <item> or repeat count == 0 if (_startArc == null || _maxRepeat == 0) { // Special Case: _maxRepeat = 0 => Epsilon transition. if (_maxRepeat == 0 && _startArc != null && _startArc.End != null) { // Delete contents of Item. Otherwise, we will end up with states disconnected to the rest of the rule. State endState = _startArc.End; _startArc.End = null; _backend.DeleteSubGraph(endState); } // empty item, just add an epsilon transition. _startArc = _endArc = _backend.EpsilonTransition(_repeatProbability); } else { // Hard case if repeat count is not one if (_minRepeat != 1 || _maxRepeat != 1) { // Duplicate the states/transitions graph as many times as repeat count //Add a state before the start to be able to duplicate the graph _startArc = InsertState(_startArc, _repeatProbability, Position.Before); State startState = _startArc.End; // If _maxRepeat = Infinite, add epsilon transition loop back to the start of this if (_maxRepeat == int.MaxValue && _minRepeat == 1) { _endArc = InsertState(_endArc, 1.0f, Position.After); AddEpsilonTransition(_endArc.Start, startState, 1 - _repeatProbability); } else { State currentStartState = startState; // For each additional repeat count, clone a new subgraph and connect with appropriate transitions. for (uint cnt = 1; cnt < _maxRepeat && cnt < 255; cnt++) { // Prepare to clone a new subgraph matching the <item> content. State newStartState = _backend.CreateNewState(_endArc.Start.Rule); // Clone subgraphs and update CurrentEndState. State newEndState = _backend.CloneSubGraph(currentStartState, _endArc.Start, newStartState); // Connect the last state with the first state //_endArc.Start.OutArcs.Add (_endArc); _endArc.End = newStartState; // reset the _endArc System.Diagnostics.Debug.Assert(newEndState.OutArcs.CountIsOne && Arc.CompareContent(_endArc, newEndState.OutArcs.First) == 0); _endArc = newEndState.OutArcs.First; if (_maxRepeat == int.MaxValue) { // If we are beyond _minRepeat, add epsilon transition from startState with (1-_repeatProbability). if (cnt == _minRepeat - 1) { // Create a new state and attach the last Arc to add _endArc = InsertState(_endArc, 1.0f, Position.After); AddEpsilonTransition(_endArc.Start, newStartState, 1 - _repeatProbability); break; } } else if (cnt <= _maxRepeat - _minRepeat) { // If we are beyond _minRepeat, add epsilon transition from startState with (1-_repeatProbability). AddEpsilonTransition(startState, newStartState, 1 - _repeatProbability); } // reset the current start state currentStartState = newStartState; } } // If _minRepeat == 0, add epsilon transition from currentEndState to FinalState with (1-_repeatProbability). // but do not do it if the only transition is an epsilon if (_minRepeat == 0 && (_startArc != _endArc || !_startArc.IsEpsilonTransition)) { if (!_endArc.IsEpsilonTransition || _endArc.SemanticTagCount > 0) { _endArc = InsertState(_endArc, 1.0f, Position.After); } AddEpsilonTransition(startState, _endArc.Start, 1 - _repeatProbability); } // Remove the added startState if possible _startArc = TrimStart(_startArc, _backend); } } // Add this item to the parent list base.PostParse((ParseElementCollection)parentElement); } #endregion #region Private Methods private void AddEpsilonTransition(State start, State end, float weight) { Arc epsilon = _backend.EpsilonTransition(weight); epsilon.Start = start; epsilon.End = end; } #endregion #region Private Fields private float _repeatProbability = 0.5f; private int _minRepeat = NotSet; private int _maxRepeat = NotSet; private const int NotSet = -1; #endregion } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/Microsoft.Extensions.Logging/tests/Common/TestLoggerExtensions.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.Test { public static class TestLoggerExtensions { public class ScopeWithoutAnyParameters { public static Func<ILogger, IDisposable> ScopeDelegate; public const string Message = "Order creation started."; public const string OriginalFormat = Message; static ScopeWithoutAnyParameters() { ScopeDelegate = LoggerMessage.DefineScope(Message); } } public class ActionMatchedInfo { public static Action<ILogger, string, string, Exception> MessageDelegate; public const string NamedStringFormat = "Request matched controller '{controller}' and action '{action}'."; public const string FormatString = "Request matched controller '{0}' and action '{1}'."; static ActionMatchedInfo() { MessageDelegate = LoggerMessage.Define<string, string>( LogLevel.Information, eventId: 1, formatString: NamedStringFormat); } } public class ScopeWithOneParameter { public static Func<ILogger, string, IDisposable> ScopeDelegate; public const string NamedStringFormat = "RequestId: {RequestId}"; public const string FormatString = "RequestId: {0}"; static ScopeWithOneParameter() { ScopeDelegate = LoggerMessage.DefineScope<string>(NamedStringFormat); } } public class ScopeInfoWithTwoParameters { public static Func<ILogger, string, string, IDisposable> ScopeDelegate; public const string NamedStringFormat = "{param1}, {param2}"; public const string FormatString = "{0}, {1}"; static ScopeInfoWithTwoParameters() { ScopeDelegate = LoggerMessage.DefineScope<string, string>(NamedStringFormat); } } public class ScopeInfoWithThreeParameters { public static Func<ILogger, string, string, int, IDisposable> ScopeDelegate; public const string NamedStringFormat = "{param1}, {param2}, {param3}"; public const string FormatString = "{0}, {1}, {2}"; static ScopeInfoWithThreeParameters() { ScopeDelegate = LoggerMessage.DefineScope<string, string, int>(NamedStringFormat); } } public static void ActionMatched( this ILogger logger, string controller, string action, Exception exception = null) { ActionMatchedInfo.MessageDelegate(logger, controller, action, exception); } public static IDisposable ScopeWithoutAnyParams(this ILogger logger) { return ScopeWithoutAnyParameters.ScopeDelegate(logger); } public static IDisposable ScopeWithOneParam(this ILogger logger, string requestId) { return ScopeWithOneParameter.ScopeDelegate(logger, requestId); } public static IDisposable ScopeWithTwoParams(this ILogger logger, string param1, string param2) { return ScopeInfoWithTwoParameters.ScopeDelegate(logger, param1, param2); } public static IDisposable ScopeWithThreeParams(this ILogger logger, string param1, string param2, int param3) { return ScopeInfoWithThreeParameters.ScopeDelegate(logger, param1, param2, param3); } } }
// 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.Test { public static class TestLoggerExtensions { public class ScopeWithoutAnyParameters { public static Func<ILogger, IDisposable> ScopeDelegate; public const string Message = "Order creation started."; public const string OriginalFormat = Message; static ScopeWithoutAnyParameters() { ScopeDelegate = LoggerMessage.DefineScope(Message); } } public class ActionMatchedInfo { public static Action<ILogger, string, string, Exception> MessageDelegate; public const string NamedStringFormat = "Request matched controller '{controller}' and action '{action}'."; public const string FormatString = "Request matched controller '{0}' and action '{1}'."; static ActionMatchedInfo() { MessageDelegate = LoggerMessage.Define<string, string>( LogLevel.Information, eventId: 1, formatString: NamedStringFormat); } } public class ScopeWithOneParameter { public static Func<ILogger, string, IDisposable> ScopeDelegate; public const string NamedStringFormat = "RequestId: {RequestId}"; public const string FormatString = "RequestId: {0}"; static ScopeWithOneParameter() { ScopeDelegate = LoggerMessage.DefineScope<string>(NamedStringFormat); } } public class ScopeInfoWithTwoParameters { public static Func<ILogger, string, string, IDisposable> ScopeDelegate; public const string NamedStringFormat = "{param1}, {param2}"; public const string FormatString = "{0}, {1}"; static ScopeInfoWithTwoParameters() { ScopeDelegate = LoggerMessage.DefineScope<string, string>(NamedStringFormat); } } public class ScopeInfoWithThreeParameters { public static Func<ILogger, string, string, int, IDisposable> ScopeDelegate; public const string NamedStringFormat = "{param1}, {param2}, {param3}"; public const string FormatString = "{0}, {1}, {2}"; static ScopeInfoWithThreeParameters() { ScopeDelegate = LoggerMessage.DefineScope<string, string, int>(NamedStringFormat); } } public static void ActionMatched( this ILogger logger, string controller, string action, Exception exception = null) { ActionMatchedInfo.MessageDelegate(logger, controller, action, exception); } public static IDisposable ScopeWithoutAnyParams(this ILogger logger) { return ScopeWithoutAnyParameters.ScopeDelegate(logger); } public static IDisposable ScopeWithOneParam(this ILogger logger, string requestId) { return ScopeWithOneParameter.ScopeDelegate(logger, requestId); } public static IDisposable ScopeWithTwoParams(this ILogger logger, string param1, string param2) { return ScopeInfoWithTwoParameters.ScopeDelegate(logger, param1, param2); } public static IDisposable ScopeWithThreeParams(this ILogger logger, string param1, string param2, int param3) { return ScopeInfoWithThreeParameters.ScopeDelegate(logger, param1, param2, param3); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/mono/mono/tests/verifier/valid_merge_first_value_is_base_type.cs
using System; using System.Reflection; using System.Reflection.Emit; public class Parent { } public class Foo : Parent { } public class Bar : Parent { } class Driver { public static int Main (string[] args) { Parent p; Parent f = new Parent(); Bar b = new Bar(); p = args == null? (Parent) f : (Parent) b; return 1; } }
using System; using System.Reflection; using System.Reflection.Emit; public class Parent { } public class Foo : Parent { } public class Bar : Parent { } class Driver { public static int Main (string[] args) { Parent p; Parent f = new Parent(); Bar b = new Bar(); p = args == null? (Parent) f : (Parent) b; return 1; } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Methodical/Arrays/lcs/lcs2.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 JitTest { internal class LCS { private const int RANK = 4; private static String buildLCS(int[][][][] b, char[] X, int[] ind) { for (int i = 0; i < RANK; i++) if (ind[i] == 0) return ""; int L = b[ind[0]][ind[1]][ind[2]][ind[3]]; if (L == RANK) { for (int i = 0; i < RANK; i++) ind[i]--; int idx = ind[0]; return buildLCS(b, X, ind) + X[idx]; } if (L >= 0 && L < RANK) { ind[L]--; return buildLCS(b, X, ind); } throw new Exception(); } private static void findLCS(ref int[][][][] c, ref int[][][][] b, ref char[][] seq, ref int[] len) { int[] ind = new int[RANK]; for (ind[0] = 1; ind[0] < len[0]; ind[0]++) { for (ind[1] = 1; ind[1] < len[1]; ind[1]++) { for (ind[2] = 1; ind[2] < len[2]; ind[2]++) { for (ind[3] = 1; ind[3] < len[3]; ind[3]++) { bool eqFlag = true; for (int i = 1; i < RANK; i++) { if (seq[i][ind[i] - 1] != seq[i - 1][ind[i - 1] - 1]) { eqFlag = false; break; } } if (eqFlag) { c[ind[0]][ind[1]][ind[2]][ind[3]] = c[ind[0] - 1][ind[1] - 1][ind[2] - 1][ind[3] - 1] + 1; b[ind[0]][ind[1]][ind[2]][ind[3]] = RANK; continue; } int R = -1; int M = -1; for (int i = 0; i < RANK; i++) { ind[i]--; if (c[ind[0]][ind[1]][ind[2]][ind[3]] > M) { R = i; M = c[ind[0]][ind[1]][ind[2]][ind[3]]; } ind[i]++; } if (R < 0 || M < 0) throw new Exception(); c[ind[0]][ind[1]][ind[2]][ind[3]] = M; b[ind[0]][ind[1]][ind[2]][ind[3]] = R; } } } } } private static int Main() { Console.WriteLine("Test searches for longest common subsequence of 4 strings\n\n"); String[] str = { "The Sun has left his blackness", "and has found a fresher morning", "and the fair Moon rejoices", "in the clear and cloudless night" }; int[] len = new int[RANK]; char[][] seq = new char[RANK][]; for (int i = 0; i < RANK; i++) { len[i] = str[i].Length + 1; seq[i] = str[i].ToCharArray(); } int[][][][] c = new int[len[0]][][][]; int[][][][] b = new int[len[0]][][][]; for (int i = 0; i < len[0]; i++) { c[i] = new int[len[1]][][]; b[i] = new int[len[1]][][]; for (int j = 0; j < len[1]; j++) { c[i][j] = new int[len[2]][]; b[i][j] = new int[len[2]][]; for (int k = 0; k < len[2]; k++) { c[i][j][k] = new int[len[3]]; b[i][j][k] = new int[len[3]]; } } } findLCS(ref c, ref b, ref seq, ref len); for (int i = 0; i < RANK; i++) len[i]--; if ("n ha es" == buildLCS(b, seq[0], len)) { Console.WriteLine("Test passed"); return 100; } else { Console.WriteLine("Test failed."); return 0; } } } }
// 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 JitTest { internal class LCS { private const int RANK = 4; private static String buildLCS(int[][][][] b, char[] X, int[] ind) { for (int i = 0; i < RANK; i++) if (ind[i] == 0) return ""; int L = b[ind[0]][ind[1]][ind[2]][ind[3]]; if (L == RANK) { for (int i = 0; i < RANK; i++) ind[i]--; int idx = ind[0]; return buildLCS(b, X, ind) + X[idx]; } if (L >= 0 && L < RANK) { ind[L]--; return buildLCS(b, X, ind); } throw new Exception(); } private static void findLCS(ref int[][][][] c, ref int[][][][] b, ref char[][] seq, ref int[] len) { int[] ind = new int[RANK]; for (ind[0] = 1; ind[0] < len[0]; ind[0]++) { for (ind[1] = 1; ind[1] < len[1]; ind[1]++) { for (ind[2] = 1; ind[2] < len[2]; ind[2]++) { for (ind[3] = 1; ind[3] < len[3]; ind[3]++) { bool eqFlag = true; for (int i = 1; i < RANK; i++) { if (seq[i][ind[i] - 1] != seq[i - 1][ind[i - 1] - 1]) { eqFlag = false; break; } } if (eqFlag) { c[ind[0]][ind[1]][ind[2]][ind[3]] = c[ind[0] - 1][ind[1] - 1][ind[2] - 1][ind[3] - 1] + 1; b[ind[0]][ind[1]][ind[2]][ind[3]] = RANK; continue; } int R = -1; int M = -1; for (int i = 0; i < RANK; i++) { ind[i]--; if (c[ind[0]][ind[1]][ind[2]][ind[3]] > M) { R = i; M = c[ind[0]][ind[1]][ind[2]][ind[3]]; } ind[i]++; } if (R < 0 || M < 0) throw new Exception(); c[ind[0]][ind[1]][ind[2]][ind[3]] = M; b[ind[0]][ind[1]][ind[2]][ind[3]] = R; } } } } } private static int Main() { Console.WriteLine("Test searches for longest common subsequence of 4 strings\n\n"); String[] str = { "The Sun has left his blackness", "and has found a fresher morning", "and the fair Moon rejoices", "in the clear and cloudless night" }; int[] len = new int[RANK]; char[][] seq = new char[RANK][]; for (int i = 0; i < RANK; i++) { len[i] = str[i].Length + 1; seq[i] = str[i].ToCharArray(); } int[][][][] c = new int[len[0]][][][]; int[][][][] b = new int[len[0]][][][]; for (int i = 0; i < len[0]; i++) { c[i] = new int[len[1]][][]; b[i] = new int[len[1]][][]; for (int j = 0; j < len[1]; j++) { c[i][j] = new int[len[2]][]; b[i][j] = new int[len[2]][]; for (int k = 0; k < len[2]; k++) { c[i][j][k] = new int[len[3]]; b[i][j][k] = new int[len[3]]; } } } findLCS(ref c, ref b, ref seq, ref len); for (int i = 0; i < RANK; i++) len[i]--; if ("n ha es" == buildLCS(b, seq[0], len)) { Console.WriteLine("Test passed"); return 100; } else { Console.WriteLine("Test failed."); return 0; } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/RequiresUnreferencedCodeAttribute.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable enable namespace System.Diagnostics.CodeAnalysis { /// <summary> /// Indicates that the specified method requires dynamic access to code that is not referenced /// statically, for example through <see cref="System.Reflection"/>. /// </summary> /// <remarks> /// This allows tools to understand which methods are unsafe to call when removing unreferenced /// code from an application. /// </remarks> [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)] #if SYSTEM_PRIVATE_CORELIB public #else internal #endif sealed class RequiresUnreferencedCodeAttribute : Attribute { /// <summary> /// Initializes a new instance of the <see cref="RequiresUnreferencedCodeAttribute"/> class /// with the specified message. /// </summary> /// <param name="message"> /// A message that contains information about the usage of unreferenced code. /// </param> public RequiresUnreferencedCodeAttribute(string message) { Message = message; } /// <summary> /// Gets a message that contains information about the usage of unreferenced code. /// </summary> public string Message { get; } /// <summary> /// Gets or sets an optional URL that contains more information about the method, /// why it requires unreferenced code, and what options a consumer has to deal with it. /// </summary> public string? Url { get; set; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable enable namespace System.Diagnostics.CodeAnalysis { /// <summary> /// Indicates that the specified method requires dynamic access to code that is not referenced /// statically, for example through <see cref="System.Reflection"/>. /// </summary> /// <remarks> /// This allows tools to understand which methods are unsafe to call when removing unreferenced /// code from an application. /// </remarks> [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)] #if SYSTEM_PRIVATE_CORELIB public #else internal #endif sealed class RequiresUnreferencedCodeAttribute : Attribute { /// <summary> /// Initializes a new instance of the <see cref="RequiresUnreferencedCodeAttribute"/> class /// with the specified message. /// </summary> /// <param name="message"> /// A message that contains information about the usage of unreferenced code. /// </param> public RequiresUnreferencedCodeAttribute(string message) { Message = message; } /// <summary> /// Gets a message that contains information about the usage of unreferenced code. /// </summary> public string Message { get; } /// <summary> /// Gets or sets an optional URL that contains more information about the method, /// why it requires unreferenced code, and what options a consumer has to deal with it. /// </summary> public string? Url { get; set; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.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.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace System.Threading { /// <summary>Signals to a <see cref="CancellationToken"/> that it should be canceled.</summary> /// <remarks> /// <para> /// <see cref="CancellationTokenSource"/> is used to instantiate a <see cref="CancellationToken"/> (via /// the source's <see cref="Token">Token</see> property) that can be handed to operations that wish to be /// notified of cancellation or that can be used to register asynchronous operations for cancellation. That /// token may have cancellation requested by calling to the source's <see cref="Cancel()"/> method. /// </para> /// <para> /// All members of this class, except <see cref="Dispose()"/>, are thread-safe and may be used /// concurrently from multiple threads. /// </para> /// </remarks> public class CancellationTokenSource : IDisposable { /// <summary>A <see cref="CancellationTokenSource"/> that's already canceled.</summary> internal static readonly CancellationTokenSource s_canceledSource = new CancellationTokenSource() { _state = NotifyingCompleteState }; /// <summary>A <see cref="CancellationTokenSource"/> that's never canceled. This isn't enforced programmatically, only by usage. Do not cancel!</summary> internal static readonly CancellationTokenSource s_neverCanceledSource = new CancellationTokenSource(); /// <summary>Delegate used with <see cref="Timer"/> to trigger cancellation of a <see cref="CancellationTokenSource"/>.</summary> private static readonly TimerCallback s_timerCallback = TimerCallback; private static void TimerCallback(object? state) => // separated out into a named method to improve Timer diagnostics in a debugger ((CancellationTokenSource)state!).NotifyCancellation(throwOnFirstException: false); // skip ThrowIfDisposed() check in Cancel() /// <summary>The current state of the CancellationTokenSource.</summary> private volatile int _state; /// <summary>Whether this <see cref="CancellationTokenSource"/> has been disposed.</summary> private bool _disposed; /// <summary>TimerQueueTimer used by CancelAfter and Timer-related ctors. Used instead of Timer to avoid extra allocations and because the rooted behavior is desired.</summary> private volatile TimerQueueTimer? _timer; /// <summary><see cref="System.Threading.WaitHandle"/> lazily initialized and returned from <see cref="WaitHandle"/>.</summary> private volatile ManualResetEvent? _kernelEvent; /// <summary>Registration state for the source.</summary> /// <remarks>Lazily-initialized, also serving as the lock to protect its contained state.</remarks> private Registrations? _registrations; // legal values for _state private const int NotCanceledState = 0; // default value of _state private const int NotifyingState = 1; private const int NotifyingCompleteState = 2; /// <summary>Gets whether cancellation has been requested for this <see cref="CancellationTokenSource" />.</summary> /// <value>Whether cancellation has been requested for this <see cref="CancellationTokenSource" />.</value> /// <remarks> /// <para> /// This property indicates whether cancellation has been requested for this token source, such as /// due to a call to its <see cref="Cancel()"/> method. /// </para> /// <para> /// If this property returns true, it only guarantees that cancellation has been requested. It does not /// guarantee that every handler registered with the corresponding token has finished executing, nor /// that cancellation requests have finished propagating to all registered handlers. Additional /// synchronization may be required, particularly in situations where related objects are being /// canceled concurrently. /// </para> /// </remarks> public bool IsCancellationRequested => _state != NotCanceledState; /// <summary>A simple helper to determine whether cancellation has finished.</summary> internal bool IsCancellationCompleted => _state == NotifyingCompleteState; /// <summary>Gets the <see cref="CancellationToken"/> associated with this <see cref="CancellationTokenSource"/>.</summary> /// <value>The <see cref="CancellationToken"/> associated with this <see cref="CancellationTokenSource"/>.</value> /// <exception cref="ObjectDisposedException">The token source has been disposed.</exception> public CancellationToken Token { get { ThrowIfDisposed(); return new CancellationToken(this); } } internal WaitHandle WaitHandle { get { ThrowIfDisposed(); // Return the handle if it was already allocated. if (_kernelEvent != null) { return _kernelEvent; } // Lazily-initialize the handle. var mre = new ManualResetEvent(false); if (Interlocked.CompareExchange(ref _kernelEvent, mre, null) != null) { mre.Dispose(); } // There is a race condition between checking IsCancellationRequested and setting the event. // However, at this point, the kernel object definitely exists and the cases are: // 1. if IsCancellationRequested = true, then we will call Set() // 2. if IsCancellationRequested = false, then NotifyCancellation will see that the event exists, and will call Set(). if (IsCancellationRequested) { _kernelEvent.Set(); } return _kernelEvent; } } /// <summary>Initializes the <see cref="CancellationTokenSource"/>.</summary> public CancellationTokenSource() { } /// <summary> /// Constructs a <see cref="CancellationTokenSource"/> that will be canceled after a specified time span. /// </summary> /// <param name="delay">The time span to wait before canceling this <see cref="CancellationTokenSource"/></param> /// <exception cref="ArgumentOutOfRangeException"> /// The <paramref name="delay"/> is less than -1 or greater than the maximum allowed timer duration. /// </exception> /// <remarks> /// <para> /// The countdown for the delay starts during the call to the constructor. When the delay expires, /// the constructed <see cref="CancellationTokenSource"/> is canceled, if it has /// not been canceled already. /// </para> /// <para> /// Subsequent calls to CancelAfter will reset the delay for the constructed /// <see cref="CancellationTokenSource"/>, if it has not been /// canceled already. /// </para> /// </remarks> public CancellationTokenSource(TimeSpan delay) { long totalMilliseconds = (long)delay.TotalMilliseconds; if (totalMilliseconds < -1 || totalMilliseconds > Timer.MaxSupportedTimeout) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.delay); } InitializeWithTimer((uint)totalMilliseconds); } /// <summary> /// Constructs a <see cref="CancellationTokenSource"/> that will be canceled after a specified time span. /// </summary> /// <param name="millisecondsDelay">The time span to wait before canceling this <see cref="CancellationTokenSource"/></param> /// <exception cref="ArgumentOutOfRangeException"> /// The exception that is thrown when <paramref name="millisecondsDelay"/> is less than -1. /// </exception> /// <remarks> /// <para> /// The countdown for the millisecondsDelay starts during the call to the constructor. When the millisecondsDelay expires, /// the constructed <see cref="CancellationTokenSource"/> is canceled (if it has /// not been canceled already). /// </para> /// <para> /// Subsequent calls to CancelAfter will reset the millisecondsDelay for the constructed /// <see cref="CancellationTokenSource"/>, if it has not been /// canceled already. /// </para> /// </remarks> public CancellationTokenSource(int millisecondsDelay) { if (millisecondsDelay < -1) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsDelay); } InitializeWithTimer((uint)millisecondsDelay); } /// <summary> /// Common initialization logic when constructing a CTS with a delay parameter. /// A zero delay will result in immediate cancellation. /// </summary> private void InitializeWithTimer(uint millisecondsDelay) { if (millisecondsDelay == 0) { _state = NotifyingCompleteState; } else { _timer = new TimerQueueTimer(s_timerCallback, this, millisecondsDelay, Timeout.UnsignedInfinite, flowExecutionContext: false); // The timer roots this CTS instance while it's scheduled. That is by design, so // that code like: // new CancellationTokenSource(timeout).Token.Register(() => ...); // will successfully invoke the delegate after the timeout. } } /// <summary>Communicates a request for cancellation.</summary> /// <remarks> /// <para> /// The associated <see cref="CancellationToken" /> will be notified of the cancellation /// and will transition to a state where <see cref="CancellationToken.IsCancellationRequested"/> returns true. /// Any callbacks or cancelable operations registered with the <see cref="CancellationToken"/> will be executed. /// </para> /// <para> /// Cancelable operations and callbacks registered with the token should not throw exceptions. /// However, this overload of Cancel will aggregate any exceptions thrown into a <see cref="AggregateException"/>, /// such that one callback throwing an exception will not prevent other registered callbacks from being executed. /// </para> /// <para> /// The <see cref="ExecutionContext"/> that was captured when each callback was registered /// will be reestablished when the callback is invoked. /// </para> /// </remarks> /// <exception cref="AggregateException">An aggregate exception containing all the exceptions thrown /// by the registered callbacks on the associated <see cref="CancellationToken"/>.</exception> /// <exception cref="ObjectDisposedException">This <see cref="CancellationTokenSource"/> has been disposed.</exception> public void Cancel() => Cancel(false); /// <summary>Communicates a request for cancellation.</summary> /// <remarks> /// <para> /// The associated <see cref="CancellationToken" /> will be notified of the cancellation and will transition to a state where /// <see cref="CancellationToken.IsCancellationRequested"/> returns true. Any callbacks or cancelable operationsregistered /// with the <see cref="CancellationToken"/> will be executed. /// </para> /// <para> /// Cancelable operations and callbacks registered with the token should not throw exceptions. /// If <paramref name="throwOnFirstException"/> is true, an exception will immediately propagate out of the /// call to Cancel, preventing the remaining callbacks and cancelable operations from being processed. /// If <paramref name="throwOnFirstException"/> is false, this overload will aggregate any /// exceptions thrown into a <see cref="AggregateException"/>, /// such that one callback throwing an exception will not prevent other registered callbacks from being executed. /// </para> /// <para> /// The <see cref="ExecutionContext"/> that was captured when each callback was registered /// will be reestablished when the callback is invoked. /// </para> /// </remarks> /// <param name="throwOnFirstException">Specifies whether exceptions should immediately propagate.</param> /// <exception cref="AggregateException">An aggregate exception containing all the exceptions thrown /// by the registered callbacks on the associated <see cref="CancellationToken"/>.</exception> /// <exception cref="ObjectDisposedException">This <see cref="CancellationTokenSource"/> has been disposed.</exception> public void Cancel(bool throwOnFirstException) { ThrowIfDisposed(); NotifyCancellation(throwOnFirstException); } /// <summary>Schedules a Cancel operation on this <see cref="CancellationTokenSource"/>.</summary> /// <param name="delay">The time span to wait before canceling this <see cref="CancellationTokenSource"/>. /// </param> /// <exception cref="ObjectDisposedException">The exception thrown when this <see /// cref="CancellationTokenSource"/> has been disposed. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The <paramref name="delay"/> is less than -1 or greater than maximum allowed timer duration. /// </exception> /// <remarks> /// <para> /// The countdown for the delay starts during this call. When the delay expires, /// this <see cref="CancellationTokenSource"/> is canceled, if it has /// not been canceled already. /// </para> /// <para> /// Subsequent calls to CancelAfter will reset the delay for this /// <see cref="CancellationTokenSource"/>, if it has not been canceled already. /// </para> /// </remarks> public void CancelAfter(TimeSpan delay) { long totalMilliseconds = (long)delay.TotalMilliseconds; if (totalMilliseconds < -1 || totalMilliseconds > Timer.MaxSupportedTimeout) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.delay); } CancelAfter((uint)totalMilliseconds); } /// <summary> /// Schedules a Cancel operation on this <see cref="CancellationTokenSource"/>. /// </summary> /// <param name="millisecondsDelay">The time span to wait before canceling this <see /// cref="CancellationTokenSource"/>. /// </param> /// <exception cref="ObjectDisposedException">The exception thrown when this <see /// cref="CancellationTokenSource"/> has been disposed. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The exception thrown when <paramref name="millisecondsDelay"/> is less than -1. /// </exception> /// <remarks> /// <para> /// The countdown for the millisecondsDelay starts during this call. When the millisecondsDelay expires, /// this <see cref="CancellationTokenSource"/> is canceled, if it has /// not been canceled already. /// </para> /// <para> /// Subsequent calls to CancelAfter will reset the millisecondsDelay for this /// <see cref="CancellationTokenSource"/>, if it has not been /// canceled already. /// </para> /// </remarks> public void CancelAfter(int millisecondsDelay) { if (millisecondsDelay < -1) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsDelay); } CancelAfter((uint)millisecondsDelay); } private void CancelAfter(uint millisecondsDelay) { ThrowIfDisposed(); if (IsCancellationRequested) { return; } // There is a race condition here as a Cancel could occur between the check of // IsCancellationRequested and the creation of the timer. This is benign; in the // worst case, a timer will be created that has no effect when it expires. // Also, if Dispose() is called right here (after ThrowIfDisposed(), before timer // creation), it would result in a leaked Timer object (at least until the timer // expired and Disposed itself). But this would be considered bad behavior, as // Dispose() is not thread-safe and should not be called concurrently with CancelAfter(). TimerQueueTimer? timer = _timer; if (timer == null) { // Lazily initialize the timer in a thread-safe fashion. // Initially set to "never go off" because we don't want to take a // chance on a timer "losing" the initialization and then // cancelling the token before it (the timer) can be disposed. timer = new TimerQueueTimer(s_timerCallback, this, Timeout.UnsignedInfinite, Timeout.UnsignedInfinite, flowExecutionContext: false); TimerQueueTimer? currentTimer = Interlocked.CompareExchange(ref _timer, timer, null); if (currentTimer != null) { // We did not initialize the timer. Dispose the new timer. timer.Close(); timer = currentTimer; } } timer.Change(millisecondsDelay, Timeout.UnsignedInfinite, throwIfDisposed: false); } /// <summary> /// Attempts to reset the <see cref="CancellationTokenSource"/> to be used for an unrelated operation. /// </summary> /// <returns> /// true if the <see cref="CancellationTokenSource"/> has not had cancellation requested and could /// have its state reset to be reused for a subsequent operation; otherwise, false. /// </returns> /// <remarks> /// <see cref="TryReset"/> is intended to be used by the sole owner of the <see cref="CancellationTokenSource"/> /// when it is known that the operation with which the <see cref="CancellationTokenSource"/> was used has /// completed, no one else will be attempting to cancel it, and any registrations still remaining are erroneous. /// Upon a successful reset, such registrations will no longer be notified for any subsequent cancellation of the /// <see cref="CancellationTokenSource"/>; however, if any component still holds a reference to this /// <see cref="CancellationTokenSource"/> either directly or indirectly via a <see cref="CancellationToken"/> /// handed out from it, polling via their reference will show the current state any time after the reset as /// it's the same instance. Usage of <see cref="TryReset"/> concurrently with requesting cancellation is not /// thread-safe and may result in TryReset returning true even if cancellation was already requested and may result /// in registrations not being invoked as part of the concurrent cancellation request. /// </remarks> public bool TryReset() { ThrowIfDisposed(); // We can only reset if cancellation has not yet been requested: we never want to allow a CancellationToken // to transition from canceled to non-canceled. if (_state == NotCanceledState) { // If there is no timer, then we're free to reset. If there is a timer, then we need to first try // to reset it to be infinite so that it won't fire, and then recognize that it could have already // fired by the time we successfully changed it, and so check to see whether that's possibly the case. // If we successfully reset it and it never fired, then we can be sure it won't trigger cancellation. bool reset = _timer is not TimerQueueTimer timer || (timer.Change(Timeout.UnsignedInfinite, Timeout.UnsignedInfinite, throwIfDisposed: false) && !timer._everQueued); if (reset) { // We're not canceled and no timer will run to cancel us. // Clear out all the registrations, and return that we've successfully reset. Volatile.Read(ref _registrations)?.UnregisterAll(); return true; } } // Failed to reset. return false; } /// <summary>Releases the resources used by this <see cref="CancellationTokenSource" />.</summary> /// <remarks>This method is not thread-safe for any other concurrent calls.</remarks> public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// <summary> /// Releases the unmanaged resources used by the <see cref="CancellationTokenSource" /> class and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) { // We specifically tolerate that a callback can be unregistered // after the CTS has been disposed and/or concurrently with cts.Dispose(). // This is safe without locks because Dispose doesn't interact with values // in the callback partitions, only nulling out the ref to existing partitions. // // We also tolerate that a callback can be registered after the CTS has been // disposed. This is safe because InternalRegister is tolerant // of _callbackPartitions becoming null during its execution. However, // we run the acceptable risk of _callbackPartitions getting reinitialized // to non-null if there is a race between Dispose and Register, in which case this // instance may unnecessarily hold onto a registered callback. But that's no worse // than if Dispose wasn't safe to use concurrently, as Dispose would never be called, // and thus no handlers would be dropped. // // And, we tolerate Dispose being used concurrently with Cancel. This is necessary // to properly support, e.g., LinkedCancellationTokenSource, where, due to common usage patterns, // it's possible for this pairing to occur with valid usage (e.g. a component accepts // an external CancellationToken and uses CreateLinkedTokenSource to combine it with an // internal source of cancellation, then Disposes of that linked source, which could // happen at the same time the external entity is requesting cancellation). TimerQueueTimer? timer = _timer; if (timer != null) { _timer = null; timer.Close(); // TimerQueueTimer.Close is thread-safe } _registrations = null; // allow the GC to clean up registrations // If a kernel event was created via WaitHandle, we'd like to Dispose of it. However, // we only want to do so if it's not being used by Cancel concurrently. First, we // interlocked exchange it to be null, and then we check whether cancellation is currently // in progress. NotifyCancellation will only try to set the event if it exists after it's // transitioned to and while it's in the NotifyingState. if (_kernelEvent != null) { ManualResetEvent? mre = Interlocked.Exchange<ManualResetEvent?>(ref _kernelEvent!, null); if (mre != null && _state != NotifyingState) { mre.Dispose(); } } _disposed = true; } } /// <summary>Throws an exception if the source has been disposed.</summary> private void ThrowIfDisposed() { if (_disposed) { ThrowHelper.ThrowObjectDisposedException(ExceptionResource.CancellationTokenSource_Disposed); } } /// <summary> /// Registers a callback object. If cancellation has already occurred, the /// callback will have been run by the time this method returns. /// </summary> internal CancellationTokenRegistration Register( Delegate callback, object? stateForCallback, SynchronizationContext? syncContext, ExecutionContext? executionContext) { Debug.Assert(this != s_neverCanceledSource, "This source should never be exposed via a CancellationToken."); Debug.Assert(callback is Action<object?> || callback is Action<object?, CancellationToken>); // If not canceled, register the handler; if canceled already, run the callback synchronously. if (!IsCancellationRequested) { // We allow Dispose to be called concurrently with Register. While this is not a recommended practice, // consumers can and do use it this way. if (_disposed) { return default; } // Get the registrations object. It's lazily initialized to keep the size of a CTS smaller for situations // where all operations associated with the CTS complete synchronously and never actually need to register, // or all only poll. Registrations? registrations = Volatile.Read(ref _registrations); if (registrations is null) { registrations = new Registrations(this); registrations = Interlocked.CompareExchange(ref _registrations, registrations, null) ?? registrations; } // If it looks like there's a node in the freelist we could grab, grab the lock and try to get, configure, // and register the node. CallbackNode? node = null; long id = 0; if (registrations.FreeNodeList is not null) { registrations.EnterLock(); try { // Try to take a free node. If we're able to, configure the node and register it. node = registrations.FreeNodeList; if (node is not null) { Debug.Assert(node.Prev == null, "Nodes in the free list should all have a null Prev"); registrations.FreeNodeList = node.Next; node.Id = id = registrations.NextAvailableId++; node.Callback = callback; node.CallbackState = stateForCallback; node.ExecutionContext = executionContext; node.SynchronizationContext = syncContext; node.Next = registrations.Callbacks; registrations.Callbacks = node; if (node.Next != null) { node.Next.Prev = node; } } } finally { registrations.ExitLock(); } } // If we were unsuccessful in using a free node, create a new one, configure it, and register it. if (node is null) { // Allocate the node if we couldn't get one from the free list. We avoid // doing this while holding the spin lock, to avoid a potentially arbitrary // amount of GC-related work under the lock, which we aim to keep very tight, // just a few assignments. node = new CallbackNode(registrations); node.Callback = callback; node.CallbackState = stateForCallback; node.ExecutionContext = executionContext; node.SynchronizationContext = syncContext; registrations.EnterLock(); try { node.Id = id = registrations.NextAvailableId++; node.Next = registrations.Callbacks; if (node.Next != null) { node.Next.Prev = node; } registrations.Callbacks = node; } finally { registrations.ExitLock(); } } // If cancellation hasn't been requested, return the registration. // if cancellation has been requested, try to undo the registration and run the callback // ourselves, but if we can't unregister it (e.g. the thread running Cancel snagged // our callback for execution), return the registration so that the caller can wait // for callback completion in ctr.Dispose(). Debug.Assert(id != 0, "IDs should never be the reserved value 0."); if (!IsCancellationRequested || !registrations.Unregister(id, node)) { return new CancellationTokenRegistration(id, node); } } // Cancellation already occurred. Run the callback on this thread and return an empty registration. Invoke(callback, stateForCallback, this); return default; } private void NotifyCancellation(bool throwOnFirstException) { // If we're the first to signal cancellation, do the main extra work. if (!IsCancellationRequested && Interlocked.CompareExchange(ref _state, NotifyingState, NotCanceledState) == NotCanceledState) { // Dispose of the timer, if any. Dispose may be running concurrently here, but TimerQueueTimer.Close is thread-safe. TimerQueueTimer? timer = _timer; if (timer != null) { _timer = null; timer.Close(); } // Set the event if it's been lazily initialized and hasn't yet been disposed of. Dispose may // be running concurrently, in which case either it'll have set m_kernelEvent back to null and // we won't see it here, or it'll see that we've transitioned to NOTIFYING and will skip disposing it, // leaving cleanup to finalization. _kernelEvent?.Set(); // update the MRE value. // - late enlisters to the Canceled event will have their callbacks called immediately in the Register() methods. // - Callbacks are not called inside a lock. // - After transition, no more delegates will be added to the // - list of handlers, and hence it can be consumed and cleared at leisure by ExecuteCallbackHandlers. ExecuteCallbackHandlers(throwOnFirstException); Debug.Assert(IsCancellationCompleted, "Expected cancellation to have finished"); } } /// <summary>Invoke all registered callbacks.</summary> /// <remarks>The handlers are invoked synchronously in LIFO order.</remarks> private void ExecuteCallbackHandlers(bool throwOnFirstException) { Debug.Assert(IsCancellationRequested, "ExecuteCallbackHandlers should only be called after setting IsCancellationRequested->true"); // If there are no callbacks to run, we can safely exit. Any race conditions to lazy initialize it // will see IsCancellationRequested and will then run the callback themselves. Registrations? registrations = Interlocked.Exchange(ref _registrations, null); if (registrations is null) { Interlocked.Exchange(ref _state, NotifyingCompleteState); return; } // Record the threadID being used for running the callbacks. registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId; List<Exception>? exceptionList = null; try { // We call the delegates in LIFO order on each partition so that callbacks fire 'deepest first'. // This is intended to help with nesting scenarios so that child enlisters cancel before their parents. // Iterate through all nodes in the partition. We remove each node prior // to processing it. This allows for unregistration of subsequent registrations // to still be effective even as other registrations are being invoked. while (true) { CallbackNode? node; registrations.EnterLock(); try { // Pop the next registration from the callbacks list. node = registrations.Callbacks; if (node == null) { // No more registrations to process. break; } Debug.Assert(node.Registrations.Source == this); Debug.Assert(node.Prev == null); if (node.Next != null) { node.Next.Prev = null; } registrations.Callbacks = node.Next; // Publish the intended callback ID, to ensure ctr.Dispose can tell if a wait is necessary. // This write happens while the lock is held so that Dispose is either able to successfully // unregister or is guaranteed to see an accurate executing callback ID, since it takes // the same lock to remove the node from the callback list. registrations.ExecutingCallbackId = node.Id; // Now that we've grabbed the Id, reset the node's Id to 0. This signals // to code unregistering that the node is no longer associated with a callback. node.Id = 0; } finally { registrations.ExitLock(); } // Invoke the callback on this thread if there's no sync context or on the // target sync context if there is one. try { if (node.SynchronizationContext != null) { // Transition to the target syncContext and continue there. node.SynchronizationContext.Send(static s => { var n = (CallbackNode)s!; n.Registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId; n.ExecuteCallback(); }, node); registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId; // above may have altered ThreadIDExecutingCallbacks, so reset it } else { node.ExecuteCallback(); } } catch (Exception ex) when (!throwOnFirstException) { // Store the exception and continue (exceptionList ??= new List<Exception>()).Add(ex); } // Drop the node. While we could add it to the free list, doing so has cost (we'd need to take the lock again) // and very limited value. Since a source can only be canceled once, and after it's canceled registrations don't // need nodes, the only benefit to putting this on the free list would be if Register raced with cancellation // occurring, such that it could have used this free node but would instead need to allocate a new node (if // there wasn't another free node available). } } finally { _state = NotifyingCompleteState; Interlocked.Exchange(ref registrations.ExecutingCallbackId, 0); // for safety, prevent reorderings crossing this point and seeing inconsistent state. } if (exceptionList != null) { Debug.Assert(exceptionList.Count > 0, $"Expected {exceptionList.Count} > 0"); throw new AggregateException(exceptionList); } } /// <summary> /// Creates a <see cref="CancellationTokenSource"/> that will be in the canceled state /// when any of the source tokens are in the canceled state. /// </summary> /// <param name="token1">The first <see cref="CancellationToken">CancellationToken</see> to observe.</param> /// <param name="token2">The second <see cref="CancellationToken">CancellationToken</see> to observe.</param> /// <returns>A <see cref="CancellationTokenSource"/> that is linked /// to the source tokens.</returns> public static CancellationTokenSource CreateLinkedTokenSource(CancellationToken token1, CancellationToken token2) => !token1.CanBeCanceled ? CreateLinkedTokenSource(token2) : token2.CanBeCanceled ? new Linked2CancellationTokenSource(token1, token2) : (CancellationTokenSource)new Linked1CancellationTokenSource(token1); /// <summary> /// Creates a <see cref="CancellationTokenSource"/> that will be in the canceled state /// when the supplied token is in the canceled state. /// </summary> /// <param name="token">The <see cref="CancellationToken">CancellationToken</see> to observe.</param> /// <returns>A <see cref="CancellationTokenSource"/> that is linked to the source token.</returns> public static CancellationTokenSource CreateLinkedTokenSource(CancellationToken token) => token.CanBeCanceled ? new Linked1CancellationTokenSource(token) : new CancellationTokenSource(); /// <summary> /// Creates a <see cref="CancellationTokenSource"/> that will be in the canceled state /// when any of the source tokens are in the canceled state. /// </summary> /// <param name="tokens">The <see cref="CancellationToken">CancellationToken</see> instances to observe.</param> /// <returns>A <see cref="CancellationTokenSource"/> that is linked to the source tokens.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="tokens"/> is null.</exception> public static CancellationTokenSource CreateLinkedTokenSource(params CancellationToken[] tokens!!) => tokens.Length switch { 0 => throw new ArgumentException(SR.CancellationToken_CreateLinkedToken_TokensIsEmpty), 1 => CreateLinkedTokenSource(tokens[0]), 2 => CreateLinkedTokenSource(tokens[0], tokens[1]), // a defensive copy is not required as the array has value-items that have only a single reference field, // hence each item cannot be null itself, and reads of the payloads cannot be torn. _ => new LinkedNCancellationTokenSource(tokens), }; private sealed class Linked1CancellationTokenSource : CancellationTokenSource { private readonly CancellationTokenRegistration _reg1; internal Linked1CancellationTokenSource(CancellationToken token1) { _reg1 = token1.UnsafeRegister(LinkedNCancellationTokenSource.s_linkedTokenCancelDelegate, this); } protected override void Dispose(bool disposing) { if (!disposing || _disposed) { return; } _reg1.Dispose(); base.Dispose(disposing); } } private sealed class Linked2CancellationTokenSource : CancellationTokenSource { private readonly CancellationTokenRegistration _reg1; private readonly CancellationTokenRegistration _reg2; internal Linked2CancellationTokenSource(CancellationToken token1, CancellationToken token2) { _reg1 = token1.UnsafeRegister(LinkedNCancellationTokenSource.s_linkedTokenCancelDelegate, this); _reg2 = token2.UnsafeRegister(LinkedNCancellationTokenSource.s_linkedTokenCancelDelegate, this); } protected override void Dispose(bool disposing) { if (!disposing || _disposed) { return; } _reg1.Dispose(); _reg2.Dispose(); base.Dispose(disposing); } } private sealed class LinkedNCancellationTokenSource : CancellationTokenSource { internal static readonly Action<object?> s_linkedTokenCancelDelegate = static s => { Debug.Assert(s is CancellationTokenSource, $"Expected {typeof(CancellationTokenSource)}, got {s}"); ((CancellationTokenSource)s).NotifyCancellation(throwOnFirstException: false); // skip ThrowIfDisposed() check in Cancel() }; private CancellationTokenRegistration[]? _linkingRegistrations; internal LinkedNCancellationTokenSource(CancellationToken[] tokens) { _linkingRegistrations = new CancellationTokenRegistration[tokens.Length]; for (int i = 0; i < tokens.Length; i++) { if (tokens[i].CanBeCanceled) { _linkingRegistrations[i] = tokens[i].UnsafeRegister(s_linkedTokenCancelDelegate, this); } // Empty slots in the array will be default(CancellationTokenRegistration), which are nops to Dispose. // Based on usage patterns, such occurrences should also be rare, such that it's not worth resizing // the array and incurring the related costs. } } protected override void Dispose(bool disposing) { if (!disposing || _disposed) { return; } CancellationTokenRegistration[]? linkingRegistrations = _linkingRegistrations; if (linkingRegistrations != null) { _linkingRegistrations = null; // release for GC once we're done enumerating for (int i = 0; i < linkingRegistrations.Length; i++) { linkingRegistrations[i].Dispose(); } } base.Dispose(disposing); } } private static void Invoke(Delegate d, object? state, CancellationTokenSource source) { Debug.Assert(d is Action<object?> || d is Action<object?, CancellationToken>); if (d is Action<object?> actionWithState) { actionWithState(state); } else { ((Action<object?, CancellationToken>)d)(state, new CancellationToken(source)); } } /// <summary>Set of all the registrations in the token source.</summary> /// <remarks> /// Separated out into a separate instance to keep CancellationTokenSource smaller for the case where one is created but nothing is registered with it. /// This happens not infrequently, in particular when one is created for an operation that ends up completing synchronously / quickly. /// </remarks> internal sealed class Registrations { /// <summary>The associated source.</summary> public readonly CancellationTokenSource Source; /// <summary>Doubly-linked list of callbacks registered with the source. Callbacks are removed during unregistration and as they're invoked.</summary> public CallbackNode? Callbacks; /// <summary>Singly-linked list of free nodes that can be used for subsequent callback registrations.</summary> public CallbackNode? FreeNodeList; /// <summary>Every callback is assigned a unique, never-reused ID. This defines the next available ID.</summary> public long NextAvailableId = 1; // avoid using 0, as that's the default long value and used to represent an empty node /// <summary>Tracks the running callback to assist ctr.Dispose() to wait for the target callback to complete.</summary> public long ExecutingCallbackId; /// <summary>The ID of the thread currently executing the main body of CTS.Cancel()</summary> /// <remarks> /// This helps us to know if a call to ctr.Dispose() is running 'within' a cancellation callback. /// This is updated as we move between the main thread calling cts.Cancel() and any syncContexts /// that are used to actually run the callbacks. /// </remarks> public volatile int ThreadIDExecutingCallbacks = -1; /// <summary>Spin lock that protects state in the instance.</summary> private int _lock; /// <summary>Initializes the instance.</summary> /// <param name="source">The associated source.</param> public Registrations(CancellationTokenSource source) => Source = source; [MethodImpl(MethodImplOptions.AggressiveInlining)] // used in only two places, one of which is a hot path private void Recycle(CallbackNode node) { Debug.Assert(_lock == 1); // Clear out the unused node and put it on the singly-linked free list. // The only field we don't clear out is the associated Registrations, as that's fixed // throughout the node's lifetime. node.Id = 0; node.Callback = null; node.CallbackState = null; node.ExecutionContext = null; node.SynchronizationContext = null; node.Prev = null; node.Next = FreeNodeList; FreeNodeList = node; } /// <summary>Unregisters a callback.</summary> /// <param name="id">The expected id of the registration.</param> /// <param name="node">The callback node.</param> /// <returns>true if the node was found and removed; false if it couldn't be found or didn't match the provided id.</returns> public bool Unregister(long id, CallbackNode node) { Debug.Assert(node != null, "Expected non-null node"); Debug.Assert(node.Registrations == this, "Expected node to come from this registrations instance"); if (id == 0) { // In general, we won't get 0 passed in here. However, race conditions between threads // Unregistering and also zero'ing out the CancellationTokenRegistration could cause 0 // to be passed in here, in which case there's nothing to do. 0 is never a valid id. return false; } EnterLock(); try { if (node.Id != id) { // Either: // - The callback is currently or has already been invoked, in which case node.Id // will no longer equal the assigned id, as it will have transitioned to 0. // - The registration was already disposed of, in which case node.Id will similarly // no longer equal the assigned id, as it will have transitioned to 0 and potentially // then to another (larger) value when reused for a new registration. // In either case, there's nothing to unregister. return false; } // The registration must still be in the callbacks list. Remove it. if (Callbacks == node) { Debug.Assert(node.Prev == null); Callbacks = node.Next; } else { Debug.Assert(node.Prev != null); node.Prev.Next = node.Next; } if (node.Next != null) { node.Next.Prev = node.Prev; } Recycle(node); return true; } finally { ExitLock(); } } /// <summary>Moves all registrations to the free list.</summary> public void UnregisterAll() { EnterLock(); try { // Null out all callbacks. CallbackNode? node = Callbacks; Callbacks = null; // Reset and move each node that was in the callbacks list to the free list. while (node != null) { CallbackNode? next = node.Next; Recycle(node); node = next; } } finally { ExitLock(); } } /// <summary> /// Wait for a single callback to complete (or, more specifically, to not be running). /// It is ok to call this method if the callback has already finished. /// Calling this method before the target callback has been selected for execution would be an error. /// </summary> public void WaitForCallbackToComplete(long id) { SpinWait sw = default; while (Volatile.Read(ref ExecutingCallbackId) == id) { sw.SpinOnce(); // spin, as we assume callback execution is fast and that this situation is rare. } } /// <summary> /// Asynchronously wait for a single callback to complete (or, more specifically, to not be running). /// It is ok to call this method if the callback has already finished. /// Calling this method before the target callback has been selected for execution would be an error. /// </summary> public ValueTask WaitForCallbackToCompleteAsync(long id) { // If the currently executing callback is not the target one, then the target one has already // completed and we can simply return. This should be the most common case, as the caller // calls if we're currently canceling but doesn't know what callback is running, if any. if (Volatile.Read(ref ExecutingCallbackId) != id) { return default; } // The specified callback is actually running: queue an async loop that'll poll for the currently executing // callback to complete. While such polling isn't ideal, we expect this to be a rare case (disposing while // the associated callback is running), and brief when it happens (so the polling will be minimal), and making // this work with a callback mechanism will add additional cost to other more common cases. return new ValueTask(Task.Factory.StartNew(static async s => { var state = (TupleSlim<Registrations, long>)s!; while (Volatile.Read(ref state.Item1.ExecutingCallbackId) == state.Item2) { await Task.Yield(); } }, new TupleSlim<Registrations, long>(this, id), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap()); } /// <summary>Enters the lock for this instance. The current thread must not be holding the lock, but that is not validated.</summary> public void EnterLock() { ref int value = ref _lock; if (Interlocked.Exchange(ref value, 1) != 0) { Contention(ref value); [MethodImpl(MethodImplOptions.NoInlining)] static void Contention(ref int value) { SpinWait sw = default; do { sw.SpinOnce(); } while (Interlocked.Exchange(ref value, 1) == 1); } } } /// <summary>Exits the lock for this instance. The current thread must be holding the lock, but that is not validated.</summary> public void ExitLock() { Debug.Assert(_lock == 1); Volatile.Write(ref _lock, 0); } } /// <summary>All of the state associated a registered callback, in a node that's part of a linked list of registered callbacks.</summary> internal sealed class CallbackNode { public readonly Registrations Registrations; public CallbackNode? Prev; public CallbackNode? Next; public long Id; public Delegate? Callback; // Action<object> or Action<object,CancellationToken> public object? CallbackState; public ExecutionContext? ExecutionContext; public SynchronizationContext? SynchronizationContext; public CallbackNode(Registrations registrations) { Debug.Assert(registrations != null, "Expected non-null parent registrations"); Registrations = registrations; } public void ExecuteCallback() { ExecutionContext? context = ExecutionContext; if (context is null) { Debug.Assert(Callback != null); Invoke(Callback, CallbackState, Registrations.Source); } else { ExecutionContext.RunInternal(context, static s => { var node = (CallbackNode)s!; Debug.Assert(node.Callback != null); Invoke(node.Callback, node.CallbackState, node.Registrations.Source); }, this); } } } } }
// 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.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace System.Threading { /// <summary>Signals to a <see cref="CancellationToken"/> that it should be canceled.</summary> /// <remarks> /// <para> /// <see cref="CancellationTokenSource"/> is used to instantiate a <see cref="CancellationToken"/> (via /// the source's <see cref="Token">Token</see> property) that can be handed to operations that wish to be /// notified of cancellation or that can be used to register asynchronous operations for cancellation. That /// token may have cancellation requested by calling to the source's <see cref="Cancel()"/> method. /// </para> /// <para> /// All members of this class, except <see cref="Dispose()"/>, are thread-safe and may be used /// concurrently from multiple threads. /// </para> /// </remarks> public class CancellationTokenSource : IDisposable { /// <summary>A <see cref="CancellationTokenSource"/> that's already canceled.</summary> internal static readonly CancellationTokenSource s_canceledSource = new CancellationTokenSource() { _state = NotifyingCompleteState }; /// <summary>A <see cref="CancellationTokenSource"/> that's never canceled. This isn't enforced programmatically, only by usage. Do not cancel!</summary> internal static readonly CancellationTokenSource s_neverCanceledSource = new CancellationTokenSource(); /// <summary>Delegate used with <see cref="Timer"/> to trigger cancellation of a <see cref="CancellationTokenSource"/>.</summary> private static readonly TimerCallback s_timerCallback = TimerCallback; private static void TimerCallback(object? state) => // separated out into a named method to improve Timer diagnostics in a debugger ((CancellationTokenSource)state!).NotifyCancellation(throwOnFirstException: false); // skip ThrowIfDisposed() check in Cancel() /// <summary>The current state of the CancellationTokenSource.</summary> private volatile int _state; /// <summary>Whether this <see cref="CancellationTokenSource"/> has been disposed.</summary> private bool _disposed; /// <summary>TimerQueueTimer used by CancelAfter and Timer-related ctors. Used instead of Timer to avoid extra allocations and because the rooted behavior is desired.</summary> private volatile TimerQueueTimer? _timer; /// <summary><see cref="System.Threading.WaitHandle"/> lazily initialized and returned from <see cref="WaitHandle"/>.</summary> private volatile ManualResetEvent? _kernelEvent; /// <summary>Registration state for the source.</summary> /// <remarks>Lazily-initialized, also serving as the lock to protect its contained state.</remarks> private Registrations? _registrations; // legal values for _state private const int NotCanceledState = 0; // default value of _state private const int NotifyingState = 1; private const int NotifyingCompleteState = 2; /// <summary>Gets whether cancellation has been requested for this <see cref="CancellationTokenSource" />.</summary> /// <value>Whether cancellation has been requested for this <see cref="CancellationTokenSource" />.</value> /// <remarks> /// <para> /// This property indicates whether cancellation has been requested for this token source, such as /// due to a call to its <see cref="Cancel()"/> method. /// </para> /// <para> /// If this property returns true, it only guarantees that cancellation has been requested. It does not /// guarantee that every handler registered with the corresponding token has finished executing, nor /// that cancellation requests have finished propagating to all registered handlers. Additional /// synchronization may be required, particularly in situations where related objects are being /// canceled concurrently. /// </para> /// </remarks> public bool IsCancellationRequested => _state != NotCanceledState; /// <summary>A simple helper to determine whether cancellation has finished.</summary> internal bool IsCancellationCompleted => _state == NotifyingCompleteState; /// <summary>Gets the <see cref="CancellationToken"/> associated with this <see cref="CancellationTokenSource"/>.</summary> /// <value>The <see cref="CancellationToken"/> associated with this <see cref="CancellationTokenSource"/>.</value> /// <exception cref="ObjectDisposedException">The token source has been disposed.</exception> public CancellationToken Token { get { ThrowIfDisposed(); return new CancellationToken(this); } } internal WaitHandle WaitHandle { get { ThrowIfDisposed(); // Return the handle if it was already allocated. if (_kernelEvent != null) { return _kernelEvent; } // Lazily-initialize the handle. var mre = new ManualResetEvent(false); if (Interlocked.CompareExchange(ref _kernelEvent, mre, null) != null) { mre.Dispose(); } // There is a race condition between checking IsCancellationRequested and setting the event. // However, at this point, the kernel object definitely exists and the cases are: // 1. if IsCancellationRequested = true, then we will call Set() // 2. if IsCancellationRequested = false, then NotifyCancellation will see that the event exists, and will call Set(). if (IsCancellationRequested) { _kernelEvent.Set(); } return _kernelEvent; } } /// <summary>Initializes the <see cref="CancellationTokenSource"/>.</summary> public CancellationTokenSource() { } /// <summary> /// Constructs a <see cref="CancellationTokenSource"/> that will be canceled after a specified time span. /// </summary> /// <param name="delay">The time span to wait before canceling this <see cref="CancellationTokenSource"/></param> /// <exception cref="ArgumentOutOfRangeException"> /// The <paramref name="delay"/> is less than -1 or greater than the maximum allowed timer duration. /// </exception> /// <remarks> /// <para> /// The countdown for the delay starts during the call to the constructor. When the delay expires, /// the constructed <see cref="CancellationTokenSource"/> is canceled, if it has /// not been canceled already. /// </para> /// <para> /// Subsequent calls to CancelAfter will reset the delay for the constructed /// <see cref="CancellationTokenSource"/>, if it has not been /// canceled already. /// </para> /// </remarks> public CancellationTokenSource(TimeSpan delay) { long totalMilliseconds = (long)delay.TotalMilliseconds; if (totalMilliseconds < -1 || totalMilliseconds > Timer.MaxSupportedTimeout) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.delay); } InitializeWithTimer((uint)totalMilliseconds); } /// <summary> /// Constructs a <see cref="CancellationTokenSource"/> that will be canceled after a specified time span. /// </summary> /// <param name="millisecondsDelay">The time span to wait before canceling this <see cref="CancellationTokenSource"/></param> /// <exception cref="ArgumentOutOfRangeException"> /// The exception that is thrown when <paramref name="millisecondsDelay"/> is less than -1. /// </exception> /// <remarks> /// <para> /// The countdown for the millisecondsDelay starts during the call to the constructor. When the millisecondsDelay expires, /// the constructed <see cref="CancellationTokenSource"/> is canceled (if it has /// not been canceled already). /// </para> /// <para> /// Subsequent calls to CancelAfter will reset the millisecondsDelay for the constructed /// <see cref="CancellationTokenSource"/>, if it has not been /// canceled already. /// </para> /// </remarks> public CancellationTokenSource(int millisecondsDelay) { if (millisecondsDelay < -1) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsDelay); } InitializeWithTimer((uint)millisecondsDelay); } /// <summary> /// Common initialization logic when constructing a CTS with a delay parameter. /// A zero delay will result in immediate cancellation. /// </summary> private void InitializeWithTimer(uint millisecondsDelay) { if (millisecondsDelay == 0) { _state = NotifyingCompleteState; } else { _timer = new TimerQueueTimer(s_timerCallback, this, millisecondsDelay, Timeout.UnsignedInfinite, flowExecutionContext: false); // The timer roots this CTS instance while it's scheduled. That is by design, so // that code like: // new CancellationTokenSource(timeout).Token.Register(() => ...); // will successfully invoke the delegate after the timeout. } } /// <summary>Communicates a request for cancellation.</summary> /// <remarks> /// <para> /// The associated <see cref="CancellationToken" /> will be notified of the cancellation /// and will transition to a state where <see cref="CancellationToken.IsCancellationRequested"/> returns true. /// Any callbacks or cancelable operations registered with the <see cref="CancellationToken"/> will be executed. /// </para> /// <para> /// Cancelable operations and callbacks registered with the token should not throw exceptions. /// However, this overload of Cancel will aggregate any exceptions thrown into a <see cref="AggregateException"/>, /// such that one callback throwing an exception will not prevent other registered callbacks from being executed. /// </para> /// <para> /// The <see cref="ExecutionContext"/> that was captured when each callback was registered /// will be reestablished when the callback is invoked. /// </para> /// </remarks> /// <exception cref="AggregateException">An aggregate exception containing all the exceptions thrown /// by the registered callbacks on the associated <see cref="CancellationToken"/>.</exception> /// <exception cref="ObjectDisposedException">This <see cref="CancellationTokenSource"/> has been disposed.</exception> public void Cancel() => Cancel(false); /// <summary>Communicates a request for cancellation.</summary> /// <remarks> /// <para> /// The associated <see cref="CancellationToken" /> will be notified of the cancellation and will transition to a state where /// <see cref="CancellationToken.IsCancellationRequested"/> returns true. Any callbacks or cancelable operationsregistered /// with the <see cref="CancellationToken"/> will be executed. /// </para> /// <para> /// Cancelable operations and callbacks registered with the token should not throw exceptions. /// If <paramref name="throwOnFirstException"/> is true, an exception will immediately propagate out of the /// call to Cancel, preventing the remaining callbacks and cancelable operations from being processed. /// If <paramref name="throwOnFirstException"/> is false, this overload will aggregate any /// exceptions thrown into a <see cref="AggregateException"/>, /// such that one callback throwing an exception will not prevent other registered callbacks from being executed. /// </para> /// <para> /// The <see cref="ExecutionContext"/> that was captured when each callback was registered /// will be reestablished when the callback is invoked. /// </para> /// </remarks> /// <param name="throwOnFirstException">Specifies whether exceptions should immediately propagate.</param> /// <exception cref="AggregateException">An aggregate exception containing all the exceptions thrown /// by the registered callbacks on the associated <see cref="CancellationToken"/>.</exception> /// <exception cref="ObjectDisposedException">This <see cref="CancellationTokenSource"/> has been disposed.</exception> public void Cancel(bool throwOnFirstException) { ThrowIfDisposed(); NotifyCancellation(throwOnFirstException); } /// <summary>Schedules a Cancel operation on this <see cref="CancellationTokenSource"/>.</summary> /// <param name="delay">The time span to wait before canceling this <see cref="CancellationTokenSource"/>. /// </param> /// <exception cref="ObjectDisposedException">The exception thrown when this <see /// cref="CancellationTokenSource"/> has been disposed. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The <paramref name="delay"/> is less than -1 or greater than maximum allowed timer duration. /// </exception> /// <remarks> /// <para> /// The countdown for the delay starts during this call. When the delay expires, /// this <see cref="CancellationTokenSource"/> is canceled, if it has /// not been canceled already. /// </para> /// <para> /// Subsequent calls to CancelAfter will reset the delay for this /// <see cref="CancellationTokenSource"/>, if it has not been canceled already. /// </para> /// </remarks> public void CancelAfter(TimeSpan delay) { long totalMilliseconds = (long)delay.TotalMilliseconds; if (totalMilliseconds < -1 || totalMilliseconds > Timer.MaxSupportedTimeout) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.delay); } CancelAfter((uint)totalMilliseconds); } /// <summary> /// Schedules a Cancel operation on this <see cref="CancellationTokenSource"/>. /// </summary> /// <param name="millisecondsDelay">The time span to wait before canceling this <see /// cref="CancellationTokenSource"/>. /// </param> /// <exception cref="ObjectDisposedException">The exception thrown when this <see /// cref="CancellationTokenSource"/> has been disposed. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The exception thrown when <paramref name="millisecondsDelay"/> is less than -1. /// </exception> /// <remarks> /// <para> /// The countdown for the millisecondsDelay starts during this call. When the millisecondsDelay expires, /// this <see cref="CancellationTokenSource"/> is canceled, if it has /// not been canceled already. /// </para> /// <para> /// Subsequent calls to CancelAfter will reset the millisecondsDelay for this /// <see cref="CancellationTokenSource"/>, if it has not been /// canceled already. /// </para> /// </remarks> public void CancelAfter(int millisecondsDelay) { if (millisecondsDelay < -1) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.millisecondsDelay); } CancelAfter((uint)millisecondsDelay); } private void CancelAfter(uint millisecondsDelay) { ThrowIfDisposed(); if (IsCancellationRequested) { return; } // There is a race condition here as a Cancel could occur between the check of // IsCancellationRequested and the creation of the timer. This is benign; in the // worst case, a timer will be created that has no effect when it expires. // Also, if Dispose() is called right here (after ThrowIfDisposed(), before timer // creation), it would result in a leaked Timer object (at least until the timer // expired and Disposed itself). But this would be considered bad behavior, as // Dispose() is not thread-safe and should not be called concurrently with CancelAfter(). TimerQueueTimer? timer = _timer; if (timer == null) { // Lazily initialize the timer in a thread-safe fashion. // Initially set to "never go off" because we don't want to take a // chance on a timer "losing" the initialization and then // cancelling the token before it (the timer) can be disposed. timer = new TimerQueueTimer(s_timerCallback, this, Timeout.UnsignedInfinite, Timeout.UnsignedInfinite, flowExecutionContext: false); TimerQueueTimer? currentTimer = Interlocked.CompareExchange(ref _timer, timer, null); if (currentTimer != null) { // We did not initialize the timer. Dispose the new timer. timer.Close(); timer = currentTimer; } } timer.Change(millisecondsDelay, Timeout.UnsignedInfinite, throwIfDisposed: false); } /// <summary> /// Attempts to reset the <see cref="CancellationTokenSource"/> to be used for an unrelated operation. /// </summary> /// <returns> /// true if the <see cref="CancellationTokenSource"/> has not had cancellation requested and could /// have its state reset to be reused for a subsequent operation; otherwise, false. /// </returns> /// <remarks> /// <see cref="TryReset"/> is intended to be used by the sole owner of the <see cref="CancellationTokenSource"/> /// when it is known that the operation with which the <see cref="CancellationTokenSource"/> was used has /// completed, no one else will be attempting to cancel it, and any registrations still remaining are erroneous. /// Upon a successful reset, such registrations will no longer be notified for any subsequent cancellation of the /// <see cref="CancellationTokenSource"/>; however, if any component still holds a reference to this /// <see cref="CancellationTokenSource"/> either directly or indirectly via a <see cref="CancellationToken"/> /// handed out from it, polling via their reference will show the current state any time after the reset as /// it's the same instance. Usage of <see cref="TryReset"/> concurrently with requesting cancellation is not /// thread-safe and may result in TryReset returning true even if cancellation was already requested and may result /// in registrations not being invoked as part of the concurrent cancellation request. /// </remarks> public bool TryReset() { ThrowIfDisposed(); // We can only reset if cancellation has not yet been requested: we never want to allow a CancellationToken // to transition from canceled to non-canceled. if (_state == NotCanceledState) { // If there is no timer, then we're free to reset. If there is a timer, then we need to first try // to reset it to be infinite so that it won't fire, and then recognize that it could have already // fired by the time we successfully changed it, and so check to see whether that's possibly the case. // If we successfully reset it and it never fired, then we can be sure it won't trigger cancellation. bool reset = _timer is not TimerQueueTimer timer || (timer.Change(Timeout.UnsignedInfinite, Timeout.UnsignedInfinite, throwIfDisposed: false) && !timer._everQueued); if (reset) { // We're not canceled and no timer will run to cancel us. // Clear out all the registrations, and return that we've successfully reset. Volatile.Read(ref _registrations)?.UnregisterAll(); return true; } } // Failed to reset. return false; } /// <summary>Releases the resources used by this <see cref="CancellationTokenSource" />.</summary> /// <remarks>This method is not thread-safe for any other concurrent calls.</remarks> public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// <summary> /// Releases the unmanaged resources used by the <see cref="CancellationTokenSource" /> class and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) { // We specifically tolerate that a callback can be unregistered // after the CTS has been disposed and/or concurrently with cts.Dispose(). // This is safe without locks because Dispose doesn't interact with values // in the callback partitions, only nulling out the ref to existing partitions. // // We also tolerate that a callback can be registered after the CTS has been // disposed. This is safe because InternalRegister is tolerant // of _callbackPartitions becoming null during its execution. However, // we run the acceptable risk of _callbackPartitions getting reinitialized // to non-null if there is a race between Dispose and Register, in which case this // instance may unnecessarily hold onto a registered callback. But that's no worse // than if Dispose wasn't safe to use concurrently, as Dispose would never be called, // and thus no handlers would be dropped. // // And, we tolerate Dispose being used concurrently with Cancel. This is necessary // to properly support, e.g., LinkedCancellationTokenSource, where, due to common usage patterns, // it's possible for this pairing to occur with valid usage (e.g. a component accepts // an external CancellationToken and uses CreateLinkedTokenSource to combine it with an // internal source of cancellation, then Disposes of that linked source, which could // happen at the same time the external entity is requesting cancellation). TimerQueueTimer? timer = _timer; if (timer != null) { _timer = null; timer.Close(); // TimerQueueTimer.Close is thread-safe } _registrations = null; // allow the GC to clean up registrations // If a kernel event was created via WaitHandle, we'd like to Dispose of it. However, // we only want to do so if it's not being used by Cancel concurrently. First, we // interlocked exchange it to be null, and then we check whether cancellation is currently // in progress. NotifyCancellation will only try to set the event if it exists after it's // transitioned to and while it's in the NotifyingState. if (_kernelEvent != null) { ManualResetEvent? mre = Interlocked.Exchange<ManualResetEvent?>(ref _kernelEvent!, null); if (mre != null && _state != NotifyingState) { mre.Dispose(); } } _disposed = true; } } /// <summary>Throws an exception if the source has been disposed.</summary> private void ThrowIfDisposed() { if (_disposed) { ThrowHelper.ThrowObjectDisposedException(ExceptionResource.CancellationTokenSource_Disposed); } } /// <summary> /// Registers a callback object. If cancellation has already occurred, the /// callback will have been run by the time this method returns. /// </summary> internal CancellationTokenRegistration Register( Delegate callback, object? stateForCallback, SynchronizationContext? syncContext, ExecutionContext? executionContext) { Debug.Assert(this != s_neverCanceledSource, "This source should never be exposed via a CancellationToken."); Debug.Assert(callback is Action<object?> || callback is Action<object?, CancellationToken>); // If not canceled, register the handler; if canceled already, run the callback synchronously. if (!IsCancellationRequested) { // We allow Dispose to be called concurrently with Register. While this is not a recommended practice, // consumers can and do use it this way. if (_disposed) { return default; } // Get the registrations object. It's lazily initialized to keep the size of a CTS smaller for situations // where all operations associated with the CTS complete synchronously and never actually need to register, // or all only poll. Registrations? registrations = Volatile.Read(ref _registrations); if (registrations is null) { registrations = new Registrations(this); registrations = Interlocked.CompareExchange(ref _registrations, registrations, null) ?? registrations; } // If it looks like there's a node in the freelist we could grab, grab the lock and try to get, configure, // and register the node. CallbackNode? node = null; long id = 0; if (registrations.FreeNodeList is not null) { registrations.EnterLock(); try { // Try to take a free node. If we're able to, configure the node and register it. node = registrations.FreeNodeList; if (node is not null) { Debug.Assert(node.Prev == null, "Nodes in the free list should all have a null Prev"); registrations.FreeNodeList = node.Next; node.Id = id = registrations.NextAvailableId++; node.Callback = callback; node.CallbackState = stateForCallback; node.ExecutionContext = executionContext; node.SynchronizationContext = syncContext; node.Next = registrations.Callbacks; registrations.Callbacks = node; if (node.Next != null) { node.Next.Prev = node; } } } finally { registrations.ExitLock(); } } // If we were unsuccessful in using a free node, create a new one, configure it, and register it. if (node is null) { // Allocate the node if we couldn't get one from the free list. We avoid // doing this while holding the spin lock, to avoid a potentially arbitrary // amount of GC-related work under the lock, which we aim to keep very tight, // just a few assignments. node = new CallbackNode(registrations); node.Callback = callback; node.CallbackState = stateForCallback; node.ExecutionContext = executionContext; node.SynchronizationContext = syncContext; registrations.EnterLock(); try { node.Id = id = registrations.NextAvailableId++; node.Next = registrations.Callbacks; if (node.Next != null) { node.Next.Prev = node; } registrations.Callbacks = node; } finally { registrations.ExitLock(); } } // If cancellation hasn't been requested, return the registration. // if cancellation has been requested, try to undo the registration and run the callback // ourselves, but if we can't unregister it (e.g. the thread running Cancel snagged // our callback for execution), return the registration so that the caller can wait // for callback completion in ctr.Dispose(). Debug.Assert(id != 0, "IDs should never be the reserved value 0."); if (!IsCancellationRequested || !registrations.Unregister(id, node)) { return new CancellationTokenRegistration(id, node); } } // Cancellation already occurred. Run the callback on this thread and return an empty registration. Invoke(callback, stateForCallback, this); return default; } private void NotifyCancellation(bool throwOnFirstException) { // If we're the first to signal cancellation, do the main extra work. if (!IsCancellationRequested && Interlocked.CompareExchange(ref _state, NotifyingState, NotCanceledState) == NotCanceledState) { // Dispose of the timer, if any. Dispose may be running concurrently here, but TimerQueueTimer.Close is thread-safe. TimerQueueTimer? timer = _timer; if (timer != null) { _timer = null; timer.Close(); } // Set the event if it's been lazily initialized and hasn't yet been disposed of. Dispose may // be running concurrently, in which case either it'll have set m_kernelEvent back to null and // we won't see it here, or it'll see that we've transitioned to NOTIFYING and will skip disposing it, // leaving cleanup to finalization. _kernelEvent?.Set(); // update the MRE value. // - late enlisters to the Canceled event will have their callbacks called immediately in the Register() methods. // - Callbacks are not called inside a lock. // - After transition, no more delegates will be added to the // - list of handlers, and hence it can be consumed and cleared at leisure by ExecuteCallbackHandlers. ExecuteCallbackHandlers(throwOnFirstException); Debug.Assert(IsCancellationCompleted, "Expected cancellation to have finished"); } } /// <summary>Invoke all registered callbacks.</summary> /// <remarks>The handlers are invoked synchronously in LIFO order.</remarks> private void ExecuteCallbackHandlers(bool throwOnFirstException) { Debug.Assert(IsCancellationRequested, "ExecuteCallbackHandlers should only be called after setting IsCancellationRequested->true"); // If there are no callbacks to run, we can safely exit. Any race conditions to lazy initialize it // will see IsCancellationRequested and will then run the callback themselves. Registrations? registrations = Interlocked.Exchange(ref _registrations, null); if (registrations is null) { Interlocked.Exchange(ref _state, NotifyingCompleteState); return; } // Record the threadID being used for running the callbacks. registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId; List<Exception>? exceptionList = null; try { // We call the delegates in LIFO order on each partition so that callbacks fire 'deepest first'. // This is intended to help with nesting scenarios so that child enlisters cancel before their parents. // Iterate through all nodes in the partition. We remove each node prior // to processing it. This allows for unregistration of subsequent registrations // to still be effective even as other registrations are being invoked. while (true) { CallbackNode? node; registrations.EnterLock(); try { // Pop the next registration from the callbacks list. node = registrations.Callbacks; if (node == null) { // No more registrations to process. break; } Debug.Assert(node.Registrations.Source == this); Debug.Assert(node.Prev == null); if (node.Next != null) { node.Next.Prev = null; } registrations.Callbacks = node.Next; // Publish the intended callback ID, to ensure ctr.Dispose can tell if a wait is necessary. // This write happens while the lock is held so that Dispose is either able to successfully // unregister or is guaranteed to see an accurate executing callback ID, since it takes // the same lock to remove the node from the callback list. registrations.ExecutingCallbackId = node.Id; // Now that we've grabbed the Id, reset the node's Id to 0. This signals // to code unregistering that the node is no longer associated with a callback. node.Id = 0; } finally { registrations.ExitLock(); } // Invoke the callback on this thread if there's no sync context or on the // target sync context if there is one. try { if (node.SynchronizationContext != null) { // Transition to the target syncContext and continue there. node.SynchronizationContext.Send(static s => { var n = (CallbackNode)s!; n.Registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId; n.ExecuteCallback(); }, node); registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId; // above may have altered ThreadIDExecutingCallbacks, so reset it } else { node.ExecuteCallback(); } } catch (Exception ex) when (!throwOnFirstException) { // Store the exception and continue (exceptionList ??= new List<Exception>()).Add(ex); } // Drop the node. While we could add it to the free list, doing so has cost (we'd need to take the lock again) // and very limited value. Since a source can only be canceled once, and after it's canceled registrations don't // need nodes, the only benefit to putting this on the free list would be if Register raced with cancellation // occurring, such that it could have used this free node but would instead need to allocate a new node (if // there wasn't another free node available). } } finally { _state = NotifyingCompleteState; Interlocked.Exchange(ref registrations.ExecutingCallbackId, 0); // for safety, prevent reorderings crossing this point and seeing inconsistent state. } if (exceptionList != null) { Debug.Assert(exceptionList.Count > 0, $"Expected {exceptionList.Count} > 0"); throw new AggregateException(exceptionList); } } /// <summary> /// Creates a <see cref="CancellationTokenSource"/> that will be in the canceled state /// when any of the source tokens are in the canceled state. /// </summary> /// <param name="token1">The first <see cref="CancellationToken">CancellationToken</see> to observe.</param> /// <param name="token2">The second <see cref="CancellationToken">CancellationToken</see> to observe.</param> /// <returns>A <see cref="CancellationTokenSource"/> that is linked /// to the source tokens.</returns> public static CancellationTokenSource CreateLinkedTokenSource(CancellationToken token1, CancellationToken token2) => !token1.CanBeCanceled ? CreateLinkedTokenSource(token2) : token2.CanBeCanceled ? new Linked2CancellationTokenSource(token1, token2) : (CancellationTokenSource)new Linked1CancellationTokenSource(token1); /// <summary> /// Creates a <see cref="CancellationTokenSource"/> that will be in the canceled state /// when the supplied token is in the canceled state. /// </summary> /// <param name="token">The <see cref="CancellationToken">CancellationToken</see> to observe.</param> /// <returns>A <see cref="CancellationTokenSource"/> that is linked to the source token.</returns> public static CancellationTokenSource CreateLinkedTokenSource(CancellationToken token) => token.CanBeCanceled ? new Linked1CancellationTokenSource(token) : new CancellationTokenSource(); /// <summary> /// Creates a <see cref="CancellationTokenSource"/> that will be in the canceled state /// when any of the source tokens are in the canceled state. /// </summary> /// <param name="tokens">The <see cref="CancellationToken">CancellationToken</see> instances to observe.</param> /// <returns>A <see cref="CancellationTokenSource"/> that is linked to the source tokens.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="tokens"/> is null.</exception> public static CancellationTokenSource CreateLinkedTokenSource(params CancellationToken[] tokens!!) => tokens.Length switch { 0 => throw new ArgumentException(SR.CancellationToken_CreateLinkedToken_TokensIsEmpty), 1 => CreateLinkedTokenSource(tokens[0]), 2 => CreateLinkedTokenSource(tokens[0], tokens[1]), // a defensive copy is not required as the array has value-items that have only a single reference field, // hence each item cannot be null itself, and reads of the payloads cannot be torn. _ => new LinkedNCancellationTokenSource(tokens), }; private sealed class Linked1CancellationTokenSource : CancellationTokenSource { private readonly CancellationTokenRegistration _reg1; internal Linked1CancellationTokenSource(CancellationToken token1) { _reg1 = token1.UnsafeRegister(LinkedNCancellationTokenSource.s_linkedTokenCancelDelegate, this); } protected override void Dispose(bool disposing) { if (!disposing || _disposed) { return; } _reg1.Dispose(); base.Dispose(disposing); } } private sealed class Linked2CancellationTokenSource : CancellationTokenSource { private readonly CancellationTokenRegistration _reg1; private readonly CancellationTokenRegistration _reg2; internal Linked2CancellationTokenSource(CancellationToken token1, CancellationToken token2) { _reg1 = token1.UnsafeRegister(LinkedNCancellationTokenSource.s_linkedTokenCancelDelegate, this); _reg2 = token2.UnsafeRegister(LinkedNCancellationTokenSource.s_linkedTokenCancelDelegate, this); } protected override void Dispose(bool disposing) { if (!disposing || _disposed) { return; } _reg1.Dispose(); _reg2.Dispose(); base.Dispose(disposing); } } private sealed class LinkedNCancellationTokenSource : CancellationTokenSource { internal static readonly Action<object?> s_linkedTokenCancelDelegate = static s => { Debug.Assert(s is CancellationTokenSource, $"Expected {typeof(CancellationTokenSource)}, got {s}"); ((CancellationTokenSource)s).NotifyCancellation(throwOnFirstException: false); // skip ThrowIfDisposed() check in Cancel() }; private CancellationTokenRegistration[]? _linkingRegistrations; internal LinkedNCancellationTokenSource(CancellationToken[] tokens) { _linkingRegistrations = new CancellationTokenRegistration[tokens.Length]; for (int i = 0; i < tokens.Length; i++) { if (tokens[i].CanBeCanceled) { _linkingRegistrations[i] = tokens[i].UnsafeRegister(s_linkedTokenCancelDelegate, this); } // Empty slots in the array will be default(CancellationTokenRegistration), which are nops to Dispose. // Based on usage patterns, such occurrences should also be rare, such that it's not worth resizing // the array and incurring the related costs. } } protected override void Dispose(bool disposing) { if (!disposing || _disposed) { return; } CancellationTokenRegistration[]? linkingRegistrations = _linkingRegistrations; if (linkingRegistrations != null) { _linkingRegistrations = null; // release for GC once we're done enumerating for (int i = 0; i < linkingRegistrations.Length; i++) { linkingRegistrations[i].Dispose(); } } base.Dispose(disposing); } } private static void Invoke(Delegate d, object? state, CancellationTokenSource source) { Debug.Assert(d is Action<object?> || d is Action<object?, CancellationToken>); if (d is Action<object?> actionWithState) { actionWithState(state); } else { ((Action<object?, CancellationToken>)d)(state, new CancellationToken(source)); } } /// <summary>Set of all the registrations in the token source.</summary> /// <remarks> /// Separated out into a separate instance to keep CancellationTokenSource smaller for the case where one is created but nothing is registered with it. /// This happens not infrequently, in particular when one is created for an operation that ends up completing synchronously / quickly. /// </remarks> internal sealed class Registrations { /// <summary>The associated source.</summary> public readonly CancellationTokenSource Source; /// <summary>Doubly-linked list of callbacks registered with the source. Callbacks are removed during unregistration and as they're invoked.</summary> public CallbackNode? Callbacks; /// <summary>Singly-linked list of free nodes that can be used for subsequent callback registrations.</summary> public CallbackNode? FreeNodeList; /// <summary>Every callback is assigned a unique, never-reused ID. This defines the next available ID.</summary> public long NextAvailableId = 1; // avoid using 0, as that's the default long value and used to represent an empty node /// <summary>Tracks the running callback to assist ctr.Dispose() to wait for the target callback to complete.</summary> public long ExecutingCallbackId; /// <summary>The ID of the thread currently executing the main body of CTS.Cancel()</summary> /// <remarks> /// This helps us to know if a call to ctr.Dispose() is running 'within' a cancellation callback. /// This is updated as we move between the main thread calling cts.Cancel() and any syncContexts /// that are used to actually run the callbacks. /// </remarks> public volatile int ThreadIDExecutingCallbacks = -1; /// <summary>Spin lock that protects state in the instance.</summary> private int _lock; /// <summary>Initializes the instance.</summary> /// <param name="source">The associated source.</param> public Registrations(CancellationTokenSource source) => Source = source; [MethodImpl(MethodImplOptions.AggressiveInlining)] // used in only two places, one of which is a hot path private void Recycle(CallbackNode node) { Debug.Assert(_lock == 1); // Clear out the unused node and put it on the singly-linked free list. // The only field we don't clear out is the associated Registrations, as that's fixed // throughout the node's lifetime. node.Id = 0; node.Callback = null; node.CallbackState = null; node.ExecutionContext = null; node.SynchronizationContext = null; node.Prev = null; node.Next = FreeNodeList; FreeNodeList = node; } /// <summary>Unregisters a callback.</summary> /// <param name="id">The expected id of the registration.</param> /// <param name="node">The callback node.</param> /// <returns>true if the node was found and removed; false if it couldn't be found or didn't match the provided id.</returns> public bool Unregister(long id, CallbackNode node) { Debug.Assert(node != null, "Expected non-null node"); Debug.Assert(node.Registrations == this, "Expected node to come from this registrations instance"); if (id == 0) { // In general, we won't get 0 passed in here. However, race conditions between threads // Unregistering and also zero'ing out the CancellationTokenRegistration could cause 0 // to be passed in here, in which case there's nothing to do. 0 is never a valid id. return false; } EnterLock(); try { if (node.Id != id) { // Either: // - The callback is currently or has already been invoked, in which case node.Id // will no longer equal the assigned id, as it will have transitioned to 0. // - The registration was already disposed of, in which case node.Id will similarly // no longer equal the assigned id, as it will have transitioned to 0 and potentially // then to another (larger) value when reused for a new registration. // In either case, there's nothing to unregister. return false; } // The registration must still be in the callbacks list. Remove it. if (Callbacks == node) { Debug.Assert(node.Prev == null); Callbacks = node.Next; } else { Debug.Assert(node.Prev != null); node.Prev.Next = node.Next; } if (node.Next != null) { node.Next.Prev = node.Prev; } Recycle(node); return true; } finally { ExitLock(); } } /// <summary>Moves all registrations to the free list.</summary> public void UnregisterAll() { EnterLock(); try { // Null out all callbacks. CallbackNode? node = Callbacks; Callbacks = null; // Reset and move each node that was in the callbacks list to the free list. while (node != null) { CallbackNode? next = node.Next; Recycle(node); node = next; } } finally { ExitLock(); } } /// <summary> /// Wait for a single callback to complete (or, more specifically, to not be running). /// It is ok to call this method if the callback has already finished. /// Calling this method before the target callback has been selected for execution would be an error. /// </summary> public void WaitForCallbackToComplete(long id) { SpinWait sw = default; while (Volatile.Read(ref ExecutingCallbackId) == id) { sw.SpinOnce(); // spin, as we assume callback execution is fast and that this situation is rare. } } /// <summary> /// Asynchronously wait for a single callback to complete (or, more specifically, to not be running). /// It is ok to call this method if the callback has already finished. /// Calling this method before the target callback has been selected for execution would be an error. /// </summary> public ValueTask WaitForCallbackToCompleteAsync(long id) { // If the currently executing callback is not the target one, then the target one has already // completed and we can simply return. This should be the most common case, as the caller // calls if we're currently canceling but doesn't know what callback is running, if any. if (Volatile.Read(ref ExecutingCallbackId) != id) { return default; } // The specified callback is actually running: queue an async loop that'll poll for the currently executing // callback to complete. While such polling isn't ideal, we expect this to be a rare case (disposing while // the associated callback is running), and brief when it happens (so the polling will be minimal), and making // this work with a callback mechanism will add additional cost to other more common cases. return new ValueTask(Task.Factory.StartNew(static async s => { var state = (TupleSlim<Registrations, long>)s!; while (Volatile.Read(ref state.Item1.ExecutingCallbackId) == state.Item2) { await Task.Yield(); } }, new TupleSlim<Registrations, long>(this, id), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap()); } /// <summary>Enters the lock for this instance. The current thread must not be holding the lock, but that is not validated.</summary> public void EnterLock() { ref int value = ref _lock; if (Interlocked.Exchange(ref value, 1) != 0) { Contention(ref value); [MethodImpl(MethodImplOptions.NoInlining)] static void Contention(ref int value) { SpinWait sw = default; do { sw.SpinOnce(); } while (Interlocked.Exchange(ref value, 1) == 1); } } } /// <summary>Exits the lock for this instance. The current thread must be holding the lock, but that is not validated.</summary> public void ExitLock() { Debug.Assert(_lock == 1); Volatile.Write(ref _lock, 0); } } /// <summary>All of the state associated a registered callback, in a node that's part of a linked list of registered callbacks.</summary> internal sealed class CallbackNode { public readonly Registrations Registrations; public CallbackNode? Prev; public CallbackNode? Next; public long Id; public Delegate? Callback; // Action<object> or Action<object,CancellationToken> public object? CallbackState; public ExecutionContext? ExecutionContext; public SynchronizationContext? SynchronizationContext; public CallbackNode(Registrations registrations) { Debug.Assert(registrations != null, "Expected non-null parent registrations"); Registrations = registrations; } public void ExecuteCallback() { ExecutionContext? context = ExecutionContext; if (context is null) { Debug.Assert(Callback != null); Invoke(Callback, CallbackState, Registrations.Source); } else { ExecutionContext.RunInternal(context, static s => { var node = (CallbackNode)s!; Debug.Assert(node.Callback != null); Invoke(node.Callback, node.CallbackState, node.Registrations.Source); }, this); } } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/SubtractRoundedHighNarrowingLower.Vector64.Int32.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 SubtractRoundedHighNarrowingLower_Vector64_Int32() { var test = new SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32(); 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__SubtractRoundedHighNarrowingLower_Vector64_Int32 { 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(Int64[] inArray1, Int64[] inArray2, Int32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>(); 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<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int64, 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<Int64> _fld1; public Vector128<Int64> _fld2; 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>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32 testClass) { var result = AdvSimd.SubtractRoundedHighNarrowingLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32 testClass) { fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(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<Int64>>() / sizeof(Int64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); private static Int64[] _data1 = new Int64[Op1ElementCount]; private static Int64[] _data2 = new Int64[Op2ElementCount]; private static Vector128<Int64> _clsVar1; private static Vector128<Int64> _clsVar2; private Vector128<Int64> _fld1; private Vector128<Int64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32() { 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>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); } public SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32() { 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 < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } _dataTable = new DataTable(_data1, _data2, new Int32[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.SubtractRoundedHighNarrowingLower( Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_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.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_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).GetMethod(nameof(AdvSimd.SubtractRoundedHighNarrowingLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractRoundedHighNarrowingLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SubtractRoundedHighNarrowingLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int64>* pClsVar1 = &_clsVar1) fixed (Vector128<Int64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pClsVar1)), AdvSimd.LoadVector128((Int64*)(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<Int64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr); var result = AdvSimd.SubtractRoundedHighNarrowingLower(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((Int64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.SubtractRoundedHighNarrowingLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32(); var result = AdvSimd.SubtractRoundedHighNarrowingLower(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__SubtractRoundedHighNarrowingLower_Vector64_Int32(); fixed (Vector128<Int64>* pFld1 = &test._fld1) fixed (Vector128<Int64>* pFld2 = &test._fld2) { var result = AdvSimd.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SubtractRoundedHighNarrowingLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(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.SubtractRoundedHighNarrowingLower(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.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(&test._fld1)), AdvSimd.LoadVector128((Int64*)(&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<Int64> op1, Vector128<Int64> op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[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 inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int64[] left, Int64[] right, Int32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SubtractRoundedHighNarrowing(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SubtractRoundedHighNarrowingLower)}<Int32>(Vector128<Int64>, Vector128<Int64>): {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 SubtractRoundedHighNarrowingLower_Vector64_Int32() { var test = new SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32(); 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__SubtractRoundedHighNarrowingLower_Vector64_Int32 { 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(Int64[] inArray1, Int64[] inArray2, Int32[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<Int64>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Int64>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<Int32>(); 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<Int64, byte>(ref inArray1[0]), (uint)sizeOfinArray1); Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<Int64, 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<Int64> _fld1; public Vector128<Int64> _fld2; 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>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref testStruct._fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32 testClass) { var result = AdvSimd.SubtractRoundedHighNarrowingLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32 testClass) { fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(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<Int64>>() / sizeof(Int64); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Int64>>() / sizeof(Int64); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Int32>>() / sizeof(Int32); private static Int64[] _data1 = new Int64[Op1ElementCount]; private static Int64[] _data2 = new Int64[Op2ElementCount]; private static Vector128<Int64> _clsVar1; private static Vector128<Int64> _clsVar2; private Vector128<Int64> _fld1; private Vector128<Int64> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32() { 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>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); } public SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32() { 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 < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Int64>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } _dataTable = new DataTable(_data1, _data2, new Int32[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.SubtractRoundedHighNarrowingLower( Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_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.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_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).GetMethod(nameof(AdvSimd.SubtractRoundedHighNarrowingLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.SubtractRoundedHighNarrowingLower), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((Int64*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Int32>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.SubtractRoundedHighNarrowingLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<Int64>* pClsVar1 = &_clsVar1) fixed (Vector128<Int64>* pClsVar2 = &_clsVar2) { var result = AdvSimd.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pClsVar1)), AdvSimd.LoadVector128((Int64*)(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<Int64>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr); var result = AdvSimd.SubtractRoundedHighNarrowingLower(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((Int64*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((Int64*)(_dataTable.inArray2Ptr)); var result = AdvSimd.SubtractRoundedHighNarrowingLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__SubtractRoundedHighNarrowingLower_Vector64_Int32(); var result = AdvSimd.SubtractRoundedHighNarrowingLower(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__SubtractRoundedHighNarrowingLower_Vector64_Int32(); fixed (Vector128<Int64>* pFld1 = &test._fld1) fixed (Vector128<Int64>* pFld2 = &test._fld2) { var result = AdvSimd.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(pFld2)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = AdvSimd.SubtractRoundedHighNarrowingLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<Int64>* pFld1 = &_fld1) fixed (Vector128<Int64>* pFld2 = &_fld2) { var result = AdvSimd.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(pFld1)), AdvSimd.LoadVector128((Int64*)(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.SubtractRoundedHighNarrowingLower(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.SubtractRoundedHighNarrowingLower( AdvSimd.LoadVector128((Int64*)(&test._fld1)), AdvSimd.LoadVector128((Int64*)(&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<Int64> op1, Vector128<Int64> op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { Int64[] inArray1 = new Int64[Op1ElementCount]; Int64[] inArray2 = new Int64[Op2ElementCount]; Int32[] outArray = new Int32[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 inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<Int64>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Int32>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Int64[] left, Int64[] right, Int32[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.SubtractRoundedHighNarrowing(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.SubtractRoundedHighNarrowingLower)}<Int32>(Vector128<Int64>, Vector128<Int64>): {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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Diagnostics.TraceSource/src/System.Diagnostics.TraceSource.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <DefineConstants>$(DefineConstants);TRACE</DefineConstants> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <Compile Include="System\Diagnostics\BooleanSwitch.cs" /> <Compile Include="System\Diagnostics\CorrelationManager.cs" /> <Compile Include="System\Diagnostics\DefaultTraceListener.cs" /> <Compile Include="System\Diagnostics\DiagnosticsConfiguration.cs" /> <Compile Include="System\Diagnostics\SeverityFilter.cs" /> <Compile Include="System\Diagnostics\SourceFilter.cs" /> <Compile Include="System\Diagnostics\SourceLevels.cs" /> <Compile Include="System\Diagnostics\SourceSwitch.cs" /> <Compile Include="System\Diagnostics\Switch.cs" /> <Compile Include="System\Diagnostics\Trace.cs" /> <Compile Include="System\Diagnostics\TraceEventCache.cs" /> <Compile Include="System\Diagnostics\TraceEventType.cs" /> <Compile Include="System\Diagnostics\TraceFilter.cs" /> <Compile Include="System\Diagnostics\TraceInternal.cs" /> <Compile Include="System\Diagnostics\TraceLevel.cs" /> <Compile Include="System\Diagnostics\TraceListener.cs" /> <Compile Include="System\Diagnostics\TraceListeners.cs" /> <Compile Include="System\Diagnostics\TraceOptions.cs" /> <Compile Include="System\Diagnostics\TraceSource.cs" /> <Compile Include="System\Diagnostics\TraceSwitch.cs" /> <Compile Include="System\Diagnostics\SwitchAttribute.cs" /> <Compile Include="System\Diagnostics\SwitchLevelAttribute.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="$(CoreLibProject)" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Collections\src\System.Collections.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Collections.NonGeneric\src\System.Collections.NonGeneric.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Collections.Specialized\src\System.Collections.Specialized.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.ComponentModel.Primitives\src\System.ComponentModel.Primitives.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime\src\System.Runtime.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.Extensions\src\System.Runtime.Extensions.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Threading\src\System.Threading.csproj" /> <Reference Include="System.IO.FileSystem" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <DefineConstants>$(DefineConstants);TRACE</DefineConstants> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> <Nullable>enable</Nullable> </PropertyGroup> <ItemGroup> <Compile Include="System\Diagnostics\BooleanSwitch.cs" /> <Compile Include="System\Diagnostics\CorrelationManager.cs" /> <Compile Include="System\Diagnostics\DefaultTraceListener.cs" /> <Compile Include="System\Diagnostics\DiagnosticsConfiguration.cs" /> <Compile Include="System\Diagnostics\SeverityFilter.cs" /> <Compile Include="System\Diagnostics\SourceFilter.cs" /> <Compile Include="System\Diagnostics\SourceLevels.cs" /> <Compile Include="System\Diagnostics\SourceSwitch.cs" /> <Compile Include="System\Diagnostics\Switch.cs" /> <Compile Include="System\Diagnostics\Trace.cs" /> <Compile Include="System\Diagnostics\TraceEventCache.cs" /> <Compile Include="System\Diagnostics\TraceEventType.cs" /> <Compile Include="System\Diagnostics\TraceFilter.cs" /> <Compile Include="System\Diagnostics\TraceInternal.cs" /> <Compile Include="System\Diagnostics\TraceLevel.cs" /> <Compile Include="System\Diagnostics\TraceListener.cs" /> <Compile Include="System\Diagnostics\TraceListeners.cs" /> <Compile Include="System\Diagnostics\TraceOptions.cs" /> <Compile Include="System\Diagnostics\TraceSource.cs" /> <Compile Include="System\Diagnostics\TraceSwitch.cs" /> <Compile Include="System\Diagnostics\SwitchAttribute.cs" /> <Compile Include="System\Diagnostics\SwitchLevelAttribute.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="$(CoreLibProject)" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Collections\src\System.Collections.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Collections.NonGeneric\src\System.Collections.NonGeneric.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Collections.Specialized\src\System.Collections.Specialized.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.ComponentModel.Primitives\src\System.ComponentModel.Primitives.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime\src\System.Runtime.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.Extensions\src\System.Runtime.Extensions.csproj" /> <ProjectReference Include="$(LibrariesProjectRoot)System.Threading\src\System.Threading.csproj" /> <Reference Include="System.IO.FileSystem" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Private.Xml/tests/XmlSchema/XmlSchemaValidatorApi/System.Xml.XmlSchema.XmlSchemaValidatorApi.Tests.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> </PropertyGroup> <ItemGroup> <Compile Include="Constructor_AddSchema.cs" /> <Compile Include="CustomImplementations.cs" /> <Compile Include="ExceptionVerifier.cs" /> <Compile Include="GetExpectedAttributes.cs" /> <Compile Include="GetExpectedParticles.cs" /> <Compile Include="Initialize_EndValidation.cs" /> <Compile Include="PropertiesTests.cs" /> <Compile Include="ValidateAttribute.cs" /> <Compile Include="ValidateAttribute_String.cs" /> <Compile Include="ValidateElement.cs" /> <Compile Include="ValidateMisc.cs" /> <Compile Include="ValidateText_EndElement.cs" /> <Compile Include="ValidateText_String.cs" /> <Compile Include="ValidateWhitespace_String.cs" /> <Compile Include="ValidatorModule.cs" /> <Compile Include="XmlTestSettings.cs" /> <Compile Include="CXmlTestResolver.cs" /> <Compile Include="$(CommonTestPath)System\IO\TempDirectory.cs" Link="Common\System\IO\TempDirectory.cs" /> </ItemGroup> <ItemGroup> <Content Include="..\TestFiles\**\*" Link="TestFiles\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" Visible="false" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> </PropertyGroup> <ItemGroup> <Compile Include="Constructor_AddSchema.cs" /> <Compile Include="CustomImplementations.cs" /> <Compile Include="ExceptionVerifier.cs" /> <Compile Include="GetExpectedAttributes.cs" /> <Compile Include="GetExpectedParticles.cs" /> <Compile Include="Initialize_EndValidation.cs" /> <Compile Include="PropertiesTests.cs" /> <Compile Include="ValidateAttribute.cs" /> <Compile Include="ValidateAttribute_String.cs" /> <Compile Include="ValidateElement.cs" /> <Compile Include="ValidateMisc.cs" /> <Compile Include="ValidateText_EndElement.cs" /> <Compile Include="ValidateText_String.cs" /> <Compile Include="ValidateWhitespace_String.cs" /> <Compile Include="ValidatorModule.cs" /> <Compile Include="XmlTestSettings.cs" /> <Compile Include="CXmlTestResolver.cs" /> <Compile Include="$(CommonTestPath)System\IO\TempDirectory.cs" Link="Common\System\IO\TempDirectory.cs" /> </ItemGroup> <ItemGroup> <Content Include="..\TestFiles\**\*" Link="TestFiles\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" Visible="false" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/mono/mono/tests/verifier/invalid_funptr_double_free_regression.il
.assembly extern mscorlib { .ver 2:0:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. } .assembly extern System.Core { .ver 3:5:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. } .assembly 'test-anon-01' { .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. .hash algorithm 0x00008004 .ver 0:0:0:0 } .module 'test-anon-01.exe' // GUID = {38A511CD-E5D7-4DA2-88C0-A137887BAFBC} .class public auto ansi beforefieldinit Test extends [mscorlib]System.Object { .field private static class [System.Core]System.Func`1<!!0> '<>f__am$cache0' .custom instance void class [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::'.ctor'() = (01 00 00 00 ) // .... // method line 1 .method public hidebysig specialname rtspecialname instance default void '.ctor' () cil managed { // Method begins at RVA 0x20ec // Code size 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void object::'.ctor'() IL_0006: ret } // end of method Test::.ctor // method line 2 .method private static hidebysig default class [System.Core]System.Func`1<!!T> XX<T> () cil managed { // Method begins at RVA 0x20f4 // Code size 32 (0x20) .maxstack 4 .locals init ( class [System.Core]System.Func`1<!!T> V_0) IL_0000: ldsfld class [System.Core]System.Func`1<!!0> Test::'<>f__am$cache0' IL_0005: brtrue.s IL_0018 IL_0007: ldnull IL_0008: ldftn !!0 class Test::'<XX>m__0'<!!0> () IL_000e: newobj instance void class [System.Core]System.Func`1<!!T>::'.ctor'(object, native int) IL_0013: stsfld class [System.Core]System.Func`1<!!0> Test::'<>f__am$cache0' IL_0018: ldsfld class [System.Core]System.Func`1<!!0> Test::'<>f__am$cache0' IL_001d: stloc.0 IL_001e: ldloc.0 IL_001f: ret } // end of method Test::XX // method line 3 .method public static hidebysig default int32 Main () cil managed { // Method begins at RVA 0x2120 .entrypoint // Code size 103 (0x67) .maxstack 20 IL_0000: call class [System.Core]System.Func`1<!!0> class Test::XX<bool> () IL_0005: callvirt instance !0 class [System.Core]System.Func`1<bool>::Invoke() IL_000a: box [mscorlib]System.Boolean IL_000f: call instance class [mscorlib]System.Type object::GetType() IL_0014: ldtoken [mscorlib]System.Boolean IL_0019: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) IL_001e: beq IL_0025 IL_0023: ldc.i4.1 IL_0024: ret IL_0025: call class [System.Core]System.Func`1<!!0> class Test::XX<int32> () IL_002a: callvirt instance !0 class [System.Core]System.Func`1<int32>::Invoke() IL_002f: box [mscorlib]System.Int32 IL_0034: call instance class [mscorlib]System.Type object::GetType() IL_0039: ldtoken [mscorlib]System.Int32 IL_003e: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) IL_0043: beq IL_004a IL_0048: ldc.i4.1 IL_0049: ret IL_004a: call class [System.Core]System.Func`1<!!0> class Test::XX<object> () IL_004f: callvirt instance !0 class [System.Core]System.Func`1<object>::Invoke() IL_0054: brfalse IL_005b IL_0059: ldc.i4.2 IL_005a: ret IL_005b: ldstr "OK" IL_0060: call void class [mscorlib]System.Console::WriteLine(string) IL_0065: ldc.i4.0 IL_0066: ret } // end of method Test::Main // method line 4 .method private static hidebysig default !!T '<XX>m__0'<T> () cil managed { .custom instance void class [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::'.ctor'() = (01 00 00 00 ) // .... // Method begins at RVA 0x2194 // Code size 12 (0xc) .maxstack 2 .locals init ( !!T V_0, !!T V_1) IL_0000: ldloca.s 0 IL_0002: initobj !!0 IL_0008: ldloc.0 IL_0009: ret IL_000a: ldloc.1 IL_000b: ret } // end of method Test::<XX>m__0 } // end of class Test
.assembly extern mscorlib { .ver 2:0:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. } .assembly extern System.Core { .ver 3:5:0:0 .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. } .assembly 'test-anon-01' { .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::'.ctor'() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. .hash algorithm 0x00008004 .ver 0:0:0:0 } .module 'test-anon-01.exe' // GUID = {38A511CD-E5D7-4DA2-88C0-A137887BAFBC} .class public auto ansi beforefieldinit Test extends [mscorlib]System.Object { .field private static class [System.Core]System.Func`1<!!0> '<>f__am$cache0' .custom instance void class [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::'.ctor'() = (01 00 00 00 ) // .... // method line 1 .method public hidebysig specialname rtspecialname instance default void '.ctor' () cil managed { // Method begins at RVA 0x20ec // Code size 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void object::'.ctor'() IL_0006: ret } // end of method Test::.ctor // method line 2 .method private static hidebysig default class [System.Core]System.Func`1<!!T> XX<T> () cil managed { // Method begins at RVA 0x20f4 // Code size 32 (0x20) .maxstack 4 .locals init ( class [System.Core]System.Func`1<!!T> V_0) IL_0000: ldsfld class [System.Core]System.Func`1<!!0> Test::'<>f__am$cache0' IL_0005: brtrue.s IL_0018 IL_0007: ldnull IL_0008: ldftn !!0 class Test::'<XX>m__0'<!!0> () IL_000e: newobj instance void class [System.Core]System.Func`1<!!T>::'.ctor'(object, native int) IL_0013: stsfld class [System.Core]System.Func`1<!!0> Test::'<>f__am$cache0' IL_0018: ldsfld class [System.Core]System.Func`1<!!0> Test::'<>f__am$cache0' IL_001d: stloc.0 IL_001e: ldloc.0 IL_001f: ret } // end of method Test::XX // method line 3 .method public static hidebysig default int32 Main () cil managed { // Method begins at RVA 0x2120 .entrypoint // Code size 103 (0x67) .maxstack 20 IL_0000: call class [System.Core]System.Func`1<!!0> class Test::XX<bool> () IL_0005: callvirt instance !0 class [System.Core]System.Func`1<bool>::Invoke() IL_000a: box [mscorlib]System.Boolean IL_000f: call instance class [mscorlib]System.Type object::GetType() IL_0014: ldtoken [mscorlib]System.Boolean IL_0019: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) IL_001e: beq IL_0025 IL_0023: ldc.i4.1 IL_0024: ret IL_0025: call class [System.Core]System.Func`1<!!0> class Test::XX<int32> () IL_002a: callvirt instance !0 class [System.Core]System.Func`1<int32>::Invoke() IL_002f: box [mscorlib]System.Int32 IL_0034: call instance class [mscorlib]System.Type object::GetType() IL_0039: ldtoken [mscorlib]System.Int32 IL_003e: call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) IL_0043: beq IL_004a IL_0048: ldc.i4.1 IL_0049: ret IL_004a: call class [System.Core]System.Func`1<!!0> class Test::XX<object> () IL_004f: callvirt instance !0 class [System.Core]System.Func`1<object>::Invoke() IL_0054: brfalse IL_005b IL_0059: ldc.i4.2 IL_005a: ret IL_005b: ldstr "OK" IL_0060: call void class [mscorlib]System.Console::WriteLine(string) IL_0065: ldc.i4.0 IL_0066: ret } // end of method Test::Main // method line 4 .method private static hidebysig default !!T '<XX>m__0'<T> () cil managed { .custom instance void class [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::'.ctor'() = (01 00 00 00 ) // .... // Method begins at RVA 0x2194 // Code size 12 (0xc) .maxstack 2 .locals init ( !!T V_0, !!T V_1) IL_0000: ldloca.s 0 IL_0002: initobj !!0 IL_0008: ldloc.0 IL_0009: ret IL_000a: ldloc.1 IL_000b: ret } // end of method Test::<XX>m__0 } // end of class Test
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/General/Vector64/Add.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\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 AddByte() { var test = new VectorBinaryOpTest__AddByte(); // 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__AddByte { 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 != 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<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 Vector64<Byte> _fld1; public Vector64<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<Vector64<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__AddByte testClass) { var result = Vector64.Add(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector64<Byte> _clsVar1; private static Vector64<Byte> _clsVar2; private Vector64<Byte> _fld1; private Vector64<Byte> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__AddByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public VectorBinaryOpTest__AddByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<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 Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector64.Add( Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<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 method = typeof(Vector64).GetMethod(nameof(Vector64.Add), new Type[] { typeof(Vector64<Byte>), typeof(Vector64<Byte>) }); if (method is null) { method = typeof(Vector64).GetMethod(nameof(Vector64.Add), 1, new Type[] { typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Byte)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector64.Add( _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<Vector64<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr); var result = Vector64.Add(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__AddByte(); var result = Vector64.Add(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 = Vector64.Add(_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 = Vector64.Add(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(Vector64<Byte> op1, Vector64<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<Vector64<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<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != (byte)(left[0] + right[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != (byte)(left[i] + right[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector64)}.{nameof(Vector64.Add)}<Byte>(Vector64<Byte>, Vector64<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\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 AddByte() { var test = new VectorBinaryOpTest__AddByte(); // 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__AddByte { 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 != 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<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 Vector64<Byte> _fld1; public Vector64<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<Vector64<Byte>, byte>(ref testStruct._fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(VectorBinaryOpTest__AddByte testClass) { var result = Vector64.Add(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 8; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static Byte[] _data1 = new Byte[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector64<Byte> _clsVar1; private static Vector64<Byte> _clsVar2; private Vector64<Byte> _fld1; private Vector64<Byte> _fld2; private DataTable _dataTable; static VectorBinaryOpTest__AddByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public VectorBinaryOpTest__AddByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<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 Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Vector64.Add( Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<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 method = typeof(Vector64).GetMethod(nameof(Vector64.Add), new Type[] { typeof(Vector64<Byte>), typeof(Vector64<Byte>) }); if (method is null) { method = typeof(Vector64).GetMethod(nameof(Vector64.Add), 1, new Type[] { typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)), typeof(Vector64<>).MakeGenericType(Type.MakeGenericMethodParameter(0)) }); } if (method.IsGenericMethodDefinition) { method = method.MakeGenericMethod(typeof(Byte)); } var result = method.Invoke(null, new object[] { Unsafe.Read<Vector64<Byte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector64<Byte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Vector64.Add( _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<Vector64<Byte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr); var result = Vector64.Add(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new VectorBinaryOpTest__AddByte(); var result = Vector64.Add(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 = Vector64.Add(_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 = Vector64.Add(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(Vector64<Byte> op1, Vector64<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<Vector64<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<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector64<Byte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") { bool succeeded = true; if (result[0] != (byte)(left[0] + right[0])) { succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (result[i] != (byte)(left[i] + right[i])) { succeeded = false; break; } } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Vector64)}.{nameof(Vector64.Add)}<Byte>(Vector64<Byte>, Vector64<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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest597/Generated597.ilproj
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated597.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk.IL"> <PropertyGroup> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <ItemGroup> <Compile Include="Generated597.il" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\TestFramework\TestFramework.csproj" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd.Arm64/ZipHigh.Vector128.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 ZipHigh_Vector128_SByte() { var test = new SimpleBinaryOpTest__ZipHigh_Vector128_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 SimpleBinaryOpTest__ZipHigh_Vector128_SByte { 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(SByte[] inArray1, SByte[] inArray2, SByte[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<SByte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<SByte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<SByte>(); 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<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* 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<SByte> _fld1; public Vector128<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<Vector128<SByte>, byte>(ref testStruct._fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref testStruct._fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__ZipHigh_Vector128_SByte testClass) { var result = AdvSimd.Arm64.ZipHigh(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__ZipHigh_Vector128_SByte testClass) { fixed (Vector128<SByte>* pFld1 = &_fld1) fixed (Vector128<SByte>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.ZipHigh( AdvSimd.LoadVector128((SByte*)(pFld1)), AdvSimd.LoadVector128((SByte*)(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<SByte>>() / sizeof(SByte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); private static SByte[] _data1 = new SByte[Op1ElementCount]; private static SByte[] _data2 = new SByte[Op2ElementCount]; private static Vector128<SByte> _clsVar1; private static Vector128<SByte> _clsVar2; private Vector128<SByte> _fld1; private Vector128<SByte> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__ZipHigh_Vector128_SByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); } public SimpleBinaryOpTest__ZipHigh_Vector128_SByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<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, new SByte[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.ZipHigh( Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<SByte>>(_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.ZipHigh( AdvSimd.LoadVector128((SByte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((SByte*)(_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.ZipHigh), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<SByte>)(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.ZipHigh), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((SByte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<SByte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.Arm64.ZipHigh( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<SByte>* pClsVar1 = &_clsVar1) fixed (Vector128<SByte>* pClsVar2 = &_clsVar2) { var result = AdvSimd.Arm64.ZipHigh( AdvSimd.LoadVector128((SByte*)(pClsVar1)), AdvSimd.LoadVector128((SByte*)(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<SByte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr); var result = AdvSimd.Arm64.ZipHigh(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((SByte*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)); var result = AdvSimd.Arm64.ZipHigh(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__ZipHigh_Vector128_SByte(); var result = AdvSimd.Arm64.ZipHigh(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__ZipHigh_Vector128_SByte(); fixed (Vector128<SByte>* pFld1 = &test._fld1) fixed (Vector128<SByte>* pFld2 = &test._fld2) { var result = AdvSimd.Arm64.ZipHigh( AdvSimd.LoadVector128((SByte*)(pFld1)), AdvSimd.LoadVector128((SByte*)(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.ZipHigh(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<SByte>* pFld1 = &_fld1) fixed (Vector128<SByte>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.ZipHigh( AdvSimd.LoadVector128((SByte*)(pFld1)), AdvSimd.LoadVector128((SByte*)(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.ZipHigh(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.ZipHigh( AdvSimd.LoadVector128((SByte*)(&test._fld1)), AdvSimd.LoadVector128((SByte*)(&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<SByte> op1, Vector128<SByte> op2, void* result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; SByte[] outArray = new SByte[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<SByte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; SByte[] outArray = new SByte[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<SByte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(SByte[] left, SByte[] right, SByte[] 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[i] != left[index+half] || result[i+1] != right[index+half]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.ZipHigh)}<SByte>(Vector128<SByte>, Vector128<SByte>): {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 ZipHigh_Vector128_SByte() { var test = new SimpleBinaryOpTest__ZipHigh_Vector128_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 SimpleBinaryOpTest__ZipHigh_Vector128_SByte { 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(SByte[] inArray1, SByte[] inArray2, SByte[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<SByte>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<SByte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<SByte>(); 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<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* 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<SByte> _fld1; public Vector128<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<Vector128<SByte>, byte>(ref testStruct._fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref testStruct._fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__ZipHigh_Vector128_SByte testClass) { var result = AdvSimd.Arm64.ZipHigh(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__ZipHigh_Vector128_SByte testClass) { fixed (Vector128<SByte>* pFld1 = &_fld1) fixed (Vector128<SByte>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.ZipHigh( AdvSimd.LoadVector128((SByte*)(pFld1)), AdvSimd.LoadVector128((SByte*)(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<SByte>>() / sizeof(SByte); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<SByte>>() / sizeof(SByte); private static SByte[] _data1 = new SByte[Op1ElementCount]; private static SByte[] _data2 = new SByte[Op2ElementCount]; private static Vector128<SByte> _clsVar1; private static Vector128<SByte> _clsVar2; private Vector128<SByte> _fld1; private Vector128<SByte> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__ZipHigh_Vector128_SByte() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); } public SimpleBinaryOpTest__ZipHigh_Vector128_SByte() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<SByte>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<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, new SByte[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.ZipHigh( Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<SByte>>(_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.ZipHigh( AdvSimd.LoadVector128((SByte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((SByte*)(_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.ZipHigh), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<SByte>)(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.ZipHigh), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((SByte*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<SByte>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.Arm64.ZipHigh( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<SByte>* pClsVar1 = &_clsVar1) fixed (Vector128<SByte>* pClsVar2 = &_clsVar2) { var result = AdvSimd.Arm64.ZipHigh( AdvSimd.LoadVector128((SByte*)(pClsVar1)), AdvSimd.LoadVector128((SByte*)(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<SByte>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr); var result = AdvSimd.Arm64.ZipHigh(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((SByte*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector128((SByte*)(_dataTable.inArray2Ptr)); var result = AdvSimd.Arm64.ZipHigh(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__ZipHigh_Vector128_SByte(); var result = AdvSimd.Arm64.ZipHigh(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__ZipHigh_Vector128_SByte(); fixed (Vector128<SByte>* pFld1 = &test._fld1) fixed (Vector128<SByte>* pFld2 = &test._fld2) { var result = AdvSimd.Arm64.ZipHigh( AdvSimd.LoadVector128((SByte*)(pFld1)), AdvSimd.LoadVector128((SByte*)(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.ZipHigh(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<SByte>* pFld1 = &_fld1) fixed (Vector128<SByte>* pFld2 = &_fld2) { var result = AdvSimd.Arm64.ZipHigh( AdvSimd.LoadVector128((SByte*)(pFld1)), AdvSimd.LoadVector128((SByte*)(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.ZipHigh(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.ZipHigh( AdvSimd.LoadVector128((SByte*)(&test._fld1)), AdvSimd.LoadVector128((SByte*)(&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<SByte> op1, Vector128<SByte> op2, void* result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; SByte[] outArray = new SByte[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<SByte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { SByte[] inArray1 = new SByte[Op1ElementCount]; SByte[] inArray2 = new SByte[Op2ElementCount]; SByte[] outArray = new SByte[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector128<SByte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<SByte>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(SByte[] left, SByte[] right, SByte[] 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[i] != left[index+half] || result[i+1] != right[index+half]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd.Arm64)}.{nameof(AdvSimd.Arm64.ZipHigh)}<SByte>(Vector128<SByte>, Vector128<SByte>): {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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Diagnostics.Debug/System.Diagnostics.Debug.sln
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{6CBF7573-4865-4DD2-A38B-74003FB43C9E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{1C01EFBD-2332-4392-BB4A-918178861EDC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Debug", "ref\System.Diagnostics.Debug.csproj", "{2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Debug", "src\System.Diagnostics.Debug.csproj", "{05AA43B5-733A-43EF-8CE5-8BF4A18BD516}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Debug.Tests", "tests\System.Diagnostics.Debug.Tests.csproj", "{5B121A9E-061D-4FED-AA3A-26054F41E2B4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib.Generators", "..\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj", "{6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Uri", "..\System.Private.Uri\src\System.Private.Uri.csproj", "{8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{99BC2F73-199C-4E97-B247-FA99AEC9E24A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{BEE502AC-7208-4289-BAFD-57EBE4A4F188}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{C4E264C7-91E7-4100-BA47-47CB12964025}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{C61770DF-C267-4B18-8822-D9C062FE806E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6C5230A5-919B-465B-9C98-852B85C96947}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8D1E1DF1-BE04-43F9-8D9D-E73AAB20C311}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{E1E2C99D-07AE-4C22-A2E1-B807B1AE61AF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{A2474395-2701-4B91-A097-985495EFE750}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 Release|x86 = Release|x86 Checked|Any CPU = Checked|Any CPU Checked|x64 = Checked|x64 Checked|x86 = Checked|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|Any CPU.ActiveCfg = Debug|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|Any CPU.Build.0 = Debug|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|x64.ActiveCfg = Debug|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|x64.Build.0 = Debug|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|x86.ActiveCfg = Debug|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|x86.Build.0 = Debug|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|Any CPU.ActiveCfg = Release|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|Any CPU.Build.0 = Release|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|x64.ActiveCfg = Release|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|x64.Build.0 = Release|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|x86.ActiveCfg = Release|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|x86.Build.0 = Release|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|Any CPU.ActiveCfg = Checked|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|Any CPU.Build.0 = Checked|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|x64.ActiveCfg = Checked|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|x64.Build.0 = Checked|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|x86.ActiveCfg = Checked|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|x86.Build.0 = Checked|x86 {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|Any CPU.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|x64.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|x64.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|x86.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|x86.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|Any CPU.ActiveCfg = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|Any CPU.Build.0 = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|x64.ActiveCfg = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|x64.Build.0 = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|x86.ActiveCfg = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|x86.Build.0 = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|Any CPU.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|x64.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|x64.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|x86.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|x86.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|x64.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|x64.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|x86.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|x86.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|Any CPU.Build.0 = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|x64.ActiveCfg = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|x64.Build.0 = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|x86.ActiveCfg = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|x86.Build.0 = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|Any CPU.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|x64.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|x64.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|x86.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|x86.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|Any CPU.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|x64.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|x64.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|x86.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|x86.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|Any CPU.ActiveCfg = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|Any CPU.Build.0 = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|x64.ActiveCfg = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|x64.Build.0 = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|x86.ActiveCfg = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|x86.Build.0 = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|Any CPU.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|x64.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|x64.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|x86.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|x86.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|x64.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|x64.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|x86.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|x86.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|Any CPU.ActiveCfg = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|Any CPU.Build.0 = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|x64.ActiveCfg = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|x64.Build.0 = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|x86.ActiveCfg = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|x86.Build.0 = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|Any CPU.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|x64.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|x64.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|x86.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|x86.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|x64.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|x64.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|x86.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|x86.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|Any CPU.Build.0 = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|x64.ActiveCfg = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|x64.Build.0 = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|x86.ActiveCfg = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|x86.Build.0 = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|Any CPU.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|x64.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|x64.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|x86.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|x86.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|x64.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|x64.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|x86.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|x86.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|Any CPU.Build.0 = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|x64.ActiveCfg = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|x64.Build.0 = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|x86.ActiveCfg = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|x86.Build.0 = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|Any CPU.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|x64.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|x64.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|x86.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|x86.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|Any CPU.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|x64.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|x64.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|x86.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|x86.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|Any CPU.ActiveCfg = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|Any CPU.Build.0 = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|x64.ActiveCfg = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|x64.Build.0 = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|x86.ActiveCfg = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|x86.Build.0 = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|Any CPU.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|x64.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|x64.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|x86.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|x86.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|x64.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|x64.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|x86.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|x86.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|Any CPU.Build.0 = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|x64.ActiveCfg = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|x64.Build.0 = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|x86.ActiveCfg = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|x86.Build.0 = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|Any CPU.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|x64.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|x64.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|x86.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|x86.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x64.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x64.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x86.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x86.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|Any CPU.ActiveCfg = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|Any CPU.Build.0 = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|x64.ActiveCfg = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|x64.Build.0 = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|x86.ActiveCfg = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|x86.Build.0 = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|Any CPU.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|x64.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|x64.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|x86.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|x86.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|Any CPU.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|x64.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|x64.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|x86.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|x86.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|Any CPU.ActiveCfg = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|Any CPU.Build.0 = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|x64.ActiveCfg = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|x64.Build.0 = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|x86.ActiveCfg = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|x86.Build.0 = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|Any CPU.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|x64.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|x64.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|x86.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {6CBF7573-4865-4DD2-A38B-74003FB43C9E} = {6C5230A5-919B-465B-9C98-852B85C96947} {05AA43B5-733A-43EF-8CE5-8BF4A18BD516} = {6C5230A5-919B-465B-9C98-852B85C96947} {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04} = {6C5230A5-919B-465B-9C98-852B85C96947} {C4E264C7-91E7-4100-BA47-47CB12964025} = {6C5230A5-919B-465B-9C98-852B85C96947} {C61770DF-C267-4B18-8822-D9C062FE806E} = {6C5230A5-919B-465B-9C98-852B85C96947} {1C01EFBD-2332-4392-BB4A-918178861EDC} = {8D1E1DF1-BE04-43F9-8D9D-E73AAB20C311} {5B121A9E-061D-4FED-AA3A-26054F41E2B4} = {8D1E1DF1-BE04-43F9-8D9D-E73AAB20C311} {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D} = {E1E2C99D-07AE-4C22-A2E1-B807B1AE61AF} {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3} = {A2474395-2701-4B91-A097-985495EFE750} {99BC2F73-199C-4E97-B247-FA99AEC9E24A} = {A2474395-2701-4B91-A097-985495EFE750} {BEE502AC-7208-4289-BAFD-57EBE4A4F188} = {A2474395-2701-4B91-A097-985495EFE750} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E0E463DC-7C7C-48D9-9806-88AFFFA1F54F} EndGlobalSection EndGlobal
Microsoft Visual Studio Solution File, Format Version 12.00 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{6CBF7573-4865-4DD2-A38B-74003FB43C9E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{1C01EFBD-2332-4392-BB4A-918178861EDC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Debug", "ref\System.Diagnostics.Debug.csproj", "{2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Debug", "src\System.Diagnostics.Debug.csproj", "{05AA43B5-733A-43EF-8CE5-8BF4A18BD516}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Diagnostics.Debug.Tests", "tests\System.Diagnostics.Debug.Tests.csproj", "{5B121A9E-061D-4FED-AA3A-26054F41E2B4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib.Generators", "..\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj", "{6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.Uri", "..\System.Private.Uri\src\System.Private.Uri.csproj", "{8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{99BC2F73-199C-4E97-B247-FA99AEC9E24A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{BEE502AC-7208-4289-BAFD-57EBE4A4F188}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime", "..\System.Runtime\src\System.Runtime.csproj", "{C4E264C7-91E7-4100-BA47-47CB12964025}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Threading", "..\System.Threading\src\System.Threading.csproj", "{C61770DF-C267-4B18-8822-D9C062FE806E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6C5230A5-919B-465B-9C98-852B85C96947}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8D1E1DF1-BE04-43F9-8D9D-E73AAB20C311}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{E1E2C99D-07AE-4C22-A2E1-B807B1AE61AF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{A2474395-2701-4B91-A097-985495EFE750}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 Release|x86 = Release|x86 Checked|Any CPU = Checked|Any CPU Checked|x64 = Checked|x64 Checked|x86 = Checked|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|Any CPU.ActiveCfg = Debug|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|Any CPU.Build.0 = Debug|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|x64.ActiveCfg = Debug|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|x64.Build.0 = Debug|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|x86.ActiveCfg = Debug|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Debug|x86.Build.0 = Debug|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|Any CPU.ActiveCfg = Release|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|Any CPU.Build.0 = Release|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|x64.ActiveCfg = Release|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|x64.Build.0 = Release|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|x86.ActiveCfg = Release|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Release|x86.Build.0 = Release|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|Any CPU.ActiveCfg = Checked|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|Any CPU.Build.0 = Checked|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|x64.ActiveCfg = Checked|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|x64.Build.0 = Checked|x64 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|x86.ActiveCfg = Checked|x86 {6CBF7573-4865-4DD2-A38B-74003FB43C9E}.Checked|x86.Build.0 = Checked|x86 {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|Any CPU.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|x64.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|x64.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|x86.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Debug|x86.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|Any CPU.ActiveCfg = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|Any CPU.Build.0 = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|x64.ActiveCfg = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|x64.Build.0 = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|x86.ActiveCfg = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Release|x86.Build.0 = Release|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|Any CPU.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|x64.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|x64.Build.0 = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|x86.ActiveCfg = Debug|Any CPU {1C01EFBD-2332-4392-BB4A-918178861EDC}.Checked|x86.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|x64.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|x64.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|x86.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Debug|x86.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|Any CPU.Build.0 = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|x64.ActiveCfg = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|x64.Build.0 = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|x86.ActiveCfg = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Release|x86.Build.0 = Release|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|Any CPU.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|x64.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|x64.Build.0 = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|x86.ActiveCfg = Debug|Any CPU {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D}.Checked|x86.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|Any CPU.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|x64.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|x64.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|x86.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Debug|x86.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|Any CPU.ActiveCfg = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|Any CPU.Build.0 = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|x64.ActiveCfg = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|x64.Build.0 = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|x86.ActiveCfg = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Release|x86.Build.0 = Release|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|Any CPU.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|x64.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|x64.Build.0 = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|x86.ActiveCfg = Debug|Any CPU {05AA43B5-733A-43EF-8CE5-8BF4A18BD516}.Checked|x86.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|Any CPU.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|x64.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|x64.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|x86.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Debug|x86.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|Any CPU.ActiveCfg = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|Any CPU.Build.0 = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|x64.ActiveCfg = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|x64.Build.0 = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|x86.ActiveCfg = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Release|x86.Build.0 = Release|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|Any CPU.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|x64.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|x64.Build.0 = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|x86.ActiveCfg = Debug|Any CPU {5B121A9E-061D-4FED-AA3A-26054F41E2B4}.Checked|x86.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|x64.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|x64.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|x86.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Debug|x86.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|Any CPU.Build.0 = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|x64.ActiveCfg = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|x64.Build.0 = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|x86.ActiveCfg = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Release|x86.Build.0 = Release|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|Any CPU.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|x64.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|x64.Build.0 = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|x86.ActiveCfg = Debug|Any CPU {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3}.Checked|x86.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|x64.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|x64.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|x86.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Debug|x86.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|Any CPU.Build.0 = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|x64.ActiveCfg = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|x64.Build.0 = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|x86.ActiveCfg = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Release|x86.Build.0 = Release|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|Any CPU.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|x64.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|x64.Build.0 = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|x86.ActiveCfg = Debug|Any CPU {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04}.Checked|x86.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|Any CPU.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|x64.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|x64.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|x86.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Debug|x86.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|Any CPU.ActiveCfg = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|Any CPU.Build.0 = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|x64.ActiveCfg = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|x64.Build.0 = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|x86.ActiveCfg = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Release|x86.Build.0 = Release|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|Any CPU.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|x64.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|x64.Build.0 = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|x86.ActiveCfg = Debug|Any CPU {99BC2F73-199C-4E97-B247-FA99AEC9E24A}.Checked|x86.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|x64.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|x64.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|x86.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Debug|x86.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|Any CPU.Build.0 = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|x64.ActiveCfg = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|x64.Build.0 = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|x86.ActiveCfg = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Release|x86.Build.0 = Release|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|Any CPU.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|x64.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|x64.Build.0 = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|x86.ActiveCfg = Debug|Any CPU {BEE502AC-7208-4289-BAFD-57EBE4A4F188}.Checked|x86.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|Any CPU.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x64.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x64.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x86.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Debug|x86.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|Any CPU.ActiveCfg = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|Any CPU.Build.0 = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|x64.ActiveCfg = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|x64.Build.0 = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|x86.ActiveCfg = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Release|x86.Build.0 = Release|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|Any CPU.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|x64.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|x64.Build.0 = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|x86.ActiveCfg = Debug|Any CPU {C4E264C7-91E7-4100-BA47-47CB12964025}.Checked|x86.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|Any CPU.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|x64.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|x64.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|x86.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Debug|x86.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|Any CPU.ActiveCfg = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|Any CPU.Build.0 = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|x64.ActiveCfg = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|x64.Build.0 = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|x86.ActiveCfg = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Release|x86.Build.0 = Release|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|Any CPU.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|Any CPU.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|x64.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|x64.Build.0 = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|x86.ActiveCfg = Debug|Any CPU {C61770DF-C267-4B18-8822-D9C062FE806E}.Checked|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {6CBF7573-4865-4DD2-A38B-74003FB43C9E} = {6C5230A5-919B-465B-9C98-852B85C96947} {05AA43B5-733A-43EF-8CE5-8BF4A18BD516} = {6C5230A5-919B-465B-9C98-852B85C96947} {8CCE7756-F004-4EF2-ABCE-0DDD03D5BE04} = {6C5230A5-919B-465B-9C98-852B85C96947} {C4E264C7-91E7-4100-BA47-47CB12964025} = {6C5230A5-919B-465B-9C98-852B85C96947} {C61770DF-C267-4B18-8822-D9C062FE806E} = {6C5230A5-919B-465B-9C98-852B85C96947} {1C01EFBD-2332-4392-BB4A-918178861EDC} = {8D1E1DF1-BE04-43F9-8D9D-E73AAB20C311} {5B121A9E-061D-4FED-AA3A-26054F41E2B4} = {8D1E1DF1-BE04-43F9-8D9D-E73AAB20C311} {2B2AFDCB-BD41-4855-BCB0-B675B8E6CD0D} = {E1E2C99D-07AE-4C22-A2E1-B807B1AE61AF} {6ED522FD-D0B0-4574-8F1A-82D339C7D0D3} = {A2474395-2701-4B91-A097-985495EFE750} {99BC2F73-199C-4E97-B247-FA99AEC9E24A} = {A2474395-2701-4B91-A097-985495EFE750} {BEE502AC-7208-4289-BAFD-57EBE4A4F188} = {A2474395-2701-4B91-A097-985495EFE750} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E0E463DC-7C7C-48D9-9806-88AFFFA1F54F} EndGlobalSection EndGlobal
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.ServiceModel.Syndication/tests/TestFeeds/RssFeeds/pubdate_july.xml
<!-- Description: valid pubDate (July) Expect: ValidRFC2822Date{parent:channel,element:pubDate} --> <rss version="2.0"> <channel> <title>Validity test</title> <link>http://contoso.com/rss/2.0/</link> <description>valid pubDate (July)</description> <pubDate>10 Jul 2002 14:20:20 GMT</pubDate> </channel> </rss>
<!-- Description: valid pubDate (July) Expect: ValidRFC2822Date{parent:channel,element:pubDate} --> <rss version="2.0"> <channel> <title>Validity test</title> <link>http://contoso.com/rss/2.0/</link> <description>valid pubDate (July)</description> <pubDate>10 Jul 2002 14:20:20 GMT</pubDate> </channel> </rss>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Methodical/VT/callconv/jumper_do.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="jumper.cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="jumper.cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/UInt32Converter.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.Converters { internal sealed class UInt32Converter : JsonConverter<uint> { public UInt32Converter() { IsInternalConverterForNumberType = true; } public override uint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { return reader.GetUInt32(); } public override void Write(Utf8JsonWriter writer, uint value, JsonSerializerOptions options) { // For performance, lift up the writer implementation. writer.WriteNumberValue((ulong)value); } internal override uint ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { return reader.GetUInt32WithQuotes(); } internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, uint value, JsonSerializerOptions options, bool isWritingExtensionDataProperty) { writer.WritePropertyName(value); } internal override uint ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options) { if (reader.TokenType == JsonTokenType.String && (JsonNumberHandling.AllowReadingFromString & handling) != 0) { return reader.GetUInt32WithQuotes(); } return reader.GetUInt32(); } internal override void WriteNumberWithCustomHandling(Utf8JsonWriter writer, uint value, JsonNumberHandling handling) { if ((JsonNumberHandling.WriteAsString & handling) != 0) { writer.WriteNumberValueAsString(value); } else { // For performance, lift up the writer implementation. writer.WriteNumberValue((ulong)value); } } } }
// 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.Converters { internal sealed class UInt32Converter : JsonConverter<uint> { public UInt32Converter() { IsInternalConverterForNumberType = true; } public override uint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { return reader.GetUInt32(); } public override void Write(Utf8JsonWriter writer, uint value, JsonSerializerOptions options) { // For performance, lift up the writer implementation. writer.WriteNumberValue((ulong)value); } internal override uint ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { return reader.GetUInt32WithQuotes(); } internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, uint value, JsonSerializerOptions options, bool isWritingExtensionDataProperty) { writer.WritePropertyName(value); } internal override uint ReadNumberWithCustomHandling(ref Utf8JsonReader reader, JsonNumberHandling handling, JsonSerializerOptions options) { if (reader.TokenType == JsonTokenType.String && (JsonNumberHandling.AllowReadingFromString & handling) != 0) { return reader.GetUInt32WithQuotes(); } return reader.GetUInt32(); } internal override void WriteNumberWithCustomHandling(Utf8JsonWriter writer, uint value, JsonNumberHandling handling) { if ((JsonNumberHandling.WriteAsString & handling) != 0) { writer.WriteNumberValueAsString(value); } else { // For performance, lift up the writer implementation. writer.WriteNumberValue((ulong)value); } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/Microsoft.Extensions.Logging.Abstractions/tests/Microsoft.Extensions.Logging.Generators.Tests/TestClasses/AtSymbolTestExtensions.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { internal static partial class AtSymbolTestExtensions { [LoggerMessage(EventId = 0, Level = LogLevel.Information, Message = "M0 {event}")] internal static partial void M0(ILogger logger, string @event); } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.Extensions.Logging.Generators.Tests.TestClasses { internal static partial class AtSymbolTestExtensions { [LoggerMessage(EventId = 0, Level = LogLevel.Information, Message = "M0 {event}")] internal static partial void M0(ILogger logger, string @event); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Performance/CodeQuality/Benchstones/BenchF/BenchMk2/BenchMk2.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.CompilerServices; namespace Benchstone.BenchF { public static class BenchMk2 { #if DEBUG public const int Iterations = 1; #else public const int Iterations = 4000000; #endif private static int s_i, s_n; private static double s_p, s_a, s_x, s_f, s_e; [MethodImpl(MethodImplOptions.NoInlining)] private static bool Bench() { s_p = Math.Acos(-1.0); s_a = 0.0; s_n = Iterations; s_f = s_p / s_n; for (s_i = 1; s_i <= s_n; ++s_i) { s_f = s_p / s_n; s_x = s_f * s_i; s_e = Math.Abs(Math.Log(Math.Exp(s_x)) / s_x) - Math.Sqrt((Math.Sin(s_x) * Math.Sin(s_x)) + Math.Cos(s_x) * Math.Cos(s_x)); s_a = s_a + Math.Abs(s_e); } return true; } public static int Main() { bool result = Bench(); return (result ? 100 : -1); } } }
// 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.CompilerServices; namespace Benchstone.BenchF { public static class BenchMk2 { #if DEBUG public const int Iterations = 1; #else public const int Iterations = 4000000; #endif private static int s_i, s_n; private static double s_p, s_a, s_x, s_f, s_e; [MethodImpl(MethodImplOptions.NoInlining)] private static bool Bench() { s_p = Math.Acos(-1.0); s_a = 0.0; s_n = Iterations; s_f = s_p / s_n; for (s_i = 1; s_i <= s_n; ++s_i) { s_f = s_p / s_n; s_x = s_f * s_i; s_e = Math.Abs(Math.Log(Math.Exp(s_x)) / s_x) - Math.Sqrt((Math.Sin(s_x) * Math.Sin(s_x)) + Math.Cos(s_x) * Math.Cos(s_x)); s_a = s_a + Math.Abs(s_e); } return true; } public static int Main() { bool result = Bench(); return (result ? 100 : -1); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/jit64/valuetypes/nullable/box-unbox/null/box-unbox-null003.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // <Area> Nullable - Box-Unbox </Area> // <Title> Nullable type with unbox box expr </Title> // <Description> // checking type of byte using is operator // </Description> // <RelatedBugs> </RelatedBugs> //<Expects Status=success></Expects> // <Code> using System.Runtime.InteropServices; using System; internal class NullableTest { private static bool BoxUnboxToNQGen<T>(T o) { return ((object)o) == null; } private static bool BoxUnboxToQGen<T>(T? o) where T : struct { return ((T?)o) == null; } private static bool BoxUnboxToNQ(object o) { return o == null; } private static bool BoxUnboxToQ(object o) { return ((byte?)o) == null; } private static int Main() { byte? s = null; if (BoxUnboxToNQ(s) && BoxUnboxToQ(s) && BoxUnboxToNQGen(s) && BoxUnboxToQGen(s)) return ExitCode.Passed; else return ExitCode.Failed; } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // <Area> Nullable - Box-Unbox </Area> // <Title> Nullable type with unbox box expr </Title> // <Description> // checking type of byte using is operator // </Description> // <RelatedBugs> </RelatedBugs> //<Expects Status=success></Expects> // <Code> using System.Runtime.InteropServices; using System; internal class NullableTest { private static bool BoxUnboxToNQGen<T>(T o) { return ((object)o) == null; } private static bool BoxUnboxToQGen<T>(T? o) where T : struct { return ((T?)o) == null; } private static bool BoxUnboxToNQ(object o) { return o == null; } private static bool BoxUnboxToQ(object o) { return ((byte?)o) == null; } private static int Main() { byte? s = null; if (BoxUnboxToNQ(s) && BoxUnboxToQ(s) && BoxUnboxToNQGen(s) && BoxUnboxToQGen(s)) return ExitCode.Passed; else return ExitCode.Failed; } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Resources.ResourceManager/tests/Resources/TestResx.es-MX.resx
<root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="OneLoc" xml:space="preserve"> <value>Value-One(es-MX)</value> </data> </root>
<root> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="OneLoc" xml:space="preserve"> <value>Value-One(es-MX)</value> </data> </root>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Text.Json/tests/System.Text.Json.Tests/DebuggerTests.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.IO; using System.Reflection; using Xunit; namespace System.Text.Json.Tests { public class DebuggerTests { [Fact] public void DefaultJsonElement() { // Validating that we don't throw on default JsonElement element = default; GetDebuggerDisplayProperty(element); } [Fact] public void DefaultJsonProperty() { // Validating that we don't throw on default JsonProperty property = default; GetDebuggerDisplayProperty(property); } [Fact] public void DefaultUtf8JsonWriter() { // Validating that we don't throw on new object using var writer = new Utf8JsonWriter(new MemoryStream()); GetDebuggerDisplayProperty(writer); } private static string GetDebuggerDisplayProperty<T>(T value) { return (string)typeof(T).GetProperty("DebuggerDisplay", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(value); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.IO; using System.Reflection; using Xunit; namespace System.Text.Json.Tests { public class DebuggerTests { [Fact] public void DefaultJsonElement() { // Validating that we don't throw on default JsonElement element = default; GetDebuggerDisplayProperty(element); } [Fact] public void DefaultJsonProperty() { // Validating that we don't throw on default JsonProperty property = default; GetDebuggerDisplayProperty(property); } [Fact] public void DefaultUtf8JsonWriter() { // Validating that we don't throw on new object using var writer = new Utf8JsonWriter(new MemoryStream()); GetDebuggerDisplayProperty(writer); } private static string GetDebuggerDisplayProperty<T>(T value) { return (string)typeof(T).GetProperty("DebuggerDisplay", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(value); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/coreclr/tools/Common/TypeSystem/Interop/IL/PInvokeDelegateWrapper.Mangling.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Internal.TypeSystem.Interop { partial class PInvokeDelegateWrapper : IPrefixMangledType { TypeDesc IPrefixMangledType.BaseType { get { return DelegateType; } } string IPrefixMangledType.Prefix { get { return "PInvokeDelegateWrapper"; } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Internal.TypeSystem.Interop { partial class PInvokeDelegateWrapper : IPrefixMangledType { TypeDesc IPrefixMangledType.BaseType { get { return DelegateType; } } string IPrefixMangledType.Prefix { get { return "PInvokeDelegateWrapper"; } } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/HardwareIntrinsics/Arm/AdvSimd/AddWideningLower.Vector128.UInt16.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 AddWideningLower_Vector128_UInt16() { var test = new SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16(); 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__AddWideningLower_Vector128_UInt16 { 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(UInt16[] inArray1, Byte[] inArray2, UInt16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt16>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt16>(); 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<UInt16, 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<UInt16> _fld1; public Vector64<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16 testClass) { var result = AdvSimd.AddWideningLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16 testClass) { fixed (Vector128<UInt16>* pFld1 = &_fld1) fixed (Vector64<Byte>* pFld2 = &_fld2) { var result = AdvSimd.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(pFld1)), AdvSimd.LoadVector64((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<UInt16>>() / sizeof(UInt16); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); private static UInt16[] _data1 = new UInt16[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector128<UInt16> _clsVar1; private static Vector64<Byte> _clsVar2; private Vector128<UInt16> _fld1; private Vector64<Byte> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, new UInt16[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.AddWideningLower( Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<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.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((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).GetMethod(nameof(AdvSimd.AddWideningLower), new Type[] { typeof(Vector128<UInt16>), typeof(Vector64<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddWideningLower), new Type[] { typeof(Vector128<UInt16>), typeof(Vector64<Byte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((Byte*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.AddWideningLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<UInt16>* pClsVar1 = &_clsVar1) fixed (Vector64<Byte>* pClsVar2 = &_clsVar2) { var result = AdvSimd.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(pClsVar1)), AdvSimd.LoadVector64((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<UInt16>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr); var result = AdvSimd.AddWideningLower(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((UInt16*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector64((Byte*)(_dataTable.inArray2Ptr)); var result = AdvSimd.AddWideningLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16(); var result = AdvSimd.AddWideningLower(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__AddWideningLower_Vector128_UInt16(); fixed (Vector128<UInt16>* pFld1 = &test._fld1) fixed (Vector64<Byte>* pFld2 = &test._fld2) { var result = AdvSimd.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(pFld1)), AdvSimd.LoadVector64((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.AddWideningLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<UInt16>* pFld1 = &_fld1) fixed (Vector64<Byte>* pFld2 = &_fld2) { var result = AdvSimd.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(pFld1)), AdvSimd.LoadVector64((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.AddWideningLower(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.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(&test._fld1)), AdvSimd.LoadVector64((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<UInt16> op1, Vector64<Byte> op2, void* result, [CallerMemberName] string method = "") { UInt16[] inArray1 = new UInt16[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt16[] inArray1 = new UInt16[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt16[] left, Byte[] right, UInt16[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.AddWidening(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.AddWideningLower)}<UInt16>(Vector128<UInt16>, Vector64<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 AddWideningLower_Vector128_UInt16() { var test = new SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16(); 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__AddWideningLower_Vector128_UInt16 { 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(UInt16[] inArray1, Byte[] inArray2, UInt16[] outArray, int alignment) { int sizeOfinArray1 = inArray1.Length * Unsafe.SizeOf<UInt16>(); int sizeOfinArray2 = inArray2.Length * Unsafe.SizeOf<Byte>(); int sizeOfoutArray = outArray.Length * Unsafe.SizeOf<UInt16>(); 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<UInt16, 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<UInt16> _fld1; public Vector64<Byte> _fld2; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref testStruct._fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref testStruct._fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); return testStruct; } public void RunStructFldScenario(SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16 testClass) { var result = AdvSimd.AddWideningLower(_fld1, _fld2); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); } public void RunStructFldScenario_Load(SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16 testClass) { fixed (Vector128<UInt16>* pFld1 = &_fld1) fixed (Vector64<Byte>* pFld2 = &_fld2) { var result = AdvSimd.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(pFld1)), AdvSimd.LoadVector64((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<UInt16>>() / sizeof(UInt16); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector64<Byte>>() / sizeof(Byte); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<UInt16>>() / sizeof(UInt16); private static UInt16[] _data1 = new UInt16[Op1ElementCount]; private static Byte[] _data2 = new Byte[Op2ElementCount]; private static Vector128<UInt16> _clsVar1; private static Vector64<Byte> _clsVar2; private Vector128<UInt16> _fld1; private Vector64<Byte> _fld2; private DataTable _dataTable; static SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); } public SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector64<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector64<Byte>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } _dataTable = new DataTable(_data1, _data2, new UInt16[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.AddWideningLower( Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<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.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((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).GetMethod(nameof(AdvSimd.AddWideningLower), new Type[] { typeof(Vector128<UInt16>), typeof(Vector64<Byte>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(AdvSimd).GetMethod(nameof(AdvSimd.AddWideningLower), new Type[] { typeof(Vector128<UInt16>), typeof(Vector64<Byte>) }) .Invoke(null, new object[] { AdvSimd.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)), AdvSimd.LoadVector64((Byte*)(_dataTable.inArray2Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<UInt16>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = AdvSimd.AddWideningLower( _clsVar1, _clsVar2 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunClsVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario_Load)); fixed (Vector128<UInt16>* pClsVar1 = &_clsVar1) fixed (Vector64<Byte>* pClsVar2 = &_clsVar2) { var result = AdvSimd.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(pClsVar1)), AdvSimd.LoadVector64((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<UInt16>>(_dataTable.inArray1Ptr); var op2 = Unsafe.Read<Vector64<Byte>>(_dataTable.inArray2Ptr); var result = AdvSimd.AddWideningLower(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((UInt16*)(_dataTable.inArray1Ptr)); var op2 = AdvSimd.LoadVector64((Byte*)(_dataTable.inArray2Ptr)); var result = AdvSimd.AddWideningLower(op1, op2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(op1, op2, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleBinaryOpTest__AddWideningLower_Vector128_UInt16(); var result = AdvSimd.AddWideningLower(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__AddWideningLower_Vector128_UInt16(); fixed (Vector128<UInt16>* pFld1 = &test._fld1) fixed (Vector64<Byte>* pFld2 = &test._fld2) { var result = AdvSimd.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(pFld1)), AdvSimd.LoadVector64((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.AddWideningLower(_fld1, _fld2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } public void RunClassFldScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load)); fixed (Vector128<UInt16>* pFld1 = &_fld1) fixed (Vector64<Byte>* pFld2 = &_fld2) { var result = AdvSimd.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(pFld1)), AdvSimd.LoadVector64((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.AddWideningLower(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.AddWideningLower( AdvSimd.LoadVector128((UInt16*)(&test._fld1)), AdvSimd.LoadVector64((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<UInt16> op1, Vector64<Byte> op2, void* result, [CallerMemberName] string method = "") { UInt16[] inArray1 = new UInt16[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), op2); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(void* op1, void* op2, void* result, [CallerMemberName] string method = "") { UInt16[] inArray1 = new UInt16[Op1ElementCount]; Byte[] inArray2 = new Byte[Op2ElementCount]; UInt16[] outArray = new UInt16[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(op1), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(op2), (uint)Unsafe.SizeOf<Vector64<Byte>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<UInt16>>()); ValidateResult(inArray1, inArray2, outArray, method); } private void ValidateResult(UInt16[] left, Byte[] right, UInt16[] result, [CallerMemberName] string method = "") { bool succeeded = true; for (var i = 0; i < RetElementCount; i++) { if (Helpers.AddWidening(left[i], right[i]) != result[i]) { succeeded = false; break; } } if (!succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(AdvSimd)}.{nameof(AdvSimd.AddWideningLower)}<UInt16>(Vector128<UInt16>, Vector64<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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Regression/JitBlue/GitHub_21231/GitHub_21231a.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <DebugType /> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <DebugType /> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/IPersistComponentSettings.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 { /// <summary> /// Components should implement this interface if they want to persist custom settings /// in a hosting application. This interface allows the application author to tell a control /// whether to persist, when to load, save etc. /// </summary> public interface IPersistComponentSettings { /// <summary> /// Indicates to the implementor that settings should be persisted. /// </summary> bool SaveSettings { get; set; } /// <summary> /// Unique key that identifies an individual instance of a settings group(s). This key is needed /// to identify which instance of a component owns a given group(s) of settings. Usually, the component /// will frame its own key, but this property allows the hosting application to override it if necessary. /// </summary> string SettingsKey { get; set; } /// <summary> /// Tells the component to load its settings. /// </summary> void LoadComponentSettings(); /// <summary> /// Tells the component to save its settings. /// </summary> void SaveComponentSettings(); /// <summary> /// Tells the component to reset its settings. Typically, the component can call Reset on its settings class(es). /// </summary> void ResetComponentSettings(); } }
// 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 { /// <summary> /// Components should implement this interface if they want to persist custom settings /// in a hosting application. This interface allows the application author to tell a control /// whether to persist, when to load, save etc. /// </summary> public interface IPersistComponentSettings { /// <summary> /// Indicates to the implementor that settings should be persisted. /// </summary> bool SaveSettings { get; set; } /// <summary> /// Unique key that identifies an individual instance of a settings group(s). This key is needed /// to identify which instance of a component owns a given group(s) of settings. Usually, the component /// will frame its own key, but this property allows the hosting application to override it if necessary. /// </summary> string SettingsKey { get; set; } /// <summary> /// Tells the component to load its settings. /// </summary> void LoadComponentSettings(); /// <summary> /// Tells the component to save its settings. /// </summary> void SaveComponentSettings(); /// <summary> /// Tells the component to reset its settings. Typically, the component can call Reset on its settings class(es). /// </summary> void ResetComponentSettings(); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/VTableSliceProvider.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Internal.TypeSystem; using ILCompiler.DependencyAnalysis; namespace ILCompiler { /// <summary> /// Provides VTable information for a specific type. /// </summary> public abstract class VTableSliceProvider { internal abstract VTableSliceNode GetSlice(TypeDesc type); } /// <summary> /// Provides VTable information that collects data during the compilation to build a VTable for a type. /// </summary> public sealed class LazyVTableSliceProvider : VTableSliceProvider { internal override VTableSliceNode GetSlice(TypeDesc type) { return new LazilyBuiltVTableSliceNode(type); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Internal.TypeSystem; using ILCompiler.DependencyAnalysis; namespace ILCompiler { /// <summary> /// Provides VTable information for a specific type. /// </summary> public abstract class VTableSliceProvider { internal abstract VTableSliceNode GetSlice(TypeDesc type); } /// <summary> /// Provides VTable information that collects data during the compilation to build a VTable for a type. /// </summary> public sealed class LazyVTableSliceProvider : VTableSliceProvider { internal override VTableSliceNode GetSlice(TypeDesc type) { return new LazilyBuiltVTableSliceNode(type); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b16122/b16122.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,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/mono/mono/tests/dim-constrained3_gm.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 constrained3_gm { } .class interface private abstract auto ansi IFrobber`1<T> { .method public hidebysig newslot virtual instance int32 Frob<U>() { ldstr "IFrobber<T>:Frob" call void [mscorlib]System.Console::WriteLine(string) ldc.i4 34 ret } } .class interface private abstract auto ansi IRobber`1<T> implements class IFrobber`1<!T> { .method public hidebysig final newslot virtual instance int32 Frob<U>() { .override class IFrobber`1<!T>::Frob ldstr "IRobber<T>:Frob" call void [mscorlib]System.Console::WriteLine(string) ldc.i4 66 ret } } .class interface private abstract auto ansi IGrabber`1<T> implements class IFrobber`1<!T> { .method public hidebysig final newslot virtual instance int32 Frob<U>() { .override class IFrobber`1<!T>::Frob ldstr "IGrabber<T>:Frob" call void [mscorlib]System.Console::WriteLine(string) ldc.i4.3 ret } } .class value Adder`1<T, U> implements class IFrobber`1<!T>, class IRobber`1<!U>, class IGrabber`1<!U[]> { } .method public hidebysig static int32 Main() { .entrypoint .locals init ( valuetype Adder`1<object, string> ) ldloca.s 0 constrained. valuetype Adder`1<object, string> callvirt instance int32 class IFrobber`1<object>::Frob<object>() ldloca.s 0 constrained. valuetype Adder`1<object, string> callvirt instance int32 class IFrobber`1<string>::Frob<object>() add ldc.i4 100 sub 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 { } .assembly constrained3_gm { } .class interface private abstract auto ansi IFrobber`1<T> { .method public hidebysig newslot virtual instance int32 Frob<U>() { ldstr "IFrobber<T>:Frob" call void [mscorlib]System.Console::WriteLine(string) ldc.i4 34 ret } } .class interface private abstract auto ansi IRobber`1<T> implements class IFrobber`1<!T> { .method public hidebysig final newslot virtual instance int32 Frob<U>() { .override class IFrobber`1<!T>::Frob ldstr "IRobber<T>:Frob" call void [mscorlib]System.Console::WriteLine(string) ldc.i4 66 ret } } .class interface private abstract auto ansi IGrabber`1<T> implements class IFrobber`1<!T> { .method public hidebysig final newslot virtual instance int32 Frob<U>() { .override class IFrobber`1<!T>::Frob ldstr "IGrabber<T>:Frob" call void [mscorlib]System.Console::WriteLine(string) ldc.i4.3 ret } } .class value Adder`1<T, U> implements class IFrobber`1<!T>, class IRobber`1<!U>, class IGrabber`1<!U[]> { } .method public hidebysig static int32 Main() { .entrypoint .locals init ( valuetype Adder`1<object, string> ) ldloca.s 0 constrained. valuetype Adder`1<object, string> callvirt instance int32 class IFrobber`1<object>::Frob<object>() ldloca.s 0 constrained. valuetype Adder`1<object, string> callvirt instance int32 class IFrobber`1<string>::Frob<object>() add ldc.i4 100 sub ret }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/Common/src/System/Net/NetworkInformation/HostInformationPal.Unix.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.Net.NetworkInformation { internal static class HostInformationPal { public static string GetHostName() { return Interop.Sys.GetHostName(); } public static string GetDomainName() { return Interop.Sys.GetDomainName(); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace System.Net.NetworkInformation { internal static class HostInformationPal { public static string GetHostName() { return Interop.Sys.GetHostName(); } public static string GetDomainName() { return Interop.Sys.GetDomainName(); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Composition.AttributedModel/src/System/Composition/SharingBoundaryAttribute.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.ObjectModel; namespace System.Composition { /// <summary> /// Applied to an import for ExportFactory{T}, this attribute marks the /// boundary of a sharing scope. The ExportLifetimeContext{T} instances /// returned from the factory will be boundaries for sharing of components that are bounded /// by the listed boundary names. /// </summary> /// <example> /// [Import, SharingBoundary("HttpRequest")] /// public ExportFactory&lt;HttpRequestHandler&gt; HandlerFactory { get; set; } /// </example> /// <seealso cref="SharedAttribute" /> [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)] [MetadataAttribute] [CLSCompliant(false)] public sealed class SharingBoundaryAttribute : Attribute { private readonly string[] _sharingBoundaryNames; /// <summary> /// Construct a <see cref="SharingBoundaryAttribute"/> for the specified boundary names. /// </summary> /// <param name="sharingBoundaryNames">Boundaries implemented by the created ExportLifetimeContext{T}s.</param> public SharingBoundaryAttribute(params string[] sharingBoundaryNames!!) { _sharingBoundaryNames = sharingBoundaryNames; } /// <summary> /// Boundaries implemented by the created ExportLifetimeContext{T}s. /// </summary> public ReadOnlyCollection<string> SharingBoundaryNames => new ReadOnlyCollection<string>(_sharingBoundaryNames); } }
// 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.ObjectModel; namespace System.Composition { /// <summary> /// Applied to an import for ExportFactory{T}, this attribute marks the /// boundary of a sharing scope. The ExportLifetimeContext{T} instances /// returned from the factory will be boundaries for sharing of components that are bounded /// by the listed boundary names. /// </summary> /// <example> /// [Import, SharingBoundary("HttpRequest")] /// public ExportFactory&lt;HttpRequestHandler&gt; HandlerFactory { get; set; } /// </example> /// <seealso cref="SharedAttribute" /> [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)] [MetadataAttribute] [CLSCompliant(false)] public sealed class SharingBoundaryAttribute : Attribute { private readonly string[] _sharingBoundaryNames; /// <summary> /// Construct a <see cref="SharingBoundaryAttribute"/> for the specified boundary names. /// </summary> /// <param name="sharingBoundaryNames">Boundaries implemented by the created ExportLifetimeContext{T}s.</param> public SharingBoundaryAttribute(params string[] sharingBoundaryNames!!) { _sharingBoundaryNames = sharingBoundaryNames; } /// <summary> /// Boundaries implemented by the created ExportLifetimeContext{T}s. /// </summary> public ReadOnlyCollection<string> SharingBoundaryNames => new ReadOnlyCollection<string>(_sharingBoundaryNames); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Directed/rvastatics/rvastatic4.il
.assembly extern mscorlib{} .assembly extern xunit.core {} .assembly rvastatic4{} .class public A{ .method static native int Call1(int64) {.maxstack 50 ldarg.0 conv.i8 dup dup xor xor conv.i conv.i ret } .method static native int Call2(float64) {.maxstack 50 ldarg.0 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i conv.i8 ldc.i4 32 shl or conv.i conv.i ret } .method static void V1() {.maxstack 50 ldsfld int32 [rvastatic4]A::a0100 ldc.i4 0 beq a0101 newobj instance void [mscorlib]System.Exception::.ctor() throw a0101: ldsfld int64 [rvastatic4]A::a0101 ldc.i8 1 beq a0102 newobj instance void [mscorlib]System.Exception::.ctor() throw a0102: ldsfld float32 [rvastatic4]A::a0102 ldc.r4 2.0 beq a0103 newobj instance void [mscorlib]System.Exception::.ctor() throw a0103: ldsfld int16 [rvastatic4]A::a0103 ldc.i4 3 beq a0104 newobj instance void [mscorlib]System.Exception::.ctor() throw a0104: ldsfld int16 [rvastatic4]A::a0104 ldc.i4 4 beq a0105 newobj instance void [mscorlib]System.Exception::.ctor() throw a0105: ldsfld int64 [rvastatic4]A::a0105 ldc.i8 5 beq a0106 newobj instance void [mscorlib]System.Exception::.ctor() throw a0106: ldsfld int16 [rvastatic4]A::a0106 ldc.i4 6 beq a0107 newobj instance void [mscorlib]System.Exception::.ctor() throw a0107: ldsfld int8 [rvastatic4]A::a0107 ldc.i4 7 beq a0108 newobj instance void [mscorlib]System.Exception::.ctor() throw a0108: ldsfld int64 [rvastatic4]A::a0108 ldc.i8 8 beq a0109 newobj instance void [mscorlib]System.Exception::.ctor() throw a0109: ldsfld int32 [rvastatic4]A::a0109 ldc.i4 9 beq a01010 newobj instance void [mscorlib]System.Exception::.ctor() throw a01010: ldsfld int16 [rvastatic4]A::a01010 ldc.i4 10 beq a01011 newobj instance void [mscorlib]System.Exception::.ctor() throw a01011: ldsfld float32 [rvastatic4]A::a01011 ldc.r4 11.0 beq a01012 newobj instance void [mscorlib]System.Exception::.ctor() throw a01012: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a01013 newobj instance void [mscorlib]System.Exception::.ctor() throw a01013: ldsfld float32 [rvastatic4]A::a01013 ldc.r4 13.0 beq a01014 newobj instance void [mscorlib]System.Exception::.ctor() throw a01014: ldsfld float32 [rvastatic4]A::a01014 ldc.r4 14.0 beq a01015 newobj instance void [mscorlib]System.Exception::.ctor() throw a01015: ldsfld int8 [rvastatic4]A::a01015 ldc.i4 15 beq a01016 newobj instance void [mscorlib]System.Exception::.ctor() throw a01016: ldsfld float32 [rvastatic4]A::a01016 ldc.r4 16.0 beq a01017 newobj instance void [mscorlib]System.Exception::.ctor() throw a01017: ldsfld int8 [rvastatic4]A::a01017 ldc.i4 17 beq a01018 newobj instance void [mscorlib]System.Exception::.ctor() throw a01018: ldsfld float32 [rvastatic4]A::a01018 ldc.r4 18.0 beq a01019 newobj instance void [mscorlib]System.Exception::.ctor() throw a01019: ldsfld float32 [rvastatic4]A::a01019 ldc.r4 19.0 beq a01020 newobj instance void [mscorlib]System.Exception::.ctor() throw a01020: ldsfld int8 [rvastatic4]A::a01020 ldc.i4 20 beq a01021 newobj instance void [mscorlib]System.Exception::.ctor() throw a01021: ldsfld float32 [rvastatic4]A::a01021 ldc.r4 21.0 beq a01022 newobj instance void [mscorlib]System.Exception::.ctor() throw a01022: ldsfld int64 [rvastatic4]A::a01022 ldc.i8 22 beq a01023 newobj instance void [mscorlib]System.Exception::.ctor() throw a01023: ldsfld int8 [rvastatic4]A::a01023 ldc.i4 23 beq a01024 newobj instance void [mscorlib]System.Exception::.ctor() throw a01024: ldsfld int32 [rvastatic4]A::a01024 ldc.i4 24 beq a01025 newobj instance void [mscorlib]System.Exception::.ctor() throw a01025: ldsfld int64 [rvastatic4]A::a01025 ldc.i8 25 beq a01026 newobj instance void [mscorlib]System.Exception::.ctor() throw a01026: ldsfld int16 [rvastatic4]A::a01026 ldc.i4 26 beq a01027 newobj instance void [mscorlib]System.Exception::.ctor() throw a01027: ldsfld int8 [rvastatic4]A::a01027 ldc.i4 27 beq a01028 newobj instance void [mscorlib]System.Exception::.ctor() throw a01028: ldsfld int16 [rvastatic4]A::a01028 ldc.i4 28 beq a01029 newobj instance void [mscorlib]System.Exception::.ctor() throw a01029: ldsfld int16 [rvastatic4]A::a01029 ldc.i4 29 beq a01030 newobj instance void [mscorlib]System.Exception::.ctor() throw a01030: ldsfld int8 [rvastatic4]A::a01030 ldc.i4 30 beq a01031 newobj instance void [mscorlib]System.Exception::.ctor() throw a01031: ldsfld int8 [rvastatic4]A::a01031 ldc.i4 31 beq a01032 newobj instance void [mscorlib]System.Exception::.ctor() throw a01032: ldsfld int64 [rvastatic4]A::a01032 ldc.i8 32 beq a01033 newobj instance void [mscorlib]System.Exception::.ctor() throw a01033: ldsfld float32 [rvastatic4]A::a01033 ldc.r4 33.0 beq a01034 newobj instance void [mscorlib]System.Exception::.ctor() throw a01034: ldsfld int16 [rvastatic4]A::a01034 ldc.i4 34 beq a01035 newobj instance void [mscorlib]System.Exception::.ctor() throw a01035: ldsfld int8 [rvastatic4]A::a01035 ldc.i4 35 beq a01036 newobj instance void [mscorlib]System.Exception::.ctor() throw a01036: ldsfld int8 [rvastatic4]A::a01036 ldc.i4 36 beq a01037 newobj instance void [mscorlib]System.Exception::.ctor() throw a01037: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a01038 newobj instance void [mscorlib]System.Exception::.ctor() throw a01038: ldsfld int16 [rvastatic4]A::a01038 ldc.i4 38 beq a01039 newobj instance void [mscorlib]System.Exception::.ctor() throw a01039: ldsfld int8 [rvastatic4]A::a01039 ldc.i4 39 beq a01040 newobj instance void [mscorlib]System.Exception::.ctor() throw a01040: ldsfld int8 [rvastatic4]A::a01040 ldc.i4 40 beq a01041 newobj instance void [mscorlib]System.Exception::.ctor() throw a01041: ldsfld int32 [rvastatic4]A::a01041 ldc.i4 41 beq a01042 newobj instance void [mscorlib]System.Exception::.ctor() throw a01042: ldsfld int64 [rvastatic4]A::a01042 ldc.i8 42 beq a01043 newobj instance void [mscorlib]System.Exception::.ctor() throw a01043: ldsfld int16 [rvastatic4]A::a01043 ldc.i4 43 beq a01044 newobj instance void [mscorlib]System.Exception::.ctor() throw a01044: ldsfld int64 [rvastatic4]A::a01044 ldc.i8 44 beq a01045 newobj instance void [mscorlib]System.Exception::.ctor() throw a01045: ldsfld int64 [rvastatic4]A::a01045 ldc.i8 45 beq a01046 newobj instance void [mscorlib]System.Exception::.ctor() throw a01046: ldsfld float32 [rvastatic4]A::a01046 ldc.r4 46.0 beq a01047 newobj instance void [mscorlib]System.Exception::.ctor() throw a01047: ldsfld int16 [rvastatic4]A::a01047 ldc.i4 47 beq a01048 newobj instance void [mscorlib]System.Exception::.ctor() throw a01048: ldsfld int64 [rvastatic4]A::a01048 ldc.i8 48 beq a01049 newobj instance void [mscorlib]System.Exception::.ctor() throw a01049: ldsfld int16 [rvastatic4]A::a01049 ldc.i4 49 beq a01050 newobj instance void [mscorlib]System.Exception::.ctor() throw a01050: ldsfld int32 [rvastatic4]A::a01050 ldc.i4 50 beq a01051 newobj instance void [mscorlib]System.Exception::.ctor() throw a01051: ldsfld int16 [rvastatic4]A::a01051 ldc.i4 51 beq a01052 newobj instance void [mscorlib]System.Exception::.ctor() throw a01052: ldsfld int32 [rvastatic4]A::a01052 ldc.i4 52 beq a01053 newobj instance void [mscorlib]System.Exception::.ctor() throw a01053: ldsfld int16 [rvastatic4]A::a01053 ldc.i4 53 beq a01054 newobj instance void [mscorlib]System.Exception::.ctor() throw a01054: ldsfld float32 [rvastatic4]A::a01054 ldc.r4 54.0 beq a01055 newobj instance void [mscorlib]System.Exception::.ctor() throw a01055: ldsfld int64 [rvastatic4]A::a01055 ldc.i8 55 beq a01056 newobj instance void [mscorlib]System.Exception::.ctor() throw a01056: ldsfld float32 [rvastatic4]A::a01056 ldc.r4 56.0 beq a01057 newobj instance void [mscorlib]System.Exception::.ctor() throw a01057: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 57 beq a01058 newobj instance void [mscorlib]System.Exception::.ctor() throw a01058: ldsfld int64 [rvastatic4]A::a01058 ldc.i8 58 beq a01059 newobj instance void [mscorlib]System.Exception::.ctor() throw a01059: ldsfld int64 [rvastatic4]A::a01059 ldc.i8 59 beq a01060 newobj instance void [mscorlib]System.Exception::.ctor() throw a01060: ldsfld int16 [rvastatic4]A::a01060 ldc.i4 60 beq a01061 newobj instance void [mscorlib]System.Exception::.ctor() throw a01061: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 61 beq a01062 newobj instance void [mscorlib]System.Exception::.ctor() throw a01062: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a01063 newobj instance void [mscorlib]System.Exception::.ctor() throw a01063: ldsfld int16 [rvastatic4]A::a01063 ldc.i4 63 beq a01064 newobj instance void [mscorlib]System.Exception::.ctor() throw a01064: ldsfld int32 [rvastatic4]A::a01064 ldc.i4 64 beq a01065 newobj instance void [mscorlib]System.Exception::.ctor() throw a01065: ldsfld int16 [rvastatic4]A::a01065 ldc.i4 65 beq a01066 newobj instance void [mscorlib]System.Exception::.ctor() throw a01066: ldsfld int8 [rvastatic4]A::a01066 ldc.i4 66 beq a01067 newobj instance void [mscorlib]System.Exception::.ctor() throw a01067: ldsfld int16 [rvastatic4]A::a01067 ldc.i4 67 beq a01068 newobj instance void [mscorlib]System.Exception::.ctor() throw a01068: ldsfld int32 [rvastatic4]A::a01068 ldc.i4 68 beq a01069 newobj instance void [mscorlib]System.Exception::.ctor() throw a01069: ldsfld float32 [rvastatic4]A::a01069 ldc.r4 69.0 beq a01070 newobj instance void [mscorlib]System.Exception::.ctor() throw a01070: ldsfld float32 [rvastatic4]A::a01070 ldc.r4 70.0 beq a01071 newobj instance void [mscorlib]System.Exception::.ctor() throw a01071: ldsfld int16 [rvastatic4]A::a01071 ldc.i4 71 beq a01072 newobj instance void [mscorlib]System.Exception::.ctor() throw a01072: ldsfld float32 [rvastatic4]A::a01072 ldc.r4 72.0 beq a01073 newobj instance void [mscorlib]System.Exception::.ctor() throw a01073: ldsfld int64 [rvastatic4]A::a01073 ldc.i8 73 beq a01074 newobj instance void [mscorlib]System.Exception::.ctor() throw a01074: ldsfld int64 [rvastatic4]A::a01074 ldc.i8 74 beq a01075 newobj instance void [mscorlib]System.Exception::.ctor() throw a01075: ldsfld int32 [rvastatic4]A::a01075 ldc.i4 75 beq a01076 newobj instance void [mscorlib]System.Exception::.ctor() throw a01076: ldsfld int8 [rvastatic4]A::a01076 ldc.i4 76 beq a01077 newobj instance void [mscorlib]System.Exception::.ctor() throw a01077: ldsfld int32 [rvastatic4]A::a01077 ldc.i4 77 beq a01078 newobj instance void [mscorlib]System.Exception::.ctor() throw a01078: ldsfld int16 [rvastatic4]A::a01078 ldc.i4 78 beq a01079 newobj instance void [mscorlib]System.Exception::.ctor() throw a01079: ldsfld float32 [rvastatic4]A::a01079 ldc.r4 79.0 beq a01080 newobj instance void [mscorlib]System.Exception::.ctor() throw a01080: ldsfld float32 [rvastatic4]A::a01080 ldc.r4 80.0 beq a01081 newobj instance void [mscorlib]System.Exception::.ctor() throw a01081: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 81.0 beq a01082 newobj instance void [mscorlib]System.Exception::.ctor() throw a01082: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 82 beq a01083 newobj instance void [mscorlib]System.Exception::.ctor() throw a01083: ldsfld int8 [rvastatic4]A::a01083 ldc.i4 83 beq a01084 newobj instance void [mscorlib]System.Exception::.ctor() throw a01084: ldsfld int64 [rvastatic4]A::a01084 ldc.i8 84 beq a01085 newobj instance void [mscorlib]System.Exception::.ctor() throw a01085: ldsfld int64 [rvastatic4]A::a01085 ldc.i8 85 beq a01086 newobj instance void [mscorlib]System.Exception::.ctor() throw a01086: ldsfld int32 [rvastatic4]A::a01086 ldc.i4 86 beq a01087 newobj instance void [mscorlib]System.Exception::.ctor() throw a01087: ldsfld int32 [rvastatic4]A::a01087 ldc.i4 87 beq a01088 newobj instance void [mscorlib]System.Exception::.ctor() throw a01088: ldsfld int8 [rvastatic4]A::a01088 ldc.i4 88 beq a01089 newobj instance void [mscorlib]System.Exception::.ctor() throw a01089: ldsfld int64 [rvastatic4]A::a01089 ldc.i8 89 beq a01090 newobj instance void [mscorlib]System.Exception::.ctor() throw a01090: ldsfld int8 [rvastatic4]A::a01090 ldc.i4 90 beq a01091 newobj instance void [mscorlib]System.Exception::.ctor() throw a01091: ldsfld int16 [rvastatic4]A::a01091 ldc.i4 91 beq a01092 newobj instance void [mscorlib]System.Exception::.ctor() throw a01092: ldsfld float32 [rvastatic4]A::a01092 ldc.r4 92.0 beq a01093 newobj instance void [mscorlib]System.Exception::.ctor() throw a01093: ldsfld int64 [rvastatic4]A::a01093 ldc.i8 93 beq a01094 newobj instance void [mscorlib]System.Exception::.ctor() throw a01094: ldsfld int64 [rvastatic4]A::a01094 ldc.i8 94 beq a01095 newobj instance void [mscorlib]System.Exception::.ctor() throw a01095: ldsfld int8 [rvastatic4]A::a01095 ldc.i4 95 beq a01096 newobj instance void [mscorlib]System.Exception::.ctor() throw a01096: ldsfld float32 [rvastatic4]A::a01096 ldc.r4 96.0 beq a01097 newobj instance void [mscorlib]System.Exception::.ctor() throw a01097: ldsfld int16 [rvastatic4]A::a01097 ldc.i4 97 beq a01098 newobj instance void [mscorlib]System.Exception::.ctor() throw a01098: ldsfld float32 [rvastatic4]A::a01098 ldc.r4 98.0 beq a01099 newobj instance void [mscorlib]System.Exception::.ctor() throw a01099: ldsfld int32 [rvastatic4]A::a01099 ldc.i4 99 beq a010100 newobj instance void [mscorlib]System.Exception::.ctor() throw a010100: ldsfld int64 [rvastatic4]A::a010100 ldc.i8 100 beq a010101 newobj instance void [mscorlib]System.Exception::.ctor() throw a010101: ldsfld int32 [rvastatic4]A::a010101 ldc.i4 101 beq a010102 newobj instance void [mscorlib]System.Exception::.ctor() throw a010102: ldsfld float32 [rvastatic4]A::a010102 ldc.r4 102.0 beq a010103 newobj instance void [mscorlib]System.Exception::.ctor() throw a010103: ldsfld int64 [rvastatic4]A::a010103 ldc.i8 103 beq a010104 newobj instance void [mscorlib]System.Exception::.ctor() throw a010104: ldsfld int32 [rvastatic4]A::a010104 ldc.i4 104 beq a010105 newobj instance void [mscorlib]System.Exception::.ctor() throw a010105: ldsfld int16 [rvastatic4]A::a010105 ldc.i4 105 beq a010106 newobj instance void [mscorlib]System.Exception::.ctor() throw a010106: ldsfld int16 [rvastatic4]A::a010106 ldc.i4 106 beq a010107 newobj instance void [mscorlib]System.Exception::.ctor() throw a010107: ldsfld float32 [rvastatic4]A::a010107 ldc.r4 107.0 beq a010108 newobj instance void [mscorlib]System.Exception::.ctor() throw a010108: ldsfld int32 [rvastatic4]A::a010108 ldc.i4 108 beq a010109 newobj instance void [mscorlib]System.Exception::.ctor() throw a010109: ldsfld int16 [rvastatic4]A::a010109 ldc.i4 109 beq a010110 newobj instance void [mscorlib]System.Exception::.ctor() throw a010110: ldsfld int32 [rvastatic4]A::a010110 ldc.i4 110 beq a010111 newobj instance void [mscorlib]System.Exception::.ctor() throw a010111: ldsfld int32 [rvastatic4]A::a010111 ldc.i4 111 beq a010112 newobj instance void [mscorlib]System.Exception::.ctor() throw a010112: ldsfld int32 [rvastatic4]A::a010112 ldc.i4 112 beq a010113 newobj instance void [mscorlib]System.Exception::.ctor() throw a010113: ldsfld int64 [rvastatic4]A::a010113 ldc.i8 113 beq a010114 newobj instance void [mscorlib]System.Exception::.ctor() throw a010114: ldsfld int64 [rvastatic4]A::a010114 ldc.i8 114 beq a010115 newobj instance void [mscorlib]System.Exception::.ctor() throw a010115: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 115 beq a010116 newobj instance void [mscorlib]System.Exception::.ctor() throw a010116: ldsfld int64 [rvastatic4]A::a010116 ldc.i8 116 beq a010117 newobj instance void [mscorlib]System.Exception::.ctor() throw a010117: ldsfld int64 [rvastatic4]A::a010117 ldc.i8 117 beq a010118 newobj instance void [mscorlib]System.Exception::.ctor() throw a010118: ldsfld int32 [rvastatic4]A::a010118 ldc.i4 118 beq a010119 newobj instance void [mscorlib]System.Exception::.ctor() throw a010119: ldsfld int64 [rvastatic4]A::a010119 ldc.i8 119 beq a010120 newobj instance void [mscorlib]System.Exception::.ctor() throw a010120: ldsfld int64 [rvastatic4]A::a010120 ldc.i8 120 beq a010121 newobj instance void [mscorlib]System.Exception::.ctor() throw a010121: ldsfld int64 [rvastatic4]A::a010121 ldc.i8 121 beq a010122 newobj instance void [mscorlib]System.Exception::.ctor() throw a010122: ldsfld int16 [rvastatic4]A::a010122 ldc.i4 122 beq a010123 newobj instance void [mscorlib]System.Exception::.ctor() throw a010123: ldsfld int64 [rvastatic4]A::a010123 ldc.i8 123 beq a010124 newobj instance void [mscorlib]System.Exception::.ctor() throw a010124: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 124 beq a010125 newobj instance void [mscorlib]System.Exception::.ctor() throw a010125: ldsfld int32 [rvastatic4]A::a010125 ldc.i4 125 beq a010126 newobj instance void [mscorlib]System.Exception::.ctor() throw a010126: ldsfld int16 [rvastatic4]A::a010126 ldc.i4 126 beq a010127 newobj instance void [mscorlib]System.Exception::.ctor() throw a010127: ldsfld int16 [rvastatic4]A::a010127 ldc.i4 127 beq a010128 newobj instance void [mscorlib]System.Exception::.ctor() throw a010128: ret} .method static void V2() {.maxstack 50 ldsflda int32 [rvastatic4]A::a0100 ldind.i4 ldc.i4 0 beq a0100 newobj instance void [mscorlib]System.Exception::.ctor() throw a0100: ldsflda int64 [rvastatic4]A::a0101 ldind.i8 ldc.i8 1 beq a0101 newobj instance void [mscorlib]System.Exception::.ctor() throw a0101: ldsflda float32 [rvastatic4]A::a0102 ldind.r4 ldc.r4 2.0 beq a0102 newobj instance void [mscorlib]System.Exception::.ctor() throw a0102: ldsflda int16 [rvastatic4]A::a0103 ldind.i2 ldc.i4 3 beq a0103 newobj instance void [mscorlib]System.Exception::.ctor() throw a0103: ldsflda int16 [rvastatic4]A::a0104 ldind.i2 ldc.i4 4 beq a0104 newobj instance void [mscorlib]System.Exception::.ctor() throw a0104: ldsflda int64 [rvastatic4]A::a0105 ldind.i8 ldc.i8 5 beq a0105 newobj instance void [mscorlib]System.Exception::.ctor() throw a0105: ldsflda int16 [rvastatic4]A::a0106 ldind.i2 ldc.i4 6 beq a0106 newobj instance void [mscorlib]System.Exception::.ctor() throw a0106: ldsflda int8 [rvastatic4]A::a0107 ldind.i1 ldc.i4 7 beq a0107 newobj instance void [mscorlib]System.Exception::.ctor() throw a0107: ldsflda int64 [rvastatic4]A::a0108 ldind.i8 ldc.i8 8 beq a0108 newobj instance void [mscorlib]System.Exception::.ctor() throw a0108: ldsflda int32 [rvastatic4]A::a0109 ldind.i4 ldc.i4 9 beq a0109 newobj instance void [mscorlib]System.Exception::.ctor() throw a0109: ldsflda int16 [rvastatic4]A::a01010 ldind.i2 ldc.i4 10 beq a01010 newobj instance void [mscorlib]System.Exception::.ctor() throw a01010: ldsflda float32 [rvastatic4]A::a01011 ldind.r4 ldc.r4 11.0 beq a01011 newobj instance void [mscorlib]System.Exception::.ctor() throw a01011: ldsflda int16 [rvastatic4]A::a01012 ldind.i2 ldc.i4 12 beq a01012 newobj instance void [mscorlib]System.Exception::.ctor() throw a01012: ldsflda float32 [rvastatic4]A::a01013 ldind.r4 ldc.r4 13.0 beq a01013 newobj instance void [mscorlib]System.Exception::.ctor() throw a01013: ldsflda float32 [rvastatic4]A::a01014 ldind.r4 ldc.r4 14.0 beq a01014 newobj instance void [mscorlib]System.Exception::.ctor() throw a01014: ldsflda int8 [rvastatic4]A::a01015 ldind.i1 ldc.i4 15 beq a01015 newobj instance void [mscorlib]System.Exception::.ctor() throw a01015: ldsflda float32 [rvastatic4]A::a01016 ldind.r4 ldc.r4 16.0 beq a01016 newobj instance void [mscorlib]System.Exception::.ctor() throw a01016: ldsflda int8 [rvastatic4]A::a01017 ldind.i1 ldc.i4 17 beq a01017 newobj instance void [mscorlib]System.Exception::.ctor() throw a01017: ldsflda float32 [rvastatic4]A::a01018 ldind.r4 ldc.r4 18.0 beq a01018 newobj instance void [mscorlib]System.Exception::.ctor() throw a01018: ldsflda float32 [rvastatic4]A::a01019 ldind.r4 ldc.r4 19.0 beq a01019 newobj instance void [mscorlib]System.Exception::.ctor() throw a01019: ldsflda int8 [rvastatic4]A::a01020 ldind.i1 ldc.i4 20 beq a01020 newobj instance void [mscorlib]System.Exception::.ctor() throw a01020: ldsflda float32 [rvastatic4]A::a01021 ldind.r4 ldc.r4 21.0 beq a01021 newobj instance void [mscorlib]System.Exception::.ctor() throw a01021: ldsflda int64 [rvastatic4]A::a01022 ldind.i8 ldc.i8 22 beq a01022 newobj instance void [mscorlib]System.Exception::.ctor() throw a01022: ldsflda int8 [rvastatic4]A::a01023 ldind.i1 ldc.i4 23 beq a01023 newobj instance void [mscorlib]System.Exception::.ctor() throw a01023: ldsflda int32 [rvastatic4]A::a01024 ldind.i4 ldc.i4 24 beq a01024 newobj instance void [mscorlib]System.Exception::.ctor() throw a01024: ldsflda int64 [rvastatic4]A::a01025 ldind.i8 ldc.i8 25 beq a01025 newobj instance void [mscorlib]System.Exception::.ctor() throw a01025: ldsflda int16 [rvastatic4]A::a01026 ldind.i2 ldc.i4 26 beq a01026 newobj instance void [mscorlib]System.Exception::.ctor() throw a01026: ldsflda int8 [rvastatic4]A::a01027 ldind.i1 ldc.i4 27 beq a01027 newobj instance void [mscorlib]System.Exception::.ctor() throw a01027: ldsflda int16 [rvastatic4]A::a01028 ldind.i2 ldc.i4 28 beq a01028 newobj instance void [mscorlib]System.Exception::.ctor() throw a01028: ldsflda int16 [rvastatic4]A::a01029 ldind.i2 ldc.i4 29 beq a01029 newobj instance void [mscorlib]System.Exception::.ctor() throw a01029: ldsflda int8 [rvastatic4]A::a01030 ldind.i1 ldc.i4 30 beq a01030 newobj instance void [mscorlib]System.Exception::.ctor() throw a01030: ldsflda int8 [rvastatic4]A::a01031 ldind.i1 ldc.i4 31 beq a01031 newobj instance void [mscorlib]System.Exception::.ctor() throw a01031: ldsflda int64 [rvastatic4]A::a01032 ldind.i8 ldc.i8 32 beq a01032 newobj instance void [mscorlib]System.Exception::.ctor() throw a01032: ldsflda float32 [rvastatic4]A::a01033 ldind.r4 ldc.r4 33.0 beq a01033 newobj instance void [mscorlib]System.Exception::.ctor() throw a01033: ldsflda int16 [rvastatic4]A::a01034 ldind.i2 ldc.i4 34 beq a01034 newobj instance void [mscorlib]System.Exception::.ctor() throw a01034: ldsflda int8 [rvastatic4]A::a01035 ldind.i1 ldc.i4 35 beq a01035 newobj instance void [mscorlib]System.Exception::.ctor() throw a01035: ldsflda int8 [rvastatic4]A::a01036 ldind.i1 ldc.i4 36 beq a01036 newobj instance void [mscorlib]System.Exception::.ctor() throw a01036: ldsflda int32 [rvastatic4]A::a01037 ldind.i4 ldc.i4 37 beq a01037 newobj instance void [mscorlib]System.Exception::.ctor() throw a01037: ldsflda int16 [rvastatic4]A::a01038 ldind.i2 ldc.i4 38 beq a01038 newobj instance void [mscorlib]System.Exception::.ctor() throw a01038: ldsflda int8 [rvastatic4]A::a01039 ldind.i1 ldc.i4 39 beq a01039 newobj instance void [mscorlib]System.Exception::.ctor() throw a01039: ldsflda int8 [rvastatic4]A::a01040 ldind.i1 ldc.i4 40 beq a01040 newobj instance void [mscorlib]System.Exception::.ctor() throw a01040: ldsflda int32 [rvastatic4]A::a01041 ldind.i4 ldc.i4 41 beq a01041 newobj instance void [mscorlib]System.Exception::.ctor() throw a01041: ldsflda int64 [rvastatic4]A::a01042 ldind.i8 ldc.i8 42 beq a01042 newobj instance void [mscorlib]System.Exception::.ctor() throw a01042: ldsflda int16 [rvastatic4]A::a01043 ldind.i2 ldc.i4 43 beq a01043 newobj instance void [mscorlib]System.Exception::.ctor() throw a01043: ldsflda int64 [rvastatic4]A::a01044 ldind.i8 ldc.i8 44 beq a01044 newobj instance void [mscorlib]System.Exception::.ctor() throw a01044: ldsflda int64 [rvastatic4]A::a01045 ldind.i8 ldc.i8 45 beq a01045 newobj instance void [mscorlib]System.Exception::.ctor() throw a01045: ldsflda float32 [rvastatic4]A::a01046 ldind.r4 ldc.r4 46.0 beq a01046 newobj instance void [mscorlib]System.Exception::.ctor() throw a01046: ldsflda int16 [rvastatic4]A::a01047 ldind.i2 ldc.i4 47 beq a01047 newobj instance void [mscorlib]System.Exception::.ctor() throw a01047: ldsflda int64 [rvastatic4]A::a01048 ldind.i8 ldc.i8 48 beq a01048 newobj instance void [mscorlib]System.Exception::.ctor() throw a01048: ldsflda int16 [rvastatic4]A::a01049 ldind.i2 ldc.i4 49 beq a01049 newobj instance void [mscorlib]System.Exception::.ctor() throw a01049: ldsflda int32 [rvastatic4]A::a01050 ldind.i4 ldc.i4 50 beq a01050 newobj instance void [mscorlib]System.Exception::.ctor() throw a01050: ldsflda int16 [rvastatic4]A::a01051 ldind.i2 ldc.i4 51 beq a01051 newobj instance void [mscorlib]System.Exception::.ctor() throw a01051: ldsflda int32 [rvastatic4]A::a01052 ldind.i4 ldc.i4 52 beq a01052 newobj instance void [mscorlib]System.Exception::.ctor() throw a01052: ldsflda int16 [rvastatic4]A::a01053 ldind.i2 ldc.i4 53 beq a01053 newobj instance void [mscorlib]System.Exception::.ctor() throw a01053: ldsflda float32 [rvastatic4]A::a01054 ldind.r4 ldc.r4 54.0 beq a01054 newobj instance void [mscorlib]System.Exception::.ctor() throw a01054: ldsflda int64 [rvastatic4]A::a01055 ldind.i8 ldc.i8 55 beq a01055 newobj instance void [mscorlib]System.Exception::.ctor() throw a01055: ldsflda float32 [rvastatic4]A::a01056 ldind.r4 ldc.r4 56.0 beq a01056 newobj instance void [mscorlib]System.Exception::.ctor() throw a01056: ldsflda int64 [rvastatic4]A::a01057 ldind.i8 ldc.i8 57 beq a01057 newobj instance void [mscorlib]System.Exception::.ctor() throw a01057: ldsflda int64 [rvastatic4]A::a01058 ldind.i8 ldc.i8 58 beq a01058 newobj instance void [mscorlib]System.Exception::.ctor() throw a01058: ldsflda int64 [rvastatic4]A::a01059 ldind.i8 ldc.i8 59 beq a01059 newobj instance void [mscorlib]System.Exception::.ctor() throw a01059: ldsflda int16 [rvastatic4]A::a01060 ldind.i2 ldc.i4 60 beq a01060 newobj instance void [mscorlib]System.Exception::.ctor() throw a01060: ldsflda int8 [rvastatic4]A::a01061 ldind.i1 ldc.i4 61 beq a01061 newobj instance void [mscorlib]System.Exception::.ctor() throw a01061: ldsflda int64 [rvastatic4]A::a01062 ldind.i8 ldc.i8 62 beq a01062 newobj instance void [mscorlib]System.Exception::.ctor() throw a01062: ldsflda int16 [rvastatic4]A::a01063 ldind.i2 ldc.i4 63 beq a01063 newobj instance void [mscorlib]System.Exception::.ctor() throw a01063: ldsflda int32 [rvastatic4]A::a01064 ldind.i4 ldc.i4 64 beq a01064 newobj instance void [mscorlib]System.Exception::.ctor() throw a01064: ldsflda int16 [rvastatic4]A::a01065 ldind.i2 ldc.i4 65 beq a01065 newobj instance void [mscorlib]System.Exception::.ctor() throw a01065: ldsflda int8 [rvastatic4]A::a01066 ldind.i1 ldc.i4 66 beq a01066 newobj instance void [mscorlib]System.Exception::.ctor() throw a01066: ldsflda int16 [rvastatic4]A::a01067 ldind.i2 ldc.i4 67 beq a01067 newobj instance void [mscorlib]System.Exception::.ctor() throw a01067: ldsflda int32 [rvastatic4]A::a01068 ldind.i4 ldc.i4 68 beq a01068 newobj instance void [mscorlib]System.Exception::.ctor() throw a01068: ldsflda float32 [rvastatic4]A::a01069 ldind.r4 ldc.r4 69.0 beq a01069 newobj instance void [mscorlib]System.Exception::.ctor() throw a01069: ldsflda float32 [rvastatic4]A::a01070 ldind.r4 ldc.r4 70.0 beq a01070 newobj instance void [mscorlib]System.Exception::.ctor() throw a01070: ldsflda int16 [rvastatic4]A::a01071 ldind.i2 ldc.i4 71 beq a01071 newobj instance void [mscorlib]System.Exception::.ctor() throw a01071: ldsflda float32 [rvastatic4]A::a01072 ldind.r4 ldc.r4 72.0 beq a01072 newobj instance void [mscorlib]System.Exception::.ctor() throw a01072: ldsflda int64 [rvastatic4]A::a01073 ldind.i8 ldc.i8 73 beq a01073 newobj instance void [mscorlib]System.Exception::.ctor() throw a01073: ldsflda int64 [rvastatic4]A::a01074 ldind.i8 ldc.i8 74 beq a01074 newobj instance void [mscorlib]System.Exception::.ctor() throw a01074: ldsflda int32 [rvastatic4]A::a01075 ldind.i4 ldc.i4 75 beq a01075 newobj instance void [mscorlib]System.Exception::.ctor() throw a01075: ldsflda int8 [rvastatic4]A::a01076 ldind.i1 ldc.i4 76 beq a01076 newobj instance void [mscorlib]System.Exception::.ctor() throw a01076: ldsflda int32 [rvastatic4]A::a01077 ldind.i4 ldc.i4 77 beq a01077 newobj instance void [mscorlib]System.Exception::.ctor() throw a01077: ldsflda int16 [rvastatic4]A::a01078 ldind.i2 ldc.i4 78 beq a01078 newobj instance void [mscorlib]System.Exception::.ctor() throw a01078: ldsflda float32 [rvastatic4]A::a01079 ldind.r4 ldc.r4 79.0 beq a01079 newobj instance void [mscorlib]System.Exception::.ctor() throw a01079: ldsflda float32 [rvastatic4]A::a01080 ldind.r4 ldc.r4 80.0 beq a01080 newobj instance void [mscorlib]System.Exception::.ctor() throw a01080: ldsflda float32 [rvastatic4]A::a01081 ldind.r4 ldc.r4 81.0 beq a01081 newobj instance void [mscorlib]System.Exception::.ctor() throw a01081: ldsflda int32 [rvastatic4]A::a01082 ldind.i4 ldc.i4 82 beq a01082 newobj instance void [mscorlib]System.Exception::.ctor() throw a01082: ldsflda int8 [rvastatic4]A::a01083 ldind.i1 ldc.i4 83 beq a01083 newobj instance void [mscorlib]System.Exception::.ctor() throw a01083: ldsflda int64 [rvastatic4]A::a01084 ldind.i8 ldc.i8 84 beq a01084 newobj instance void [mscorlib]System.Exception::.ctor() throw a01084: ldsflda int64 [rvastatic4]A::a01085 ldind.i8 ldc.i8 85 beq a01085 newobj instance void [mscorlib]System.Exception::.ctor() throw a01085: ldsflda int32 [rvastatic4]A::a01086 ldind.i4 ldc.i4 86 beq a01086 newobj instance void [mscorlib]System.Exception::.ctor() throw a01086: ldsflda int32 [rvastatic4]A::a01087 ldind.i4 ldc.i4 87 beq a01087 newobj instance void [mscorlib]System.Exception::.ctor() throw a01087: ldsflda int8 [rvastatic4]A::a01088 ldind.i1 ldc.i4 88 beq a01088 newobj instance void [mscorlib]System.Exception::.ctor() throw a01088: ldsflda int64 [rvastatic4]A::a01089 ldind.i8 ldc.i8 89 beq a01089 newobj instance void [mscorlib]System.Exception::.ctor() throw a01089: ldsflda int8 [rvastatic4]A::a01090 ldind.i1 ldc.i4 90 beq a01090 newobj instance void [mscorlib]System.Exception::.ctor() throw a01090: ldsflda int16 [rvastatic4]A::a01091 ldind.i2 ldc.i4 91 beq a01091 newobj instance void [mscorlib]System.Exception::.ctor() throw a01091: ldsflda float32 [rvastatic4]A::a01092 ldind.r4 ldc.r4 92.0 beq a01092 newobj instance void [mscorlib]System.Exception::.ctor() throw a01092: ldsflda int64 [rvastatic4]A::a01093 ldind.i8 ldc.i8 93 beq a01093 newobj instance void [mscorlib]System.Exception::.ctor() throw a01093: ldsflda int64 [rvastatic4]A::a01094 ldind.i8 ldc.i8 94 beq a01094 newobj instance void [mscorlib]System.Exception::.ctor() throw a01094: ldsflda int8 [rvastatic4]A::a01095 ldind.i1 ldc.i4 95 beq a01095 newobj instance void [mscorlib]System.Exception::.ctor() throw a01095: ldsflda float32 [rvastatic4]A::a01096 ldind.r4 ldc.r4 96.0 beq a01096 newobj instance void [mscorlib]System.Exception::.ctor() throw a01096: ldsflda int16 [rvastatic4]A::a01097 ldind.i2 ldc.i4 97 beq a01097 newobj instance void [mscorlib]System.Exception::.ctor() throw a01097: ldsflda float32 [rvastatic4]A::a01098 ldind.r4 ldc.r4 98.0 beq a01098 newobj instance void [mscorlib]System.Exception::.ctor() throw a01098: ldsflda int32 [rvastatic4]A::a01099 ldind.i4 ldc.i4 99 beq a01099 newobj instance void [mscorlib]System.Exception::.ctor() throw a01099: ldsflda int64 [rvastatic4]A::a010100 ldind.i8 ldc.i8 100 beq a010100 newobj instance void [mscorlib]System.Exception::.ctor() throw a010100: ldsflda int32 [rvastatic4]A::a010101 ldind.i4 ldc.i4 101 beq a010101 newobj instance void [mscorlib]System.Exception::.ctor() throw a010101: ldsflda float32 [rvastatic4]A::a010102 ldind.r4 ldc.r4 102.0 beq a010102 newobj instance void [mscorlib]System.Exception::.ctor() throw a010102: ldsflda int64 [rvastatic4]A::a010103 ldind.i8 ldc.i8 103 beq a010103 newobj instance void [mscorlib]System.Exception::.ctor() throw a010103: ldsflda int32 [rvastatic4]A::a010104 ldind.i4 ldc.i4 104 beq a010104 newobj instance void [mscorlib]System.Exception::.ctor() throw a010104: ldsflda int16 [rvastatic4]A::a010105 ldind.i2 ldc.i4 105 beq a010105 newobj instance void [mscorlib]System.Exception::.ctor() throw a010105: ldsflda int16 [rvastatic4]A::a010106 ldind.i2 ldc.i4 106 beq a010106 newobj instance void [mscorlib]System.Exception::.ctor() throw a010106: ldsflda float32 [rvastatic4]A::a010107 ldind.r4 ldc.r4 107.0 beq a010107 newobj instance void [mscorlib]System.Exception::.ctor() throw a010107: ldsflda int32 [rvastatic4]A::a010108 ldind.i4 ldc.i4 108 beq a010108 newobj instance void [mscorlib]System.Exception::.ctor() throw a010108: ldsflda int16 [rvastatic4]A::a010109 ldind.i2 ldc.i4 109 beq a010109 newobj instance void [mscorlib]System.Exception::.ctor() throw a010109: ldsflda int32 [rvastatic4]A::a010110 ldind.i4 ldc.i4 110 beq a010110 newobj instance void [mscorlib]System.Exception::.ctor() throw a010110: ldsflda int32 [rvastatic4]A::a010111 ldind.i4 ldc.i4 111 beq a010111 newobj instance void [mscorlib]System.Exception::.ctor() throw a010111: ldsflda int32 [rvastatic4]A::a010112 ldind.i4 ldc.i4 112 beq a010112 newobj instance void [mscorlib]System.Exception::.ctor() throw a010112: ldsflda int64 [rvastatic4]A::a010113 ldind.i8 ldc.i8 113 beq a010113 newobj instance void [mscorlib]System.Exception::.ctor() throw a010113: ldsflda int64 [rvastatic4]A::a010114 ldind.i8 ldc.i8 114 beq a010114 newobj instance void [mscorlib]System.Exception::.ctor() throw a010114: ldsflda int16 [rvastatic4]A::a010115 ldind.i2 ldc.i4 115 beq a010115 newobj instance void [mscorlib]System.Exception::.ctor() throw a010115: ldsflda int64 [rvastatic4]A::a010116 ldind.i8 ldc.i8 116 beq a010116 newobj instance void [mscorlib]System.Exception::.ctor() throw a010116: ldsflda int64 [rvastatic4]A::a010117 ldind.i8 ldc.i8 117 beq a010117 newobj instance void [mscorlib]System.Exception::.ctor() throw a010117: ldsflda int32 [rvastatic4]A::a010118 ldind.i4 ldc.i4 118 beq a010118 newobj instance void [mscorlib]System.Exception::.ctor() throw a010118: ldsflda int64 [rvastatic4]A::a010119 ldind.i8 ldc.i8 119 beq a010119 newobj instance void [mscorlib]System.Exception::.ctor() throw a010119: ldsflda int64 [rvastatic4]A::a010120 ldind.i8 ldc.i8 120 beq a010120 newobj instance void [mscorlib]System.Exception::.ctor() throw a010120: ldsflda int64 [rvastatic4]A::a010121 ldind.i8 ldc.i8 121 beq a010121 newobj instance void [mscorlib]System.Exception::.ctor() throw a010121: ldsflda int16 [rvastatic4]A::a010122 ldind.i2 ldc.i4 122 beq a010122 newobj instance void [mscorlib]System.Exception::.ctor() throw a010122: ldsflda int64 [rvastatic4]A::a010123 ldind.i8 ldc.i8 123 beq a010123 newobj instance void [mscorlib]System.Exception::.ctor() throw a010123: ldsflda int64 [rvastatic4]A::a010124 ldind.i8 ldc.i8 124 beq a010124 newobj instance void [mscorlib]System.Exception::.ctor() throw a010124: ldsflda int32 [rvastatic4]A::a010125 ldind.i4 ldc.i4 125 beq a010125 newobj instance void [mscorlib]System.Exception::.ctor() throw a010125: ldsflda int16 [rvastatic4]A::a010126 ldind.i2 ldc.i4 126 beq a010126 newobj instance void [mscorlib]System.Exception::.ctor() throw a010126: ldsflda int16 [rvastatic4]A::a010127 ldind.i2 ldc.i4 127 beq a010127 newobj instance void [mscorlib]System.Exception::.ctor() throw a010127: ret} .method static void V3() {.maxstack 50 ldsfld float32 [rvastatic4]A::a01079 ldc.r4 79.0 beq a010129 newobj instance void [mscorlib]System.Exception::.ctor() throw a010129: ldsfld int32 [rvastatic4]A::a010111 ldc.i4 111 beq a010130 newobj instance void [mscorlib]System.Exception::.ctor() throw a010130: ldsfld int16 [rvastatic4]A::a01034 ldc.i4 34 beq a010131 newobj instance void [mscorlib]System.Exception::.ctor() throw a010131: ldsfld int8 [rvastatic4]A::a01040 ldc.i4 40 beq a010132 newobj instance void [mscorlib]System.Exception::.ctor() throw a010132: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a010133 newobj instance void [mscorlib]System.Exception::.ctor() throw a010133: ldsfld int64 [rvastatic4]A::a01089 ldc.i8 89 beq a010134 newobj instance void [mscorlib]System.Exception::.ctor() throw a010134: ldsfld float32 [rvastatic4]A::a01070 ldc.r4 70.0 beq a010135 newobj instance void [mscorlib]System.Exception::.ctor() throw a010135: ldsfld int8 [rvastatic4]A::a01066 ldc.i4 66 beq a010136 newobj instance void [mscorlib]System.Exception::.ctor() throw a010136: ldsfld int64 [rvastatic4]A::a01048 ldc.i8 48 beq a010137 newobj instance void [mscorlib]System.Exception::.ctor() throw a010137: ldsfld float32 [rvastatic4]A::a01080 ldc.r4 80.0 beq a010138 newobj instance void [mscorlib]System.Exception::.ctor() throw a010138: ldsfld int32 [rvastatic4]A::a010104 ldc.i4 104 beq a010139 newobj instance void [mscorlib]System.Exception::.ctor() throw a010139: ldsfld int16 [rvastatic4]A::a01091 ldc.i4 91 beq a010140 newobj instance void [mscorlib]System.Exception::.ctor() throw a010140: ldsfld int32 [rvastatic4]A::a01024 ldc.i4 24 beq a010141 newobj instance void [mscorlib]System.Exception::.ctor() throw a010141: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 81.0 beq a010142 newobj instance void [mscorlib]System.Exception::.ctor() throw a010142: ldsfld int64 [rvastatic4]A::a010121 ldc.i8 121 beq a010143 newobj instance void [mscorlib]System.Exception::.ctor() throw a010143: ldsfld int8 [rvastatic4]A::a01017 ldc.i4 17 beq a010144 newobj instance void [mscorlib]System.Exception::.ctor() throw a010144: ldsfld float32 [rvastatic4]A::a010107 ldc.r4 107.0 beq a010145 newobj instance void [mscorlib]System.Exception::.ctor() throw a010145: ldsfld int16 [rvastatic4]A::a01047 ldc.i4 47 beq a010146 newobj instance void [mscorlib]System.Exception::.ctor() throw a010146: ldsfld int64 [rvastatic4]A::a01048 ldc.i8 48 beq a010147 newobj instance void [mscorlib]System.Exception::.ctor() throw a010147: ldsfld int8 [rvastatic4]A::a01020 ldc.i4 20 beq a010148 newobj instance void [mscorlib]System.Exception::.ctor() throw a010148: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 115 beq a010149 newobj instance void [mscorlib]System.Exception::.ctor() throw a010149: ldsfld int32 [rvastatic4]A::a01024 ldc.i4 24 beq a010150 newobj instance void [mscorlib]System.Exception::.ctor() throw a010150: ldsfld float32 [rvastatic4]A::a010102 ldc.r4 102.0 beq a010151 newobj instance void [mscorlib]System.Exception::.ctor() throw a010151: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 124 beq a010152 newobj instance void [mscorlib]System.Exception::.ctor() throw a010152: ldsfld int16 [rvastatic4]A::a01028 ldc.i4 28 beq a010153 newobj instance void [mscorlib]System.Exception::.ctor() throw a010153: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a010154 newobj instance void [mscorlib]System.Exception::.ctor() throw a010154: ldsfld int64 [rvastatic4]A::a0105 ldc.i8 5 beq a010155 newobj instance void [mscorlib]System.Exception::.ctor() throw a010155: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 115 beq a010156 newobj instance void [mscorlib]System.Exception::.ctor() throw a010156: ldsfld int64 [rvastatic4]A::a010113 ldc.i8 113 beq a010157 newobj instance void [mscorlib]System.Exception::.ctor() throw a010157: ldsfld int64 [rvastatic4]A::a0101 ldc.i8 1 beq a010158 newobj instance void [mscorlib]System.Exception::.ctor() throw a010158: ldsfld int16 [rvastatic4]A::a010122 ldc.i4 122 beq a010159 newobj instance void [mscorlib]System.Exception::.ctor() throw a010159: ldsfld int32 [rvastatic4]A::a010108 ldc.i4 108 beq a010160 newobj instance void [mscorlib]System.Exception::.ctor() throw a010160: ldsfld int8 [rvastatic4]A::a01090 ldc.i4 90 beq a010161 newobj instance void [mscorlib]System.Exception::.ctor() throw a010161: ldsfld int8 [rvastatic4]A::a01090 ldc.i4 90 beq a010162 newobj instance void [mscorlib]System.Exception::.ctor() throw a010162: ldsfld int32 [rvastatic4]A::a010112 ldc.i4 112 beq a010163 newobj instance void [mscorlib]System.Exception::.ctor() throw a010163: ldsfld int16 [rvastatic4]A::a01067 ldc.i4 67 beq a010164 newobj instance void [mscorlib]System.Exception::.ctor() throw a010164: ldsfld int32 [rvastatic4]A::a01064 ldc.i4 64 beq a010165 newobj instance void [mscorlib]System.Exception::.ctor() throw a010165: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 57 beq a010166 newobj instance void [mscorlib]System.Exception::.ctor() throw a010166: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a010167 newobj instance void [mscorlib]System.Exception::.ctor() throw a010167: ldsfld int64 [rvastatic4]A::a010120 ldc.i8 120 beq a010168 newobj instance void [mscorlib]System.Exception::.ctor() throw a010168: ldsfld float32 [rvastatic4]A::a01019 ldc.r4 19.0 beq a010169 newobj instance void [mscorlib]System.Exception::.ctor() throw a010169: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 124 beq a010170 newobj instance void [mscorlib]System.Exception::.ctor() throw a010170: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a010171 newobj instance void [mscorlib]System.Exception::.ctor() throw a010171: ldsfld int8 [rvastatic4]A::a0107 ldc.i4 7 beq a010172 newobj instance void [mscorlib]System.Exception::.ctor() throw a010172: ldsfld int16 [rvastatic4]A::a010106 ldc.i4 106 beq a010173 newobj instance void [mscorlib]System.Exception::.ctor() throw a010173: ldsfld int64 [rvastatic4]A::a01073 ldc.i8 73 beq a010174 newobj instance void [mscorlib]System.Exception::.ctor() throw a010174: ldsfld int64 [rvastatic4]A::a01074 ldc.i8 74 beq a010175 newobj instance void [mscorlib]System.Exception::.ctor() throw a010175: ldsfld int8 [rvastatic4]A::a01015 ldc.i4 15 beq a010176 newobj instance void [mscorlib]System.Exception::.ctor() throw a010176: ldsfld int32 [rvastatic4]A::a01077 ldc.i4 77 beq a010177 newobj instance void [mscorlib]System.Exception::.ctor() throw a010177: ldsfld int8 [rvastatic4]A::a01031 ldc.i4 31 beq a010178 newobj instance void [mscorlib]System.Exception::.ctor() throw a010178: ldsfld int16 [rvastatic4]A::a01067 ldc.i4 67 beq a010179 newobj instance void [mscorlib]System.Exception::.ctor() throw a010179: ldsfld int16 [rvastatic4]A::a01071 ldc.i4 71 beq a010180 newobj instance void [mscorlib]System.Exception::.ctor() throw a010180: ldsfld int16 [rvastatic4]A::a01047 ldc.i4 47 beq a010181 newobj instance void [mscorlib]System.Exception::.ctor() throw a010181: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 61 beq a010182 newobj instance void [mscorlib]System.Exception::.ctor() throw a010182: ldsfld int64 [rvastatic4]A::a010114 ldc.i8 114 beq a010183 newobj instance void [mscorlib]System.Exception::.ctor() throw a010183: ldsfld float32 [rvastatic4]A::a01054 ldc.r4 54.0 beq a010184 newobj instance void [mscorlib]System.Exception::.ctor() throw a010184: ldsfld int32 [rvastatic4]A::a0109 ldc.i4 9 beq a010185 newobj instance void [mscorlib]System.Exception::.ctor() throw a010185: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a010186 newobj instance void [mscorlib]System.Exception::.ctor() throw a010186: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a010187 newobj instance void [mscorlib]System.Exception::.ctor() throw a010187: ldsfld int32 [rvastatic4]A::a0100 ldc.i4 0 beq a010188 newobj instance void [mscorlib]System.Exception::.ctor() throw a010188: ldsfld int8 [rvastatic4]A::a01083 ldc.i4 83 beq a010189 newobj instance void [mscorlib]System.Exception::.ctor() throw a010189: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 82 beq a010190 newobj instance void [mscorlib]System.Exception::.ctor() throw a010190: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 81.0 beq a010191 newobj instance void [mscorlib]System.Exception::.ctor() throw a010191: ldsfld float32 [rvastatic4]A::a01046 ldc.r4 46.0 beq a010192 newobj instance void [mscorlib]System.Exception::.ctor() throw a010192: ldsfld int64 [rvastatic4]A::a01085 ldc.i8 85 beq a010193 newobj instance void [mscorlib]System.Exception::.ctor() throw a010193: ldsfld int64 [rvastatic4]A::a010123 ldc.i8 123 beq a010194 newobj instance void [mscorlib]System.Exception::.ctor() throw a010194: ldsfld int32 [rvastatic4]A::a0100 ldc.i4 0 beq a010195 newobj instance void [mscorlib]System.Exception::.ctor() throw a010195: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a010196 newobj instance void [mscorlib]System.Exception::.ctor() throw a010196: ldsfld float32 [rvastatic4]A::a01096 ldc.r4 96.0 beq a010197 newobj instance void [mscorlib]System.Exception::.ctor() throw a010197: ldsfld int16 [rvastatic4]A::a01053 ldc.i4 53 beq a010198 newobj instance void [mscorlib]System.Exception::.ctor() throw a010198: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 81.0 beq a010199 newobj instance void [mscorlib]System.Exception::.ctor() throw a010199: ldsfld int16 [rvastatic4]A::a01049 ldc.i4 49 beq a010200 newobj instance void [mscorlib]System.Exception::.ctor() throw a010200: ldsfld int32 [rvastatic4]A::a0109 ldc.i4 9 beq a010201 newobj instance void [mscorlib]System.Exception::.ctor() throw a010201: ldsfld float32 [rvastatic4]A::a01056 ldc.r4 56.0 beq a010202 newobj instance void [mscorlib]System.Exception::.ctor() throw a010202: ldsfld int64 [rvastatic4]A::a0101 ldc.i8 1 beq a010203 newobj instance void [mscorlib]System.Exception::.ctor() throw a010203: ldsfld int64 [rvastatic4]A::a010119 ldc.i8 119 beq a010204 newobj instance void [mscorlib]System.Exception::.ctor() throw a010204: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 115 beq a010205 newobj instance void [mscorlib]System.Exception::.ctor() throw a010205: ldsfld int64 [rvastatic4]A::a01094 ldc.i8 94 beq a010206 newobj instance void [mscorlib]System.Exception::.ctor() throw a010206: ldsfld int8 [rvastatic4]A::a01017 ldc.i4 17 beq a010207 newobj instance void [mscorlib]System.Exception::.ctor() throw a010207: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 82 beq a010208 newobj instance void [mscorlib]System.Exception::.ctor() throw a010208: ldsfld int16 [rvastatic4]A::a01065 ldc.i4 65 beq a010209 newobj instance void [mscorlib]System.Exception::.ctor() throw a010209: ldsfld int64 [rvastatic4]A::a010117 ldc.i8 117 beq a010210 newobj instance void [mscorlib]System.Exception::.ctor() throw a010210: ldsfld int16 [rvastatic4]A::a01038 ldc.i4 38 beq a010211 newobj instance void [mscorlib]System.Exception::.ctor() throw a010211: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 82 beq a010212 newobj instance void [mscorlib]System.Exception::.ctor() throw a010212: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a010213 newobj instance void [mscorlib]System.Exception::.ctor() throw a010213: ldsfld int32 [rvastatic4]A::a01050 ldc.i4 50 beq a010214 newobj instance void [mscorlib]System.Exception::.ctor() throw a010214: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 61 beq a010215 newobj instance void [mscorlib]System.Exception::.ctor() throw a010215: ldsfld int16 [rvastatic4]A::a01029 ldc.i4 29 beq a010216 newobj instance void [mscorlib]System.Exception::.ctor() throw a010216: ldsfld int32 [rvastatic4]A::a010104 ldc.i4 104 beq a010217 newobj instance void [mscorlib]System.Exception::.ctor() throw a010217: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 57 beq a010218 newobj instance void [mscorlib]System.Exception::.ctor() throw a010218: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 57 beq a010219 newobj instance void [mscorlib]System.Exception::.ctor() throw a010219: ldsfld int16 [rvastatic4]A::a01026 ldc.i4 26 beq a010220 newobj instance void [mscorlib]System.Exception::.ctor() throw a010220: ldsfld int64 [rvastatic4]A::a01045 ldc.i8 45 beq a010221 newobj instance void [mscorlib]System.Exception::.ctor() throw a010221: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a010222 newobj instance void [mscorlib]System.Exception::.ctor() throw a010222: ldsfld int8 [rvastatic4]A::a01036 ldc.i4 36 beq a010223 newobj instance void [mscorlib]System.Exception::.ctor() throw a010223: ldsfld int32 [rvastatic4]A::a01064 ldc.i4 64 beq a010224 newobj instance void [mscorlib]System.Exception::.ctor() throw a010224: ldsfld int16 [rvastatic4]A::a01043 ldc.i4 43 beq a010225 newobj instance void [mscorlib]System.Exception::.ctor() throw a010225: ldsfld int32 [rvastatic4]A::a010118 ldc.i4 118 beq a010226 newobj instance void [mscorlib]System.Exception::.ctor() throw a010226: ldsfld int32 [rvastatic4]A::a01050 ldc.i4 50 beq a010227 newobj instance void [mscorlib]System.Exception::.ctor() throw a010227: ldsfld int32 [rvastatic4]A::a010111 ldc.i4 111 beq a010228 newobj instance void [mscorlib]System.Exception::.ctor() throw a010228: ldsfld float32 [rvastatic4]A::a01072 ldc.r4 72.0 beq a010229 newobj instance void [mscorlib]System.Exception::.ctor() throw a010229: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a010230 newobj instance void [mscorlib]System.Exception::.ctor() throw a010230: ldsfld float32 [rvastatic4]A::a01046 ldc.r4 46.0 beq a010231 newobj instance void [mscorlib]System.Exception::.ctor() throw a010231: ldsfld int8 [rvastatic4]A::a01023 ldc.i4 23 beq a010232 newobj instance void [mscorlib]System.Exception::.ctor() throw a010232: ldsfld int32 [rvastatic4]A::a01077 ldc.i4 77 beq a010233 newobj instance void [mscorlib]System.Exception::.ctor() throw a010233: ldsfld float32 [rvastatic4]A::a01018 ldc.r4 18.0 beq a010234 newobj instance void [mscorlib]System.Exception::.ctor() throw a010234: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 61 beq a010235 newobj instance void [mscorlib]System.Exception::.ctor() throw a010235: ldsfld int32 [rvastatic4]A::a010118 ldc.i4 118 beq a010236 newobj instance void [mscorlib]System.Exception::.ctor() throw a010236: ldsfld int64 [rvastatic4]A::a01059 ldc.i8 59 beq a010237 newobj instance void [mscorlib]System.Exception::.ctor() throw a010237: ldsfld int16 [rvastatic4]A::a010122 ldc.i4 122 beq a010238 newobj instance void [mscorlib]System.Exception::.ctor() throw a010238: ldsfld int8 [rvastatic4]A::a01066 ldc.i4 66 beq a010239 newobj instance void [mscorlib]System.Exception::.ctor() throw a010239: ldsfld int16 [rvastatic4]A::a01043 ldc.i4 43 beq a010240 newobj instance void [mscorlib]System.Exception::.ctor() throw a010240: ldsfld int8 [rvastatic4]A::a01020 ldc.i4 20 beq a010241 newobj instance void [mscorlib]System.Exception::.ctor() throw a010241: ldsfld int64 [rvastatic4]A::a01058 ldc.i8 58 beq a010242 newobj instance void [mscorlib]System.Exception::.ctor() throw a010242: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a010243 newobj instance void [mscorlib]System.Exception::.ctor() throw a010243: ldsfld int64 [rvastatic4]A::a01094 ldc.i8 94 beq a010244 newobj instance void [mscorlib]System.Exception::.ctor() throw a010244: ldsfld int64 [rvastatic4]A::a01044 ldc.i8 44 beq a010245 newobj instance void [mscorlib]System.Exception::.ctor() throw a010245: ldsfld int16 [rvastatic4]A::a010126 ldc.i4 126 beq a010246 newobj instance void [mscorlib]System.Exception::.ctor() throw a010246: ldsfld int32 [rvastatic4]A::a010112 ldc.i4 112 beq a010247 newobj instance void [mscorlib]System.Exception::.ctor() throw a010247: ldsfld int16 [rvastatic4]A::a01034 ldc.i4 34 beq a010248 newobj instance void [mscorlib]System.Exception::.ctor() throw a010248: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a010249 newobj instance void [mscorlib]System.Exception::.ctor() throw a010249: ldsfld int32 [rvastatic4]A::a01099 ldc.i4 99 beq a010250 newobj instance void [mscorlib]System.Exception::.ctor() throw a010250: ldsfld int64 [rvastatic4]A::a01085 ldc.i8 85 beq a010251 newobj instance void [mscorlib]System.Exception::.ctor() throw a010251: ldsfld int8 [rvastatic4]A::a01039 ldc.i4 39 beq a010252 newobj instance void [mscorlib]System.Exception::.ctor() throw a010252: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 124 beq a010253 newobj instance void [mscorlib]System.Exception::.ctor() throw a010253: ldsfld int64 [rvastatic4]A::a01055 ldc.i8 55 beq a010254 newobj instance void [mscorlib]System.Exception::.ctor() throw a010254: ldsfld int16 [rvastatic4]A::a0104 ldc.i4 4 beq a010255 newobj instance void [mscorlib]System.Exception::.ctor() throw a010255: ldsfld int64 [rvastatic4]A::a010100 ldc.i8 100 beq a010256 newobj instance void [mscorlib]System.Exception::.ctor() throw a010256: ret} .method static void V4() {.maxstack 50 ldsflda int32 [rvastatic4]A::a0100 conv.i8 ldc.i8 19349 add conv.i8 ldc.i8 19349 sub conv.i ldind.i4 ldc.i4 0 beq a0100 ldstr "a0100" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0100: ldsflda int64 [rvastatic4]A::a0101 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i8 ldc.i8 1 beq a0101 ldstr "a0101" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0101: ldsflda float32 [rvastatic4]A::a0102 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.r4 ldc.r4 2.0 beq a0102 ldstr "a0102" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0102: ldsflda int16 [rvastatic4]A::a0103 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 3 beq a0103 ldstr "a0103" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0103: ldsflda int16 [rvastatic4]A::a0104 conv.i8 ldc.i8 46081 add conv.i8 ldc.i8 46081 sub conv.i ldind.i2 ldc.i4 4 beq a0104 ldstr "a0104" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0104: ldsflda int64 [rvastatic4]A::a0105 conv.i8 dup dup xor xor conv.i ldind.i8 ldc.i8 5 beq a0105 ldstr "a0105" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0105: ldsflda int16 [rvastatic4]A::a0106 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i2 ldc.i4 6 beq a0106 ldstr "a0106" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0106: ldsflda int8 [rvastatic4]A::a0107 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 7 beq a0107 ldstr "a0107" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0107: ldsflda int64 [rvastatic4]A::a0108 conv.i8 ldc.i8 3218 add conv.i8 ldc.i8 3218 sub conv.i ldind.i8 ldc.i8 8 beq a0108 ldstr "a0108" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0108: ldsflda int32 [rvastatic4]A::a0109 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 9 beq a0109 ldstr "a0109" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0109: ldsflda int16 [rvastatic4]A::a01010 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 10 beq a01010 ldstr "a01010" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01010: ldsflda float32 [rvastatic4]A::a01011 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.r4 ldc.r4 11.0 beq a01011 ldstr "a01011" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01011: ldsflda int16 [rvastatic4]A::a01012 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 12 beq a01012 ldstr "a01012" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01012: ldsflda float32 [rvastatic4]A::a01013 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.r4 ldc.r4 13.0 beq a01013 ldstr "a01013" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01013: ldsflda float32 [rvastatic4]A::a01014 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.r4 ldc.r4 14.0 beq a01014 ldstr "a01014" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01014: ldsflda int8 [rvastatic4]A::a01015 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 15 beq a01015 ldstr "a01015" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01015: ldsflda float32 [rvastatic4]A::a01016 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.r4 ldc.r4 16.0 beq a01016 ldstr "a01016" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01016: ldsflda int8 [rvastatic4]A::a01017 conv.i8 ldc.i8 15229 add conv.i8 ldc.i8 15229 sub conv.i ldind.i1 ldc.i4 17 beq a01017 ldstr "a01017" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01017: ldsflda float32 [rvastatic4]A::a01018 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.r4 ldc.r4 18.0 beq a01018 ldstr "a01018" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01018: ldsflda float32 [rvastatic4]A::a01019 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 19.0 beq a01019 ldstr "a01019" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01019: ldsflda int8 [rvastatic4]A::a01020 conv.i8 ldc.i8 28655 add conv.i8 ldc.i8 28655 sub conv.i ldind.i1 ldc.i4 20 beq a01020 ldstr "a01020" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01020: ldsflda float32 [rvastatic4]A::a01021 conv.i8 ldc.i8 33205 add conv.i8 ldc.i8 33205 sub conv.i ldind.r4 ldc.r4 21.0 beq a01021 ldstr "a01021" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01021: ldsflda int64 [rvastatic4]A::a01022 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i8 ldc.i8 22 beq a01022 ldstr "a01022" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01022: ldsflda int8 [rvastatic4]A::a01023 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 23 beq a01023 ldstr "a01023" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01023: ldsflda int32 [rvastatic4]A::a01024 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i4 ldc.i4 24 beq a01024 ldstr "a01024" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01024: ldsflda int64 [rvastatic4]A::a01025 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i8 ldc.i8 25 beq a01025 ldstr "a01025" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01025: ldsflda int16 [rvastatic4]A::a01026 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 26 beq a01026 ldstr "a01026" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01026: ldsflda int8 [rvastatic4]A::a01027 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i1 ldc.i4 27 beq a01027 ldstr "a01027" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01027: ldsflda int16 [rvastatic4]A::a01028 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 28 beq a01028 ldstr "a01028" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01028: ldsflda int16 [rvastatic4]A::a01029 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 29 beq a01029 ldstr "a01029" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01029: ldsflda int8 [rvastatic4]A::a01030 conv.i8 dup dup xor xor conv.i ldind.i1 ldc.i4 30 beq a01030 ldstr "a01030" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01030: ldsflda int8 [rvastatic4]A::a01031 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i1 ldc.i4 31 beq a01031 ldstr "a01031" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01031: ldsflda int64 [rvastatic4]A::a01032 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 32 beq a01032 ldstr "a01032" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01032: ldsflda float32 [rvastatic4]A::a01033 conv.i8 dup dup xor xor conv.i ldind.r4 ldc.r4 33.0 beq a01033 ldstr "a01033" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01033: ldsflda int16 [rvastatic4]A::a01034 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 34 beq a01034 ldstr "a01034" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01034: ldsflda int8 [rvastatic4]A::a01035 conv.i8 dup dup xor xor conv.i ldind.i1 ldc.i4 35 beq a01035 ldstr "a01035" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01035: ldsflda int8 [rvastatic4]A::a01036 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i1 ldc.i4 36 beq a01036 ldstr "a01036" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01036: ldsflda int32 [rvastatic4]A::a01037 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i4 ldc.i4 37 beq a01037 ldstr "a01037" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01037: ldsflda int16 [rvastatic4]A::a01038 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 38 beq a01038 ldstr "a01038" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01038: ldsflda int8 [rvastatic4]A::a01039 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i1 ldc.i4 39 beq a01039 ldstr "a01039" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01039: ldsflda int8 [rvastatic4]A::a01040 conv.i8 ldc.i8 65464 add conv.i8 ldc.i8 65464 sub conv.i ldind.i1 ldc.i4 40 beq a01040 ldstr "a01040" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01040: ldsflda int32 [rvastatic4]A::a01041 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i4 ldc.i4 41 beq a01041 ldstr "a01041" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01041: ldsflda int64 [rvastatic4]A::a01042 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 42 beq a01042 ldstr "a01042" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01042: ldsflda int16 [rvastatic4]A::a01043 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 43 beq a01043 ldstr "a01043" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01043: ldsflda int64 [rvastatic4]A::a01044 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 44 beq a01044 ldstr "a01044" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01044: ldsflda int64 [rvastatic4]A::a01045 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 45 beq a01045 ldstr "a01045" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01045: ldsflda float32 [rvastatic4]A::a01046 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.r4 ldc.r4 46.0 beq a01046 ldstr "a01046" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01046: ldsflda int16 [rvastatic4]A::a01047 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 47 beq a01047 ldstr "a01047" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01047: ldsflda int64 [rvastatic4]A::a01048 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 48 beq a01048 ldstr "a01048" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01048: ldsflda int16 [rvastatic4]A::a01049 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 49 beq a01049 ldstr "a01049" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01049: ldsflda int32 [rvastatic4]A::a01050 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i4 ldc.i4 50 beq a01050 ldstr "a01050" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01050: ldsflda int16 [rvastatic4]A::a01051 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 51 beq a01051 ldstr "a01051" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01051: ldsflda int32 [rvastatic4]A::a01052 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i4 ldc.i4 52 beq a01052 ldstr "a01052" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01052: ldsflda int16 [rvastatic4]A::a01053 conv.i8 ldc.i8 26716 add conv.i8 ldc.i8 26716 sub conv.i ldind.i2 ldc.i4 53 beq a01053 ldstr "a01053" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01053: ldsflda float32 [rvastatic4]A::a01054 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.r4 ldc.r4 54.0 beq a01054 ldstr "a01054" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01054: ldsflda int64 [rvastatic4]A::a01055 conv.i8 dup dup xor xor conv.i ldind.i8 ldc.i8 55 beq a01055 ldstr "a01055" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01055: ldsflda float32 [rvastatic4]A::a01056 conv.i8 dup dup xor xor conv.i ldind.r4 ldc.r4 56.0 beq a01056 ldstr "a01056" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01056: ldsflda int64 [rvastatic4]A::a01057 conv.i8 ldc.i8 62605 add conv.i8 ldc.i8 62605 sub conv.i ldind.i8 ldc.i8 57 beq a01057 ldstr "a01057" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01057: ldsflda int64 [rvastatic4]A::a01058 conv.i8 dup dup xor xor conv.i ldind.i8 ldc.i8 58 beq a01058 ldstr "a01058" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01058: ldsflda int64 [rvastatic4]A::a01059 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 59 beq a01059 ldstr "a01059" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01059: ldsflda int16 [rvastatic4]A::a01060 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i2 ldc.i4 60 beq a01060 ldstr "a01060" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01060: ldsflda int8 [rvastatic4]A::a01061 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i1 ldc.i4 61 beq a01061 ldstr "a01061" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01061: ldsflda int64 [rvastatic4]A::a01062 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 62 beq a01062 ldstr "a01062" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01062: ldsflda int16 [rvastatic4]A::a01063 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 63 beq a01063 ldstr "a01063" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01063: ldsflda int32 [rvastatic4]A::a01064 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i4 ldc.i4 64 beq a01064 ldstr "a01064" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01064: ldsflda int16 [rvastatic4]A::a01065 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 65 beq a01065 ldstr "a01065" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01065: ldsflda int8 [rvastatic4]A::a01066 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 66 beq a01066 ldstr "a01066" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01066: ldsflda int16 [rvastatic4]A::a01067 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 67 beq a01067 ldstr "a01067" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01067: ldsflda int32 [rvastatic4]A::a01068 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 68 beq a01068 ldstr "a01068" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01068: ldsflda float32 [rvastatic4]A::a01069 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.r4 ldc.r4 69.0 beq a01069 ldstr "a01069" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01069: ldsflda float32 [rvastatic4]A::a01070 conv.i8 ldc.i8 48606 add conv.i8 ldc.i8 48606 sub conv.i ldind.r4 ldc.r4 70.0 beq a01070 ldstr "a01070" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01070: ldsflda int16 [rvastatic4]A::a01071 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i2 ldc.i4 71 beq a01071 ldstr "a01071" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01071: ldsflda float32 [rvastatic4]A::a01072 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 72.0 beq a01072 ldstr "a01072" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01072: ldsflda int64 [rvastatic4]A::a01073 conv.i8 ldc.i8 5680 add conv.i8 ldc.i8 5680 sub conv.i ldind.i8 ldc.i8 73 beq a01073 ldstr "a01073" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01073: ldsflda int64 [rvastatic4]A::a01074 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 74 beq a01074 ldstr "a01074" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01074: ldsflda int32 [rvastatic4]A::a01075 conv.i8 ldc.i8 32361 add conv.i8 ldc.i8 32361 sub conv.i ldind.i4 ldc.i4 75 beq a01075 ldstr "a01075" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01075: ldsflda int8 [rvastatic4]A::a01076 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i1 ldc.i4 76 beq a01076 ldstr "a01076" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01076: ldsflda int32 [rvastatic4]A::a01077 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 77 beq a01077 ldstr "a01077" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01077: ldsflda int16 [rvastatic4]A::a01078 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 78 beq a01078 ldstr "a01078" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01078: ldsflda float32 [rvastatic4]A::a01079 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.r4 ldc.r4 79.0 beq a01079 ldstr "a01079" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01079: ldsflda float32 [rvastatic4]A::a01080 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.r4 ldc.r4 80.0 beq a01080 ldstr "a01080" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01080: ldsflda float32 [rvastatic4]A::a01081 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 81.0 beq a01081 ldstr "a01081" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01081: ldsflda int32 [rvastatic4]A::a01082 conv.i8 ldc.i8 30180 add conv.i8 ldc.i8 30180 sub conv.i ldind.i4 ldc.i4 82 beq a01082 ldstr "a01082" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01082: ldsflda int8 [rvastatic4]A::a01083 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 83 beq a01083 ldstr "a01083" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01083: ldsflda int64 [rvastatic4]A::a01084 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i8 ldc.i8 84 beq a01084 ldstr "a01084" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01084: ldsflda int64 [rvastatic4]A::a01085 conv.i8 ldc.i8 18787 add conv.i8 ldc.i8 18787 sub conv.i ldind.i8 ldc.i8 85 beq a01085 ldstr "a01085" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01085: ldsflda int32 [rvastatic4]A::a01086 conv.i8 dup dup xor xor conv.i ldind.i4 ldc.i4 86 beq a01086 ldstr "a01086" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01086: ldsflda int32 [rvastatic4]A::a01087 conv.i8 ldc.i8 16913 add conv.i8 ldc.i8 16913 sub conv.i ldind.i4 ldc.i4 87 beq a01087 ldstr "a01087" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01087: ldsflda int8 [rvastatic4]A::a01088 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i1 ldc.i4 88 beq a01088 ldstr "a01088" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01088: ldsflda int64 [rvastatic4]A::a01089 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 89 beq a01089 ldstr "a01089" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01089: ldsflda int8 [rvastatic4]A::a01090 conv.i8 ldc.i8 42807 add conv.i8 ldc.i8 42807 sub conv.i ldind.i1 ldc.i4 90 beq a01090 ldstr "a01090" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01090: ldsflda int16 [rvastatic4]A::a01091 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 91 beq a01091 ldstr "a01091" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01091: ldsflda float32 [rvastatic4]A::a01092 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 92.0 beq a01092 ldstr "a01092" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01092: ldsflda int64 [rvastatic4]A::a01093 conv.i8 ldc.i8 37525 add conv.i8 ldc.i8 37525 sub conv.i ldind.i8 ldc.i8 93 beq a01093 ldstr "a01093" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01093: ldsflda int64 [rvastatic4]A::a01094 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 94 beq a01094 ldstr "a01094" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01094: ldsflda int8 [rvastatic4]A::a01095 conv.i8 dup dup xor xor conv.i ldind.i1 ldc.i4 95 beq a01095 ldstr "a01095" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01095: ldsflda float32 [rvastatic4]A::a01096 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 96.0 beq a01096 ldstr "a01096" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01096: ldsflda int16 [rvastatic4]A::a01097 conv.i8 ldc.i8 41331 add conv.i8 ldc.i8 41331 sub conv.i ldind.i2 ldc.i4 97 beq a01097 ldstr "a01097" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01097: ldsflda float32 [rvastatic4]A::a01098 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 98.0 beq a01098 ldstr "a01098" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01098: ldsflda int32 [rvastatic4]A::a01099 conv.i8 ldc.i8 4072 add conv.i8 ldc.i8 4072 sub conv.i ldind.i4 ldc.i4 99 beq a01099 ldstr "a01099" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01099: ldsflda int64 [rvastatic4]A::a010100 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 100 beq a010100 ldstr "a010100" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010100: ldsflda int32 [rvastatic4]A::a010101 conv.i8 dup dup xor xor conv.i ldind.i4 ldc.i4 101 beq a010101 ldstr "a010101" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010101: ldsflda float32 [rvastatic4]A::a010102 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 102.0 beq a010102 ldstr "a010102" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010102: ldsflda int64 [rvastatic4]A::a010103 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 103 beq a010103 ldstr "a010103" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010103: ldsflda int32 [rvastatic4]A::a010104 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i4 ldc.i4 104 beq a010104 ldstr "a010104" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010104: ldsflda int16 [rvastatic4]A::a010105 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 105 beq a010105 ldstr "a010105" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010105: ldsflda int16 [rvastatic4]A::a010106 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 106 beq a010106 ldstr "a010106" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010106: ldsflda float32 [rvastatic4]A::a010107 conv.i8 ldc.i8 61555 add conv.i8 ldc.i8 61555 sub conv.i ldind.r4 ldc.r4 107.0 beq a010107 ldstr "a010107" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010107: ldsflda int32 [rvastatic4]A::a010108 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i4 ldc.i4 108 beq a010108 ldstr "a010108" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010108: ldsflda int16 [rvastatic4]A::a010109 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 109 beq a010109 ldstr "a010109" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010109: ldsflda int32 [rvastatic4]A::a010110 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 110 beq a010110 ldstr "a010110" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010110: ldsflda int32 [rvastatic4]A::a010111 conv.i8 dup dup xor xor conv.i ldind.i4 ldc.i4 111 beq a010111 ldstr "a010111" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010111: ldsflda int32 [rvastatic4]A::a010112 conv.i8 dup dup xor xor conv.i ldind.i4 ldc.i4 112 beq a010112 ldstr "a010112" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010112: ldsflda int64 [rvastatic4]A::a010113 conv.i8 ldc.i8 45274 add conv.i8 ldc.i8 45274 sub conv.i ldind.i8 ldc.i8 113 beq a010113 ldstr "a010113" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010113: ldsflda int64 [rvastatic4]A::a010114 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 114 beq a010114 ldstr "a010114" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010114: ldsflda int16 [rvastatic4]A::a010115 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 115 beq a010115 ldstr "a010115" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010115: ldsflda int64 [rvastatic4]A::a010116 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 116 beq a010116 ldstr "a010116" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010116: ldsflda int64 [rvastatic4]A::a010117 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i8 ldc.i8 117 beq a010117 ldstr "a010117" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010117: ldsflda int32 [rvastatic4]A::a010118 conv.i8 ldc.i8 9701 add conv.i8 ldc.i8 9701 sub conv.i ldind.i4 ldc.i4 118 beq a010118 ldstr "a010118" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010118: ldsflda int64 [rvastatic4]A::a010119 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 119 beq a010119 ldstr "a010119" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010119: ldsflda int64 [rvastatic4]A::a010120 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i8 ldc.i8 120 beq a010120 ldstr "a010120" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010120: ldsflda int64 [rvastatic4]A::a010121 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i8 ldc.i8 121 beq a010121 ldstr "a010121" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010121: ldsflda int16 [rvastatic4]A::a010122 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i2 ldc.i4 122 beq a010122 ldstr "a010122" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010122: ldsflda int64 [rvastatic4]A::a010123 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 123 beq a010123 ldstr "a010123" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010123: ldsflda int64 [rvastatic4]A::a010124 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 124 beq a010124 ldstr "a010124" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010124: ldsflda int32 [rvastatic4]A::a010125 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 125 beq a010125 ldstr "a010125" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010125: ldsflda int16 [rvastatic4]A::a010126 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 126 beq a010126 ldstr "a010126" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010126: ldsflda int16 [rvastatic4]A::a010127 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 127 beq a010127 ldstr "a010127" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010127: ret} .method static void V5() {.maxstack 50 ldsflda int32 [rvastatic4]A::a0100 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 0 beq a0100 ldstr "a0100" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0100: ldsflda int64 [rvastatic4]A::a0101 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 1 beq a0101 ldstr "a0101" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0101: ldsflda float32 [rvastatic4]A::a0102 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 2.0 beq a0102 ldstr "a0102" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0102: ldsflda int16 [rvastatic4]A::a0103 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 3 beq a0103 ldstr "a0103" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0103: ldsflda int16 [rvastatic4]A::a0104 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 4 beq a0104 ldstr "a0104" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0104: ldsflda int64 [rvastatic4]A::a0105 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 5 beq a0105 ldstr "a0105" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0105: ldsflda int16 [rvastatic4]A::a0106 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 6 beq a0106 ldstr "a0106" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0106: ldsflda int8 [rvastatic4]A::a0107 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 7 beq a0107 ldstr "a0107" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0107: ldsflda int64 [rvastatic4]A::a0108 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 8 beq a0108 ldstr "a0108" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0108: ldsflda int32 [rvastatic4]A::a0109 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 9 beq a0109 ldstr "a0109" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0109: ldsflda int16 [rvastatic4]A::a01010 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 10 beq a01010 ldstr "a01010" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01010: ldsflda float32 [rvastatic4]A::a01011 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 11.0 beq a01011 ldstr "a01011" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01011: ldsflda int16 [rvastatic4]A::a01012 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 12 beq a01012 ldstr "a01012" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01012: ldsflda float32 [rvastatic4]A::a01013 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 13.0 beq a01013 ldstr "a01013" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01013: ldsflda float32 [rvastatic4]A::a01014 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.r4 ldc.r4 14.0 beq a01014 ldstr "a01014" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01014: ldsflda int8 [rvastatic4]A::a01015 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 15 beq a01015 ldstr "a01015" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01015: ldsflda float32 [rvastatic4]A::a01016 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 16.0 beq a01016 ldstr "a01016" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01016: ldsflda int8 [rvastatic4]A::a01017 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 17 beq a01017 ldstr "a01017" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01017: ldsflda float32 [rvastatic4]A::a01018 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.r4 ldc.r4 18.0 beq a01018 ldstr "a01018" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01018: ldsflda float32 [rvastatic4]A::a01019 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 19.0 beq a01019 ldstr "a01019" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01019: ldsflda int8 [rvastatic4]A::a01020 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 20 beq a01020 ldstr "a01020" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01020: ldsflda float32 [rvastatic4]A::a01021 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 21.0 beq a01021 ldstr "a01021" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01021: ldsflda int64 [rvastatic4]A::a01022 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 22 beq a01022 ldstr "a01022" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01022: ldsflda int8 [rvastatic4]A::a01023 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 23 beq a01023 ldstr "a01023" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01023: ldsflda int32 [rvastatic4]A::a01024 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 24 beq a01024 ldstr "a01024" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01024: ldsflda int64 [rvastatic4]A::a01025 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 25 beq a01025 ldstr "a01025" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01025: ldsflda int16 [rvastatic4]A::a01026 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 26 beq a01026 ldstr "a01026" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01026: ldsflda int8 [rvastatic4]A::a01027 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 27 beq a01027 ldstr "a01027" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01027: ldsflda int16 [rvastatic4]A::a01028 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 28 beq a01028 ldstr "a01028" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01028: ldsflda int16 [rvastatic4]A::a01029 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 29 beq a01029 ldstr "a01029" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01029: ldsflda int8 [rvastatic4]A::a01030 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 30 beq a01030 ldstr "a01030" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01030: ldsflda int8 [rvastatic4]A::a01031 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 31 beq a01031 ldstr "a01031" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01031: ldsflda int64 [rvastatic4]A::a01032 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 32 beq a01032 ldstr "a01032" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01032: ldsflda float32 [rvastatic4]A::a01033 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 33.0 beq a01033 ldstr "a01033" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01033: ldsflda int16 [rvastatic4]A::a01034 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 34 beq a01034 ldstr "a01034" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01034: ldsflda int8 [rvastatic4]A::a01035 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 35 beq a01035 ldstr "a01035" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01035: ldsflda int8 [rvastatic4]A::a01036 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 36 beq a01036 ldstr "a01036" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01036: ldsflda int32 [rvastatic4]A::a01037 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 37 beq a01037 ldstr "a01037" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01037: ldsflda int16 [rvastatic4]A::a01038 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 38 beq a01038 ldstr "a01038" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01038: ldsflda int8 [rvastatic4]A::a01039 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 39 beq a01039 ldstr "a01039" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01039: ldsflda int8 [rvastatic4]A::a01040 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 40 beq a01040 ldstr "a01040" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01040: ldsflda int32 [rvastatic4]A::a01041 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 41 beq a01041 ldstr "a01041" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01041: ldsflda int64 [rvastatic4]A::a01042 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 42 beq a01042 ldstr "a01042" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01042: ldsflda int16 [rvastatic4]A::a01043 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 43 beq a01043 ldstr "a01043" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01043: ldsflda int64 [rvastatic4]A::a01044 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 44 beq a01044 ldstr "a01044" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01044: ldsflda int64 [rvastatic4]A::a01045 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 45 beq a01045 ldstr "a01045" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01045: ldsflda float32 [rvastatic4]A::a01046 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 46.0 beq a01046 ldstr "a01046" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01046: ldsflda int16 [rvastatic4]A::a01047 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 47 beq a01047 ldstr "a01047" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01047: ldsflda int64 [rvastatic4]A::a01048 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 48 beq a01048 ldstr "a01048" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01048: ldsflda int16 [rvastatic4]A::a01049 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 49 beq a01049 ldstr "a01049" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01049: ldsflda int32 [rvastatic4]A::a01050 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 50 beq a01050 ldstr "a01050" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01050: ldsflda int16 [rvastatic4]A::a01051 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 51 beq a01051 ldstr "a01051" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01051: ldsflda int32 [rvastatic4]A::a01052 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 52 beq a01052 ldstr "a01052" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01052: ldsflda int16 [rvastatic4]A::a01053 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 53 beq a01053 ldstr "a01053" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01053: ldsflda float32 [rvastatic4]A::a01054 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 54.0 beq a01054 ldstr "a01054" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01054: ldsflda int64 [rvastatic4]A::a01055 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 55 beq a01055 ldstr "a01055" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01055: ldsflda float32 [rvastatic4]A::a01056 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.r4 ldc.r4 56.0 beq a01056 ldstr "a01056" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01056: ldsflda int64 [rvastatic4]A::a01057 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 57 beq a01057 ldstr "a01057" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01057: ldsflda int64 [rvastatic4]A::a01058 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 58 beq a01058 ldstr "a01058" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01058: ldsflda int64 [rvastatic4]A::a01059 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 59 beq a01059 ldstr "a01059" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01059: ldsflda int16 [rvastatic4]A::a01060 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 60 beq a01060 ldstr "a01060" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01060: ldsflda int8 [rvastatic4]A::a01061 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 61 beq a01061 ldstr "a01061" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01061: ldsflda int64 [rvastatic4]A::a01062 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 62 beq a01062 ldstr "a01062" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01062: ldsflda int16 [rvastatic4]A::a01063 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 63 beq a01063 ldstr "a01063" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01063: ldsflda int32 [rvastatic4]A::a01064 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 64 beq a01064 ldstr "a01064" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01064: ldsflda int16 [rvastatic4]A::a01065 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 65 beq a01065 ldstr "a01065" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01065: ldsflda int8 [rvastatic4]A::a01066 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 66 beq a01066 ldstr "a01066" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01066: ldsflda int16 [rvastatic4]A::a01067 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 67 beq a01067 ldstr "a01067" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01067: ldsflda int32 [rvastatic4]A::a01068 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 68 beq a01068 ldstr "a01068" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01068: ldsflda float32 [rvastatic4]A::a01069 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 69.0 beq a01069 ldstr "a01069" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01069: ldsflda float32 [rvastatic4]A::a01070 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 70.0 beq a01070 ldstr "a01070" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01070: ldsflda int16 [rvastatic4]A::a01071 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 71 beq a01071 ldstr "a01071" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01071: ldsflda float32 [rvastatic4]A::a01072 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 72.0 beq a01072 ldstr "a01072" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01072: ldsflda int64 [rvastatic4]A::a01073 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 73 beq a01073 ldstr "a01073" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01073: ldsflda int64 [rvastatic4]A::a01074 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 74 beq a01074 ldstr "a01074" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01074: ldsflda int32 [rvastatic4]A::a01075 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 75 beq a01075 ldstr "a01075" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01075: ldsflda int8 [rvastatic4]A::a01076 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 76 beq a01076 ldstr "a01076" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01076: ldsflda int32 [rvastatic4]A::a01077 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 77 beq a01077 ldstr "a01077" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01077: ldsflda int16 [rvastatic4]A::a01078 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 78 beq a01078 ldstr "a01078" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01078: ldsflda float32 [rvastatic4]A::a01079 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.r4 ldc.r4 79.0 beq a01079 ldstr "a01079" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01079: ldsflda float32 [rvastatic4]A::a01080 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 80.0 beq a01080 ldstr "a01080" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01080: ldsflda float32 [rvastatic4]A::a01081 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 81.0 beq a01081 ldstr "a01081" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01081: ldsflda int32 [rvastatic4]A::a01082 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 82 beq a01082 ldstr "a01082" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01082: ldsflda int8 [rvastatic4]A::a01083 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 83 beq a01083 ldstr "a01083" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01083: ldsflda int64 [rvastatic4]A::a01084 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 84 beq a01084 ldstr "a01084" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01084: ldsflda int64 [rvastatic4]A::a01085 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 85 beq a01085 ldstr "a01085" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01085: ldsflda int32 [rvastatic4]A::a01086 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 86 beq a01086 ldstr "a01086" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01086: ldsflda int32 [rvastatic4]A::a01087 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 87 beq a01087 ldstr "a01087" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01087: ldsflda int8 [rvastatic4]A::a01088 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 88 beq a01088 ldstr "a01088" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01088: ldsflda int64 [rvastatic4]A::a01089 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 89 beq a01089 ldstr "a01089" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01089: ldsflda int8 [rvastatic4]A::a01090 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 90 beq a01090 ldstr "a01090" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01090: ldsflda int16 [rvastatic4]A::a01091 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 91 beq a01091 ldstr "a01091" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01091: ldsflda float32 [rvastatic4]A::a01092 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 92.0 beq a01092 ldstr "a01092" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01092: ldsflda int64 [rvastatic4]A::a01093 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 93 beq a01093 ldstr "a01093" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01093: ldsflda int64 [rvastatic4]A::a01094 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 94 beq a01094 ldstr "a01094" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01094: ldsflda int8 [rvastatic4]A::a01095 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 95 beq a01095 ldstr "a01095" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01095: ldsflda float32 [rvastatic4]A::a01096 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 96.0 beq a01096 ldstr "a01096" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01096: ldsflda int16 [rvastatic4]A::a01097 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 97 beq a01097 ldstr "a01097" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01097: ldsflda float32 [rvastatic4]A::a01098 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 98.0 beq a01098 ldstr "a01098" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01098: ldsflda int32 [rvastatic4]A::a01099 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 99 beq a01099 ldstr "a01099" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01099: ldsflda int64 [rvastatic4]A::a010100 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 100 beq a010100 ldstr "a010100" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010100: ldsflda int32 [rvastatic4]A::a010101 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 101 beq a010101 ldstr "a010101" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010101: ldsflda float32 [rvastatic4]A::a010102 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 102.0 beq a010102 ldstr "a010102" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010102: ldsflda int64 [rvastatic4]A::a010103 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 103 beq a010103 ldstr "a010103" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010103: ldsflda int32 [rvastatic4]A::a010104 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 104 beq a010104 ldstr "a010104" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010104: ldsflda int16 [rvastatic4]A::a010105 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 105 beq a010105 ldstr "a010105" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010105: ldsflda int16 [rvastatic4]A::a010106 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 106 beq a010106 ldstr "a010106" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010106: ldsflda float32 [rvastatic4]A::a010107 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 107.0 beq a010107 ldstr "a010107" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010107: ldsflda int32 [rvastatic4]A::a010108 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 108 beq a010108 ldstr "a010108" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010108: ldsflda int16 [rvastatic4]A::a010109 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 109 beq a010109 ldstr "a010109" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010109: ldsflda int32 [rvastatic4]A::a010110 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 110 beq a010110 ldstr "a010110" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010110: ldsflda int32 [rvastatic4]A::a010111 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 111 beq a010111 ldstr "a010111" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010111: ldsflda int32 [rvastatic4]A::a010112 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 112 beq a010112 ldstr "a010112" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010112: ldsflda int64 [rvastatic4]A::a010113 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 113 beq a010113 ldstr "a010113" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010113: ldsflda int64 [rvastatic4]A::a010114 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 114 beq a010114 ldstr "a010114" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010114: ldsflda int16 [rvastatic4]A::a010115 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 115 beq a010115 ldstr "a010115" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010115: ldsflda int64 [rvastatic4]A::a010116 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 116 beq a010116 ldstr "a010116" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010116: ldsflda int64 [rvastatic4]A::a010117 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 117 beq a010117 ldstr "a010117" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010117: ldsflda int32 [rvastatic4]A::a010118 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 118 beq a010118 ldstr "a010118" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010118: ldsflda int64 [rvastatic4]A::a010119 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 119 beq a010119 ldstr "a010119" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010119: ldsflda int64 [rvastatic4]A::a010120 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 120 beq a010120 ldstr "a010120" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010120: ldsflda int64 [rvastatic4]A::a010121 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 121 beq a010121 ldstr "a010121" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010121: ldsflda int16 [rvastatic4]A::a010122 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 122 beq a010122 ldstr "a010122" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010122: ldsflda int64 [rvastatic4]A::a010123 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 123 beq a010123 ldstr "a010123" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010123: ldsflda int64 [rvastatic4]A::a010124 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 124 beq a010124 ldstr "a010124" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010124: ldsflda int32 [rvastatic4]A::a010125 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 125 beq a010125 ldstr "a010125" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010125: ldsflda int16 [rvastatic4]A::a010126 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 126 beq a010126 ldstr "a010126" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010126: ldsflda int16 [rvastatic4]A::a010127 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 127 beq a010127 ldstr "a010127" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010127: ret} .method static void V6() {.maxstack 50 ldsfld int32 [rvastatic4]A::a0100 ldc.i4 1 add stsfld int32 [rvastatic4]A::a0100 ldsfld int32 [rvastatic4]A::a0100 ldc.i4 1 beq a0100 newobj instance void [mscorlib]System.Exception::.ctor() throw a0100: ldsfld int64 [rvastatic4]A::a0101 ldc.i8 1 add stsfld int64 [rvastatic4]A::a0101 ldsfld int64 [rvastatic4]A::a0101 ldc.i8 2 beq a0101 newobj instance void [mscorlib]System.Exception::.ctor() throw a0101: ldsfld float32 [rvastatic4]A::a0102 ldc.r4 1 add stsfld float32 [rvastatic4]A::a0102 ldsfld float32 [rvastatic4]A::a0102 ldc.r4 3.0 beq a0102 newobj instance void [mscorlib]System.Exception::.ctor() throw a0102: ldsfld int16 [rvastatic4]A::a0103 ldc.i4 1 add stsfld int16 [rvastatic4]A::a0103 ldsfld int16 [rvastatic4]A::a0103 ldc.i4 4 beq a0103 newobj instance void [mscorlib]System.Exception::.ctor() throw a0103: ldsfld int16 [rvastatic4]A::a0104 ldc.i4 1 add stsfld int16 [rvastatic4]A::a0104 ldsfld int16 [rvastatic4]A::a0104 ldc.i4 5 beq a0104 newobj instance void [mscorlib]System.Exception::.ctor() throw a0104: ldsfld int64 [rvastatic4]A::a0105 ldc.i8 1 add stsfld int64 [rvastatic4]A::a0105 ldsfld int64 [rvastatic4]A::a0105 ldc.i8 6 beq a0105 newobj instance void [mscorlib]System.Exception::.ctor() throw a0105: ldsfld int16 [rvastatic4]A::a0106 ldc.i4 1 add stsfld int16 [rvastatic4]A::a0106 ldsfld int16 [rvastatic4]A::a0106 ldc.i4 7 beq a0106 newobj instance void [mscorlib]System.Exception::.ctor() throw a0106: ldsfld int8 [rvastatic4]A::a0107 ldc.i4 1 add stsfld int8 [rvastatic4]A::a0107 ldsfld int8 [rvastatic4]A::a0107 ldc.i4 8 beq a0107 newobj instance void [mscorlib]System.Exception::.ctor() throw a0107: ldsfld int64 [rvastatic4]A::a0108 ldc.i8 1 add stsfld int64 [rvastatic4]A::a0108 ldsfld int64 [rvastatic4]A::a0108 ldc.i8 9 beq a0108 newobj instance void [mscorlib]System.Exception::.ctor() throw a0108: ldsfld int32 [rvastatic4]A::a0109 ldc.i4 1 add stsfld int32 [rvastatic4]A::a0109 ldsfld int32 [rvastatic4]A::a0109 ldc.i4 10 beq a0109 newobj instance void [mscorlib]System.Exception::.ctor() throw a0109: ldsfld int16 [rvastatic4]A::a01010 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01010 ldsfld int16 [rvastatic4]A::a01010 ldc.i4 11 beq a01010 newobj instance void [mscorlib]System.Exception::.ctor() throw a01010: ldsfld float32 [rvastatic4]A::a01011 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01011 ldsfld float32 [rvastatic4]A::a01011 ldc.r4 12.0 beq a01011 newobj instance void [mscorlib]System.Exception::.ctor() throw a01011: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01012 ldsfld int16 [rvastatic4]A::a01012 ldc.i4 13 beq a01012 newobj instance void [mscorlib]System.Exception::.ctor() throw a01012: ldsfld float32 [rvastatic4]A::a01013 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01013 ldsfld float32 [rvastatic4]A::a01013 ldc.r4 14.0 beq a01013 newobj instance void [mscorlib]System.Exception::.ctor() throw a01013: ldsfld float32 [rvastatic4]A::a01014 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01014 ldsfld float32 [rvastatic4]A::a01014 ldc.r4 15.0 beq a01014 newobj instance void [mscorlib]System.Exception::.ctor() throw a01014: ldsfld int8 [rvastatic4]A::a01015 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01015 ldsfld int8 [rvastatic4]A::a01015 ldc.i4 16 beq a01015 newobj instance void [mscorlib]System.Exception::.ctor() throw a01015: ldsfld float32 [rvastatic4]A::a01016 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01016 ldsfld float32 [rvastatic4]A::a01016 ldc.r4 17.0 beq a01016 newobj instance void [mscorlib]System.Exception::.ctor() throw a01016: ldsfld int8 [rvastatic4]A::a01017 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01017 ldsfld int8 [rvastatic4]A::a01017 ldc.i4 18 beq a01017 newobj instance void [mscorlib]System.Exception::.ctor() throw a01017: ldsfld float32 [rvastatic4]A::a01018 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01018 ldsfld float32 [rvastatic4]A::a01018 ldc.r4 19.0 beq a01018 newobj instance void [mscorlib]System.Exception::.ctor() throw a01018: ldsfld float32 [rvastatic4]A::a01019 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01019 ldsfld float32 [rvastatic4]A::a01019 ldc.r4 20.0 beq a01019 newobj instance void [mscorlib]System.Exception::.ctor() throw a01019: ldsfld int8 [rvastatic4]A::a01020 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01020 ldsfld int8 [rvastatic4]A::a01020 ldc.i4 21 beq a01020 newobj instance void [mscorlib]System.Exception::.ctor() throw a01020: ldsfld float32 [rvastatic4]A::a01021 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01021 ldsfld float32 [rvastatic4]A::a01021 ldc.r4 22.0 beq a01021 newobj instance void [mscorlib]System.Exception::.ctor() throw a01021: ldsfld int64 [rvastatic4]A::a01022 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01022 ldsfld int64 [rvastatic4]A::a01022 ldc.i8 23 beq a01022 newobj instance void [mscorlib]System.Exception::.ctor() throw a01022: ldsfld int8 [rvastatic4]A::a01023 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01023 ldsfld int8 [rvastatic4]A::a01023 ldc.i4 24 beq a01023 newobj instance void [mscorlib]System.Exception::.ctor() throw a01023: ldsfld int32 [rvastatic4]A::a01024 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01024 ldsfld int32 [rvastatic4]A::a01024 ldc.i4 25 beq a01024 newobj instance void [mscorlib]System.Exception::.ctor() throw a01024: ldsfld int64 [rvastatic4]A::a01025 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01025 ldsfld int64 [rvastatic4]A::a01025 ldc.i8 26 beq a01025 newobj instance void [mscorlib]System.Exception::.ctor() throw a01025: ldsfld int16 [rvastatic4]A::a01026 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01026 ldsfld int16 [rvastatic4]A::a01026 ldc.i4 27 beq a01026 newobj instance void [mscorlib]System.Exception::.ctor() throw a01026: ldsfld int8 [rvastatic4]A::a01027 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01027 ldsfld int8 [rvastatic4]A::a01027 ldc.i4 28 beq a01027 newobj instance void [mscorlib]System.Exception::.ctor() throw a01027: ldsfld int16 [rvastatic4]A::a01028 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01028 ldsfld int16 [rvastatic4]A::a01028 ldc.i4 29 beq a01028 newobj instance void [mscorlib]System.Exception::.ctor() throw a01028: ldsfld int16 [rvastatic4]A::a01029 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01029 ldsfld int16 [rvastatic4]A::a01029 ldc.i4 30 beq a01029 newobj instance void [mscorlib]System.Exception::.ctor() throw a01029: ldsfld int8 [rvastatic4]A::a01030 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01030 ldsfld int8 [rvastatic4]A::a01030 ldc.i4 31 beq a01030 newobj instance void [mscorlib]System.Exception::.ctor() throw a01030: ldsfld int8 [rvastatic4]A::a01031 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01031 ldsfld int8 [rvastatic4]A::a01031 ldc.i4 32 beq a01031 newobj instance void [mscorlib]System.Exception::.ctor() throw a01031: ldsfld int64 [rvastatic4]A::a01032 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01032 ldsfld int64 [rvastatic4]A::a01032 ldc.i8 33 beq a01032 newobj instance void [mscorlib]System.Exception::.ctor() throw a01032: ldsfld float32 [rvastatic4]A::a01033 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01033 ldsfld float32 [rvastatic4]A::a01033 ldc.r4 34.0 beq a01033 newobj instance void [mscorlib]System.Exception::.ctor() throw a01033: ldsfld int16 [rvastatic4]A::a01034 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01034 ldsfld int16 [rvastatic4]A::a01034 ldc.i4 35 beq a01034 newobj instance void [mscorlib]System.Exception::.ctor() throw a01034: ldsfld int8 [rvastatic4]A::a01035 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01035 ldsfld int8 [rvastatic4]A::a01035 ldc.i4 36 beq a01035 newobj instance void [mscorlib]System.Exception::.ctor() throw a01035: ldsfld int8 [rvastatic4]A::a01036 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01036 ldsfld int8 [rvastatic4]A::a01036 ldc.i4 37 beq a01036 newobj instance void [mscorlib]System.Exception::.ctor() throw a01036: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01037 ldsfld int32 [rvastatic4]A::a01037 ldc.i4 38 beq a01037 newobj instance void [mscorlib]System.Exception::.ctor() throw a01037: ldsfld int16 [rvastatic4]A::a01038 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01038 ldsfld int16 [rvastatic4]A::a01038 ldc.i4 39 beq a01038 newobj instance void [mscorlib]System.Exception::.ctor() throw a01038: ldsfld int8 [rvastatic4]A::a01039 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01039 ldsfld int8 [rvastatic4]A::a01039 ldc.i4 40 beq a01039 newobj instance void [mscorlib]System.Exception::.ctor() throw a01039: ldsfld int8 [rvastatic4]A::a01040 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01040 ldsfld int8 [rvastatic4]A::a01040 ldc.i4 41 beq a01040 newobj instance void [mscorlib]System.Exception::.ctor() throw a01040: ldsfld int32 [rvastatic4]A::a01041 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01041 ldsfld int32 [rvastatic4]A::a01041 ldc.i4 42 beq a01041 newobj instance void [mscorlib]System.Exception::.ctor() throw a01041: ldsfld int64 [rvastatic4]A::a01042 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01042 ldsfld int64 [rvastatic4]A::a01042 ldc.i8 43 beq a01042 newobj instance void [mscorlib]System.Exception::.ctor() throw a01042: ldsfld int16 [rvastatic4]A::a01043 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01043 ldsfld int16 [rvastatic4]A::a01043 ldc.i4 44 beq a01043 newobj instance void [mscorlib]System.Exception::.ctor() throw a01043: ldsfld int64 [rvastatic4]A::a01044 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01044 ldsfld int64 [rvastatic4]A::a01044 ldc.i8 45 beq a01044 newobj instance void [mscorlib]System.Exception::.ctor() throw a01044: ldsfld int64 [rvastatic4]A::a01045 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01045 ldsfld int64 [rvastatic4]A::a01045 ldc.i8 46 beq a01045 newobj instance void [mscorlib]System.Exception::.ctor() throw a01045: ldsfld float32 [rvastatic4]A::a01046 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01046 ldsfld float32 [rvastatic4]A::a01046 ldc.r4 47.0 beq a01046 newobj instance void [mscorlib]System.Exception::.ctor() throw a01046: ldsfld int16 [rvastatic4]A::a01047 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01047 ldsfld int16 [rvastatic4]A::a01047 ldc.i4 48 beq a01047 newobj instance void [mscorlib]System.Exception::.ctor() throw a01047: ldsfld int64 [rvastatic4]A::a01048 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01048 ldsfld int64 [rvastatic4]A::a01048 ldc.i8 49 beq a01048 newobj instance void [mscorlib]System.Exception::.ctor() throw a01048: ldsfld int16 [rvastatic4]A::a01049 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01049 ldsfld int16 [rvastatic4]A::a01049 ldc.i4 50 beq a01049 newobj instance void [mscorlib]System.Exception::.ctor() throw a01049: ldsfld int32 [rvastatic4]A::a01050 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01050 ldsfld int32 [rvastatic4]A::a01050 ldc.i4 51 beq a01050 newobj instance void [mscorlib]System.Exception::.ctor() throw a01050: ldsfld int16 [rvastatic4]A::a01051 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01051 ldsfld int16 [rvastatic4]A::a01051 ldc.i4 52 beq a01051 newobj instance void [mscorlib]System.Exception::.ctor() throw a01051: ldsfld int32 [rvastatic4]A::a01052 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01052 ldsfld int32 [rvastatic4]A::a01052 ldc.i4 53 beq a01052 newobj instance void [mscorlib]System.Exception::.ctor() throw a01052: ldsfld int16 [rvastatic4]A::a01053 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01053 ldsfld int16 [rvastatic4]A::a01053 ldc.i4 54 beq a01053 newobj instance void [mscorlib]System.Exception::.ctor() throw a01053: ldsfld float32 [rvastatic4]A::a01054 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01054 ldsfld float32 [rvastatic4]A::a01054 ldc.r4 55.0 beq a01054 newobj instance void [mscorlib]System.Exception::.ctor() throw a01054: ldsfld int64 [rvastatic4]A::a01055 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01055 ldsfld int64 [rvastatic4]A::a01055 ldc.i8 56 beq a01055 newobj instance void [mscorlib]System.Exception::.ctor() throw a01055: ldsfld float32 [rvastatic4]A::a01056 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01056 ldsfld float32 [rvastatic4]A::a01056 ldc.r4 57.0 beq a01056 newobj instance void [mscorlib]System.Exception::.ctor() throw a01056: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01057 ldsfld int64 [rvastatic4]A::a01057 ldc.i8 58 beq a01057 newobj instance void [mscorlib]System.Exception::.ctor() throw a01057: ldsfld int64 [rvastatic4]A::a01058 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01058 ldsfld int64 [rvastatic4]A::a01058 ldc.i8 59 beq a01058 newobj instance void [mscorlib]System.Exception::.ctor() throw a01058: ldsfld int64 [rvastatic4]A::a01059 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01059 ldsfld int64 [rvastatic4]A::a01059 ldc.i8 60 beq a01059 newobj instance void [mscorlib]System.Exception::.ctor() throw a01059: ldsfld int16 [rvastatic4]A::a01060 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01060 ldsfld int16 [rvastatic4]A::a01060 ldc.i4 61 beq a01060 newobj instance void [mscorlib]System.Exception::.ctor() throw a01060: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01061 ldsfld int8 [rvastatic4]A::a01061 ldc.i4 62 beq a01061 newobj instance void [mscorlib]System.Exception::.ctor() throw a01061: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01062 ldsfld int64 [rvastatic4]A::a01062 ldc.i8 63 beq a01062 newobj instance void [mscorlib]System.Exception::.ctor() throw a01062: ldsfld int16 [rvastatic4]A::a01063 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01063 ldsfld int16 [rvastatic4]A::a01063 ldc.i4 64 beq a01063 newobj instance void [mscorlib]System.Exception::.ctor() throw a01063: ldsfld int32 [rvastatic4]A::a01064 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01064 ldsfld int32 [rvastatic4]A::a01064 ldc.i4 65 beq a01064 newobj instance void [mscorlib]System.Exception::.ctor() throw a01064: ldsfld int16 [rvastatic4]A::a01065 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01065 ldsfld int16 [rvastatic4]A::a01065 ldc.i4 66 beq a01065 newobj instance void [mscorlib]System.Exception::.ctor() throw a01065: ldsfld int8 [rvastatic4]A::a01066 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01066 ldsfld int8 [rvastatic4]A::a01066 ldc.i4 67 beq a01066 newobj instance void [mscorlib]System.Exception::.ctor() throw a01066: ldsfld int16 [rvastatic4]A::a01067 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01067 ldsfld int16 [rvastatic4]A::a01067 ldc.i4 68 beq a01067 newobj instance void [mscorlib]System.Exception::.ctor() throw a01067: ldsfld int32 [rvastatic4]A::a01068 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01068 ldsfld int32 [rvastatic4]A::a01068 ldc.i4 69 beq a01068 newobj instance void [mscorlib]System.Exception::.ctor() throw a01068: ldsfld float32 [rvastatic4]A::a01069 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01069 ldsfld float32 [rvastatic4]A::a01069 ldc.r4 70.0 beq a01069 newobj instance void [mscorlib]System.Exception::.ctor() throw a01069: ldsfld float32 [rvastatic4]A::a01070 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01070 ldsfld float32 [rvastatic4]A::a01070 ldc.r4 71.0 beq a01070 newobj instance void [mscorlib]System.Exception::.ctor() throw a01070: ldsfld int16 [rvastatic4]A::a01071 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01071 ldsfld int16 [rvastatic4]A::a01071 ldc.i4 72 beq a01071 newobj instance void [mscorlib]System.Exception::.ctor() throw a01071: ldsfld float32 [rvastatic4]A::a01072 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01072 ldsfld float32 [rvastatic4]A::a01072 ldc.r4 73.0 beq a01072 newobj instance void [mscorlib]System.Exception::.ctor() throw a01072: ldsfld int64 [rvastatic4]A::a01073 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01073 ldsfld int64 [rvastatic4]A::a01073 ldc.i8 74 beq a01073 newobj instance void [mscorlib]System.Exception::.ctor() throw a01073: ldsfld int64 [rvastatic4]A::a01074 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01074 ldsfld int64 [rvastatic4]A::a01074 ldc.i8 75 beq a01074 newobj instance void [mscorlib]System.Exception::.ctor() throw a01074: ldsfld int32 [rvastatic4]A::a01075 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01075 ldsfld int32 [rvastatic4]A::a01075 ldc.i4 76 beq a01075 newobj instance void [mscorlib]System.Exception::.ctor() throw a01075: ldsfld int8 [rvastatic4]A::a01076 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01076 ldsfld int8 [rvastatic4]A::a01076 ldc.i4 77 beq a01076 newobj instance void [mscorlib]System.Exception::.ctor() throw a01076: ldsfld int32 [rvastatic4]A::a01077 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01077 ldsfld int32 [rvastatic4]A::a01077 ldc.i4 78 beq a01077 newobj instance void [mscorlib]System.Exception::.ctor() throw a01077: ldsfld int16 [rvastatic4]A::a01078 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01078 ldsfld int16 [rvastatic4]A::a01078 ldc.i4 79 beq a01078 newobj instance void [mscorlib]System.Exception::.ctor() throw a01078: ldsfld float32 [rvastatic4]A::a01079 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01079 ldsfld float32 [rvastatic4]A::a01079 ldc.r4 80.0 beq a01079 newobj instance void [mscorlib]System.Exception::.ctor() throw a01079: ldsfld float32 [rvastatic4]A::a01080 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01080 ldsfld float32 [rvastatic4]A::a01080 ldc.r4 81.0 beq a01080 newobj instance void [mscorlib]System.Exception::.ctor() throw a01080: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01081 ldsfld float32 [rvastatic4]A::a01081 ldc.r4 82.0 beq a01081 newobj instance void [mscorlib]System.Exception::.ctor() throw a01081: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01082 ldsfld int32 [rvastatic4]A::a01082 ldc.i4 83 beq a01082 newobj instance void [mscorlib]System.Exception::.ctor() throw a01082: ldsfld int8 [rvastatic4]A::a01083 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01083 ldsfld int8 [rvastatic4]A::a01083 ldc.i4 84 beq a01083 newobj instance void [mscorlib]System.Exception::.ctor() throw a01083: ldsfld int64 [rvastatic4]A::a01084 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01084 ldsfld int64 [rvastatic4]A::a01084 ldc.i8 85 beq a01084 newobj instance void [mscorlib]System.Exception::.ctor() throw a01084: ldsfld int64 [rvastatic4]A::a01085 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01085 ldsfld int64 [rvastatic4]A::a01085 ldc.i8 86 beq a01085 newobj instance void [mscorlib]System.Exception::.ctor() throw a01085: ldsfld int32 [rvastatic4]A::a01086 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01086 ldsfld int32 [rvastatic4]A::a01086 ldc.i4 87 beq a01086 newobj instance void [mscorlib]System.Exception::.ctor() throw a01086: ldsfld int32 [rvastatic4]A::a01087 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01087 ldsfld int32 [rvastatic4]A::a01087 ldc.i4 88 beq a01087 newobj instance void [mscorlib]System.Exception::.ctor() throw a01087: ldsfld int8 [rvastatic4]A::a01088 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01088 ldsfld int8 [rvastatic4]A::a01088 ldc.i4 89 beq a01088 newobj instance void [mscorlib]System.Exception::.ctor() throw a01088: ldsfld int64 [rvastatic4]A::a01089 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01089 ldsfld int64 [rvastatic4]A::a01089 ldc.i8 90 beq a01089 newobj instance void [mscorlib]System.Exception::.ctor() throw a01089: ldsfld int8 [rvastatic4]A::a01090 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01090 ldsfld int8 [rvastatic4]A::a01090 ldc.i4 91 beq a01090 newobj instance void [mscorlib]System.Exception::.ctor() throw a01090: ldsfld int16 [rvastatic4]A::a01091 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01091 ldsfld int16 [rvastatic4]A::a01091 ldc.i4 92 beq a01091 newobj instance void [mscorlib]System.Exception::.ctor() throw a01091: ldsfld float32 [rvastatic4]A::a01092 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01092 ldsfld float32 [rvastatic4]A::a01092 ldc.r4 93.0 beq a01092 newobj instance void [mscorlib]System.Exception::.ctor() throw a01092: ldsfld int64 [rvastatic4]A::a01093 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01093 ldsfld int64 [rvastatic4]A::a01093 ldc.i8 94 beq a01093 newobj instance void [mscorlib]System.Exception::.ctor() throw a01093: ldsfld int64 [rvastatic4]A::a01094 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01094 ldsfld int64 [rvastatic4]A::a01094 ldc.i8 95 beq a01094 newobj instance void [mscorlib]System.Exception::.ctor() throw a01094: ldsfld int8 [rvastatic4]A::a01095 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01095 ldsfld int8 [rvastatic4]A::a01095 ldc.i4 96 beq a01095 newobj instance void [mscorlib]System.Exception::.ctor() throw a01095: ldsfld float32 [rvastatic4]A::a01096 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01096 ldsfld float32 [rvastatic4]A::a01096 ldc.r4 97.0 beq a01096 newobj instance void [mscorlib]System.Exception::.ctor() throw a01096: ldsfld int16 [rvastatic4]A::a01097 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01097 ldsfld int16 [rvastatic4]A::a01097 ldc.i4 98 beq a01097 newobj instance void [mscorlib]System.Exception::.ctor() throw a01097: ldsfld float32 [rvastatic4]A::a01098 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01098 ldsfld float32 [rvastatic4]A::a01098 ldc.r4 99.0 beq a01098 newobj instance void [mscorlib]System.Exception::.ctor() throw a01098: ldsfld int32 [rvastatic4]A::a01099 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01099 ldsfld int32 [rvastatic4]A::a01099 ldc.i4 100 beq a01099 newobj instance void [mscorlib]System.Exception::.ctor() throw a01099: ldsfld int64 [rvastatic4]A::a010100 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010100 ldsfld int64 [rvastatic4]A::a010100 ldc.i8 101 beq a010100 newobj instance void [mscorlib]System.Exception::.ctor() throw a010100: ldsfld int32 [rvastatic4]A::a010101 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010101 ldsfld int32 [rvastatic4]A::a010101 ldc.i4 102 beq a010101 newobj instance void [mscorlib]System.Exception::.ctor() throw a010101: ldsfld float32 [rvastatic4]A::a010102 ldc.r4 1 add stsfld float32 [rvastatic4]A::a010102 ldsfld float32 [rvastatic4]A::a010102 ldc.r4 103.0 beq a010102 newobj instance void [mscorlib]System.Exception::.ctor() throw a010102: ldsfld int64 [rvastatic4]A::a010103 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010103 ldsfld int64 [rvastatic4]A::a010103 ldc.i8 104 beq a010103 newobj instance void [mscorlib]System.Exception::.ctor() throw a010103: ldsfld int32 [rvastatic4]A::a010104 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010104 ldsfld int32 [rvastatic4]A::a010104 ldc.i4 105 beq a010104 newobj instance void [mscorlib]System.Exception::.ctor() throw a010104: ldsfld int16 [rvastatic4]A::a010105 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010105 ldsfld int16 [rvastatic4]A::a010105 ldc.i4 106 beq a010105 newobj instance void [mscorlib]System.Exception::.ctor() throw a010105: ldsfld int16 [rvastatic4]A::a010106 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010106 ldsfld int16 [rvastatic4]A::a010106 ldc.i4 107 beq a010106 newobj instance void [mscorlib]System.Exception::.ctor() throw a010106: ldsfld float32 [rvastatic4]A::a010107 ldc.r4 1 add stsfld float32 [rvastatic4]A::a010107 ldsfld float32 [rvastatic4]A::a010107 ldc.r4 108.0 beq a010107 newobj instance void [mscorlib]System.Exception::.ctor() throw a010107: ldsfld int32 [rvastatic4]A::a010108 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010108 ldsfld int32 [rvastatic4]A::a010108 ldc.i4 109 beq a010108 newobj instance void [mscorlib]System.Exception::.ctor() throw a010108: ldsfld int16 [rvastatic4]A::a010109 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010109 ldsfld int16 [rvastatic4]A::a010109 ldc.i4 110 beq a010109 newobj instance void [mscorlib]System.Exception::.ctor() throw a010109: ldsfld int32 [rvastatic4]A::a010110 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010110 ldsfld int32 [rvastatic4]A::a010110 ldc.i4 111 beq a010110 newobj instance void [mscorlib]System.Exception::.ctor() throw a010110: ldsfld int32 [rvastatic4]A::a010111 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010111 ldsfld int32 [rvastatic4]A::a010111 ldc.i4 112 beq a010111 newobj instance void [mscorlib]System.Exception::.ctor() throw a010111: ldsfld int32 [rvastatic4]A::a010112 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010112 ldsfld int32 [rvastatic4]A::a010112 ldc.i4 113 beq a010112 newobj instance void [mscorlib]System.Exception::.ctor() throw a010112: ldsfld int64 [rvastatic4]A::a010113 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010113 ldsfld int64 [rvastatic4]A::a010113 ldc.i8 114 beq a010113 newobj instance void [mscorlib]System.Exception::.ctor() throw a010113: ldsfld int64 [rvastatic4]A::a010114 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010114 ldsfld int64 [rvastatic4]A::a010114 ldc.i8 115 beq a010114 newobj instance void [mscorlib]System.Exception::.ctor() throw a010114: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010115 ldsfld int16 [rvastatic4]A::a010115 ldc.i4 116 beq a010115 newobj instance void [mscorlib]System.Exception::.ctor() throw a010115: ldsfld int64 [rvastatic4]A::a010116 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010116 ldsfld int64 [rvastatic4]A::a010116 ldc.i8 117 beq a010116 newobj instance void [mscorlib]System.Exception::.ctor() throw a010116: ldsfld int64 [rvastatic4]A::a010117 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010117 ldsfld int64 [rvastatic4]A::a010117 ldc.i8 118 beq a010117 newobj instance void [mscorlib]System.Exception::.ctor() throw a010117: ldsfld int32 [rvastatic4]A::a010118 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010118 ldsfld int32 [rvastatic4]A::a010118 ldc.i4 119 beq a010118 newobj instance void [mscorlib]System.Exception::.ctor() throw a010118: ldsfld int64 [rvastatic4]A::a010119 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010119 ldsfld int64 [rvastatic4]A::a010119 ldc.i8 120 beq a010119 newobj instance void [mscorlib]System.Exception::.ctor() throw a010119: ldsfld int64 [rvastatic4]A::a010120 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010120 ldsfld int64 [rvastatic4]A::a010120 ldc.i8 121 beq a010120 newobj instance void [mscorlib]System.Exception::.ctor() throw a010120: ldsfld int64 [rvastatic4]A::a010121 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010121 ldsfld int64 [rvastatic4]A::a010121 ldc.i8 122 beq a010121 newobj instance void [mscorlib]System.Exception::.ctor() throw a010121: ldsfld int16 [rvastatic4]A::a010122 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010122 ldsfld int16 [rvastatic4]A::a010122 ldc.i4 123 beq a010122 newobj instance void [mscorlib]System.Exception::.ctor() throw a010122: ldsfld int64 [rvastatic4]A::a010123 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010123 ldsfld int64 [rvastatic4]A::a010123 ldc.i8 124 beq a010123 newobj instance void [mscorlib]System.Exception::.ctor() throw a010123: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010124 ldsfld int64 [rvastatic4]A::a010124 ldc.i8 125 beq a010124 newobj instance void [mscorlib]System.Exception::.ctor() throw a010124: ldsfld int32 [rvastatic4]A::a010125 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010125 ldsfld int32 [rvastatic4]A::a010125 ldc.i4 126 beq a010125 newobj instance void [mscorlib]System.Exception::.ctor() throw a010125: ldsfld int16 [rvastatic4]A::a010126 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010126 ldsfld int16 [rvastatic4]A::a010126 ldc.i4 127 beq a010126 newobj instance void [mscorlib]System.Exception::.ctor() throw a010126: ldsfld int16 [rvastatic4]A::a010127 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010127 ldsfld int16 [rvastatic4]A::a010127 ldc.i4 128 beq a010127 newobj instance void [mscorlib]System.Exception::.ctor() throw a010127: ret} .method static int32 Main(string[] args){.entrypoint .maxstack 5 .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) call void [rvastatic4]A::V1() call void [rvastatic4]A::V2() call void [rvastatic4]A::V3() call void [rvastatic4]A::V4() call void [rvastatic4]A::V5() call void [rvastatic4]A::V6() ldc.i4 100 ret} .field public static int32 a0100 at b0100 .field private static int32 aALIGN10100 at bALIGN10100 .field public static int64 a0101 at b0101 .field public static float32 a0102 at b0102 .field private static int32 aALIGN10102 at bALIGN10102 .field public static int16 a0103 at b0103 .field private static int16 aALIGN10103 at bALIGN10103 .field private static int32 aALIGN20103 at bALIGN20103 .field public static int16 a0104 at b0104 .field private static int16 aALIGN10104 at bALIGN10104 .field private static int32 aALIGN20104 at bALIGN20104 .field public static int64 a0105 at b0105 .field public static int16 a0106 at b0106 .field private static int16 aALIGN10106 at bALIGN10106 .field private static int32 aALIGN20106 at bALIGN20106 .field public static int8 a0107 at b0107 .field private static int32 aALIGN10107 at bALIGN10107 .field private static int16 aALIGN20107 at bALIGN20107 .field private static int8 aALIGN20107 at bALIGN30107 .field public static int64 a0108 at b0108 .field public static int32 a0109 at b0109 .field private static int32 aALIGN10109 at bALIGN10109 .field public static int16 a01010 at b01010 .field private static int16 aALIGN101010 at bALIGN101010 .field private static int32 aALIGN201010 at bALIGN201010 .field public static float32 a01011 at b01011 .field private static int32 aALIGN101011 at bALIGN101011 .field public static int16 a01012 at b01012 .field private static int16 aALIGN101012 at bALIGN101012 .field private static int32 aALIGN201012 at bALIGN201012 .field public static float32 a01013 at b01013 .field private static int32 aALIGN101013 at bALIGN101013 .field public static float32 a01014 at b01014 .field private static int32 aALIGN101014 at bALIGN101014 .field public static int8 a01015 at b01015 .field private static int32 aALIGN101015 at bALIGN101015 .field private static int16 aALIGN201015 at bALIGN201015 .field private static int8 aALIGN201015 at bALIGN301015 .field public static float32 a01016 at b01016 .field private static int32 aALIGN101016 at bALIGN101016 .field public static int8 a01017 at b01017 .field private static int32 aALIGN101017 at bALIGN101017 .field private static int16 aALIGN201017 at bALIGN201017 .field private static int8 aALIGN201017 at bALIGN301017 .field public static float32 a01018 at b01018 .field private static int32 aALIGN101018 at bALIGN101018 .field public static float32 a01019 at b01019 .field private static int32 aALIGN101019 at bALIGN101019 .field public static int8 a01020 at b01020 .field private static int32 aALIGN101020 at bALIGN101020 .field private static int16 aALIGN201020 at bALIGN201020 .field private static int8 aALIGN201020 at bALIGN301020 .field public static float32 a01021 at b01021 .field private static int32 aALIGN101021 at bALIGN101021 .field public static int64 a01022 at b01022 .field public static int8 a01023 at b01023 .field private static int32 aALIGN101023 at bALIGN101023 .field private static int16 aALIGN201023 at bALIGN201023 .field private static int8 aALIGN201023 at bALIGN301023 .field public static int32 a01024 at b01024 .field private static int32 aALIGN101024 at bALIGN101024 .field public static int64 a01025 at b01025 .field public static int16 a01026 at b01026 .field private static int16 aALIGN101026 at bALIGN101026 .field private static int32 aALIGN201026 at bALIGN201026 .field public static int8 a01027 at b01027 .field private static int32 aALIGN101027 at bALIGN101027 .field private static int16 aALIGN201027 at bALIGN201027 .field private static int8 aALIGN201027 at bALIGN301027 .field public static int16 a01028 at b01028 .field private static int16 aALIGN101028 at bALIGN101028 .field private static int32 aALIGN201028 at bALIGN201028 .field public static int16 a01029 at b01029 .field private static int16 aALIGN101029 at bALIGN101029 .field private static int32 aALIGN201029 at bALIGN201029 .field public static int8 a01030 at b01030 .field private static int32 aALIGN101030 at bALIGN101030 .field private static int16 aALIGN201030 at bALIGN201030 .field private static int8 aALIGN201030 at bALIGN301030 .field public static int8 a01031 at b01031 .field private static int32 aALIGN101031 at bALIGN101031 .field private static int16 aALIGN201031 at bALIGN201031 .field private static int8 aALIGN201031 at bALIGN301031 .field public static int64 a01032 at b01032 .field public static float32 a01033 at b01033 .field private static int32 aALIGN101033 at bALIGN101033 .field public static int16 a01034 at b01034 .field private static int16 aALIGN101034 at bALIGN101034 .field private static int32 aALIGN201034 at bALIGN201034 .field public static int8 a01035 at b01035 .field private static int32 aALIGN101035 at bALIGN101035 .field private static int16 aALIGN201035 at bALIGN201035 .field private static int8 aALIGN201035 at bALIGN301035 .field public static int8 a01036 at b01036 .field private static int32 aALIGN101036 at bALIGN101036 .field private static int16 aALIGN201036 at bALIGN201036 .field private static int8 aALIGN201036 at bALIGN301036 .field public static int32 a01037 at b01037 .field private static int32 aALIGN101037 at bALIGN101037 .field public static int16 a01038 at b01038 .field private static int16 aALIGN101038 at bALIGN101038 .field private static int32 aALIGN201038 at bALIGN201038 .field public static int8 a01039 at b01039 .field private static int32 aALIGN101039 at bALIGN101039 .field private static int16 aALIGN201039 at bALIGN201039 .field private static int8 aALIGN201039 at bALIGN301039 .field public static int8 a01040 at b01040 .field private static int32 aALIGN101040 at bALIGN101040 .field private static int16 aALIGN201040 at bALIGN201040 .field private static int8 aALIGN201040 at bALIGN301040 .field public static int32 a01041 at b01041 .field private static int32 aALIGN101041 at bALIGN101041 .field public static int64 a01042 at b01042 .field public static int16 a01043 at b01043 .field private static int16 aALIGN101043 at bALIGN101043 .field private static int32 aALIGN201043 at bALIGN201043 .field public static int64 a01044 at b01044 .field public static int64 a01045 at b01045 .field public static float32 a01046 at b01046 .field private static int32 aALIGN101046 at bALIGN101046 .field public static int16 a01047 at b01047 .field private static int16 aALIGN101047 at bALIGN101047 .field private static int32 aALIGN201047 at bALIGN201047 .field public static int64 a01048 at b01048 .field public static int16 a01049 at b01049 .field private static int16 aALIGN101049 at bALIGN101049 .field private static int32 aALIGN201049 at bALIGN201049 .field public static int32 a01050 at b01050 .field private static int32 aALIGN101050 at bALIGN101050 .field public static int16 a01051 at b01051 .field private static int16 aALIGN101051 at bALIGN101051 .field private static int32 aALIGN201051 at bALIGN201051 .field public static int32 a01052 at b01052 .field private static int32 aALIGN101052 at bALIGN101052 .field public static int16 a01053 at b01053 .field private static int16 aALIGN101053 at bALIGN101053 .field private static int32 aALIGN201053 at bALIGN201053 .field public static float32 a01054 at b01054 .field private static int32 aALIGN101054 at bALIGN101054 .field public static int64 a01055 at b01055 .field public static float32 a01056 at b01056 .field private static int32 aALIGN101056 at bALIGN101056 .field public static int64 a01057 at b01057 .field public static int64 a01058 at b01058 .field public static int64 a01059 at b01059 .field public static int16 a01060 at b01060 .field private static int16 aALIGN101060 at bALIGN101060 .field private static int32 aALIGN201060 at bALIGN201060 .field public static int8 a01061 at b01061 .field private static int32 aALIGN101061 at bALIGN101061 .field private static int16 aALIGN201061 at bALIGN201061 .field private static int8 aALIGN201061 at bALIGN301061 .field public static int64 a01062 at b01062 .field public static int16 a01063 at b01063 .field private static int16 aALIGN101063 at bALIGN101063 .field private static int32 aALIGN201063 at bALIGN201063 .field public static int32 a01064 at b01064 .field private static int32 aALIGN101064 at bALIGN101064 .field public static int16 a01065 at b01065 .field private static int16 aALIGN101065 at bALIGN101065 .field private static int32 aALIGN201065 at bALIGN201065 .field public static int8 a01066 at b01066 .field private static int32 aALIGN101066 at bALIGN101066 .field private static int16 aALIGN201066 at bALIGN201066 .field private static int8 aALIGN201066 at bALIGN301066 .field public static int16 a01067 at b01067 .field private static int16 aALIGN101067 at bALIGN101067 .field private static int32 aALIGN201067 at bALIGN201067 .field public static int32 a01068 at b01068 .field private static int32 aALIGN101068 at bALIGN101068 .field public static float32 a01069 at b01069 .field private static int32 aALIGN101069 at bALIGN101069 .field public static float32 a01070 at b01070 .field private static int32 aALIGN101070 at bALIGN101070 .field public static int16 a01071 at b01071 .field private static int16 aALIGN101071 at bALIGN101071 .field private static int32 aALIGN201071 at bALIGN201071 .field public static float32 a01072 at b01072 .field private static int32 aALIGN101072 at bALIGN101072 .field public static int64 a01073 at b01073 .field public static int64 a01074 at b01074 .field public static int32 a01075 at b01075 .field private static int32 aALIGN101075 at bALIGN101075 .field public static int8 a01076 at b01076 .field private static int32 aALIGN101076 at bALIGN101076 .field private static int16 aALIGN201076 at bALIGN201076 .field private static int8 aALIGN201076 at bALIGN301076 .field public static int32 a01077 at b01077 .field private static int32 aALIGN101077 at bALIGN101077 .field public static int16 a01078 at b01078 .field private static int16 aALIGN101078 at bALIGN101078 .field private static int32 aALIGN201078 at bALIGN201078 .field public static float32 a01079 at b01079 .field private static int32 aALIGN101079 at bALIGN101079 .field public static float32 a01080 at b01080 .field private static int32 aALIGN101080 at bALIGN101080 .field public static float32 a01081 at b01081 .field private static int32 aALIGN101081 at bALIGN101081 .field public static int32 a01082 at b01082 .field private static int32 aALIGN101082 at bALIGN101082 .field public static int8 a01083 at b01083 .field private static int32 aALIGN101083 at bALIGN101083 .field private static int16 aALIGN201083 at bALIGN201083 .field private static int8 aALIGN201083 at bALIGN301083 .field public static int64 a01084 at b01084 .field public static int64 a01085 at b01085 .field public static int32 a01086 at b01086 .field private static int32 aALIGN101086 at bALIGN101086 .field public static int32 a01087 at b01087 .field private static int32 aALIGN101087 at bALIGN101087 .field public static int8 a01088 at b01088 .field private static int32 aALIGN101088 at bALIGN101088 .field private static int16 aALIGN201088 at bALIGN201088 .field private static int8 aALIGN201088 at bALIGN301088 .field public static int64 a01089 at b01089 .field public static int8 a01090 at b01090 .field private static int32 aALIGN101090 at bALIGN101090 .field private static int16 aALIGN201090 at bALIGN201090 .field private static int8 aALIGN201090 at bALIGN301090 .field public static int16 a01091 at b01091 .field private static int16 aALIGN101091 at bALIGN101091 .field private static int32 aALIGN201091 at bALIGN201091 .field public static float32 a01092 at b01092 .field private static int32 aALIGN101092 at bALIGN101092 .field public static int64 a01093 at b01093 .field public static int64 a01094 at b01094 .field public static int8 a01095 at b01095 .field private static int32 aALIGN101095 at bALIGN101095 .field private static int16 aALIGN201095 at bALIGN201095 .field private static int8 aALIGN201095 at bALIGN301095 .field public static float32 a01096 at b01096 .field private static int32 aALIGN101096 at bALIGN101096 .field public static int16 a01097 at b01097 .field private static int16 aALIGN101097 at bALIGN101097 .field private static int32 aALIGN201097 at bALIGN201097 .field public static float32 a01098 at b01098 .field private static int32 aALIGN101098 at bALIGN101098 .field public static int32 a01099 at b01099 .field private static int32 aALIGN101099 at bALIGN101099 .field public static int64 a010100 at b010100 .field public static int32 a010101 at b010101 .field private static int32 aALIGN1010101 at bALIGN1010101 .field public static float32 a010102 at b010102 .field private static int32 aALIGN1010102 at bALIGN1010102 .field public static int64 a010103 at b010103 .field public static int32 a010104 at b010104 .field private static int32 aALIGN1010104 at bALIGN1010104 .field public static int16 a010105 at b010105 .field private static int16 aALIGN1010105 at bALIGN1010105 .field private static int32 aALIGN2010105 at bALIGN2010105 .field public static int16 a010106 at b010106 .field private static int16 aALIGN1010106 at bALIGN1010106 .field private static int32 aALIGN2010106 at bALIGN2010106 .field public static float32 a010107 at b010107 .field private static int32 aALIGN1010107 at bALIGN1010107 .field public static int32 a010108 at b010108 .field private static int32 aALIGN1010108 at bALIGN1010108 .field public static int16 a010109 at b010109 .field private static int16 aALIGN1010109 at bALIGN1010109 .field private static int32 aALIGN2010109 at bALIGN2010109 .field public static int32 a010110 at b010110 .field private static int32 aALIGN1010110 at bALIGN1010110 .field public static int32 a010111 at b010111 .field private static int32 aALIGN1010111 at bALIGN1010111 .field public static int32 a010112 at b010112 .field private static int32 aALIGN1010112 at bALIGN1010112 .field public static int64 a010113 at b010113 .field public static int64 a010114 at b010114 .field public static int16 a010115 at b010115 .field private static int16 aALIGN1010115 at bALIGN1010115 .field private static int32 aALIGN2010115 at bALIGN2010115 .field public static int64 a010116 at b010116 .field public static int64 a010117 at b010117 .field public static int32 a010118 at b010118 .field private static int32 aALIGN1010118 at bALIGN1010118 .field public static int64 a010119 at b010119 .field public static int64 a010120 at b010120 .field public static int64 a010121 at b010121 .field public static int16 a010122 at b010122 .field private static int16 aALIGN1010122 at bALIGN1010122 .field private static int32 aALIGN2010122 at bALIGN2010122 .field public static int64 a010123 at b010123 .field public static int64 a010124 at b010124 .field public static int32 a010125 at b010125 .field private static int32 aALIGN1010125 at bALIGN1010125 .field public static int16 a010126 at b010126 .field private static int16 aALIGN1010126 at bALIGN1010126 .field private static int32 aALIGN2010126 at bALIGN2010126 .field public static int16 a010127 at b010127 .field private static int16 aALIGN1010127 at bALIGN1010127 .field private static int32 aALIGN2010127 at bALIGN2010127 } .data b0100 = int32(0) .data bALIGN10100 = int32(0) .data b0101 = int64(1) .data b0102 = float32(2.0) .data bALIGN10102 = int32(0) .data b0103 = int16(3) .data bALIGN10103 = int16(0) .data bALIGN20103 = int32(0) .data b0104 = int16(4) .data bALIGN10104 = int16(0) .data bALIGN20104 = int32(0) .data b0105 = int64(5) .data b0106 = int16(6) .data bALIGN10106 = int16(0) .data bALIGN20106 = int32(0) .data b0107 = int8(7) .data bALIGN10107 = int32(0) .data bALIGN20107 = int16(0) .data bALIGN30107 = int8(0) .data b0108 = int64(8) .data b0109 = int32(9) .data bALIGN10109 = int32(0) .data b01010 = int16(10) .data bALIGN101010 = int16(0) .data bALIGN201010 = int32(0) .data b01011 = float32(11.0) .data bALIGN101011 = int32(0) .data b01012 = int16(12) .data bALIGN101012 = int16(0) .data bALIGN201012 = int32(0) .data b01013 = float32(13.0) .data bALIGN101013 = int32(0) .data b01014 = float32(14.0) .data bALIGN101014 = int32(0) .data b01015 = int8(15) .data bALIGN101015 = int32(0) .data bALIGN201015 = int16(0) .data bALIGN301015 = int8(0) .data b01016 = float32(16.0) .data bALIGN101016 = int32(0) .data b01017 = int8(17) .data bALIGN101017 = int32(0) .data bALIGN201017 = int16(0) .data bALIGN301017 = int8(0) .data b01018 = float32(18.0) .data bALIGN101018 = int32(0) .data b01019 = float32(19.0) .data bALIGN101019 = int32(0) .data b01020 = int8(20) .data bALIGN101020 = int32(0) .data bALIGN201020 = int16(0) .data bALIGN301020 = int8(0) .data b01021 = float32(21.0) .data bALIGN101021 = int32(0) .data b01022 = int64(22) .data b01023 = int8(23) .data bALIGN101023 = int32(0) .data bALIGN201023 = int16(0) .data bALIGN301023 = int8(0) .data b01024 = int32(24) .data bALIGN101024 = int32(0) .data b01025 = int64(25) .data b01026 = int16(26) .data bALIGN101026 = int16(0) .data bALIGN201026 = int32(0) .data b01027 = int8(27) .data bALIGN101027 = int32(0) .data bALIGN201027 = int16(0) .data bALIGN301027 = int8(0) .data b01028 = int16(28) .data bALIGN101028 = int16(0) .data bALIGN201028 = int32(0) .data b01029 = int16(29) .data bALIGN101029 = int16(0) .data bALIGN201029 = int32(0) .data b01030 = int8(30) .data bALIGN101030 = int32(0) .data bALIGN201030 = int16(0) .data bALIGN301030 = int8(0) .data b01031 = int8(31) .data bALIGN101031 = int32(0) .data bALIGN201031 = int16(0) .data bALIGN301031 = int8(0) .data b01032 = int64(32) .data b01033 = float32(33.0) .data bALIGN101033 = int32(0) .data b01034 = int16(34) .data bALIGN101034 = int16(0) .data bALIGN201034 = int32(0) .data b01035 = int8(35) .data bALIGN101035 = int32(0) .data bALIGN201035 = int16(0) .data bALIGN301035 = int8(0) .data b01036 = int8(36) .data bALIGN101036 = int32(0) .data bALIGN201036 = int16(0) .data bALIGN301036 = int8(0) .data b01037 = int32(37) .data bALIGN101037 = int32(0) .data b01038 = int16(38) .data bALIGN101038 = int16(0) .data bALIGN201038 = int32(0) .data b01039 = int8(39) .data bALIGN101039 = int32(0) .data bALIGN201039 = int16(0) .data bALIGN301039 = int8(0) .data b01040 = int8(40) .data bALIGN101040 = int32(0) .data bALIGN201040 = int16(0) .data bALIGN301040 = int8(0) .data b01041 = int32(41) .data bALIGN101041 = int32(0) .data b01042 = int64(42) .data b01043 = int16(43) .data bALIGN101043 = int16(0) .data bALIGN201043 = int32(0) .data b01044 = int64(44) .data b01045 = int64(45) .data b01046 = float32(46.0) .data bALIGN101046 = int32(0) .data b01047 = int16(47) .data bALIGN101047 = int16(0) .data bALIGN201047 = int32(0) .data b01048 = int64(48) .data b01049 = int16(49) .data bALIGN101049 = int16(0) .data bALIGN201049 = int32(0) .data b01050 = int32(50) .data bALIGN101050 = int32(0) .data b01051 = int16(51) .data bALIGN101051 = int16(0) .data bALIGN201051 = int32(0) .data b01052 = int32(52) .data bALIGN101052 = int32(0) .data b01053 = int16(53) .data bALIGN101053 = int16(0) .data bALIGN201053 = int32(0) .data b01054 = float32(54.0) .data bALIGN101054 = int32(0) .data b01055 = int64(55) .data b01056 = float32(56.0) .data bALIGN101056 = int32(0) .data b01057 = int64(57) .data b01058 = int64(58) .data b01059 = int64(59) .data b01060 = int16(60) .data bALIGN101060 = int16(0) .data bALIGN201060 = int32(0) .data b01061 = int8(61) .data bALIGN101061 = int32(0) .data bALIGN201061 = int16(0) .data bALIGN301061 = int8(0) .data b01062 = int64(62) .data b01063 = int16(63) .data bALIGN101063 = int16(0) .data bALIGN201063 = int32(0) .data b01064 = int32(64) .data bALIGN101064 = int32(0) .data b01065 = int16(65) .data bALIGN101065 = int16(0) .data bALIGN201065 = int32(0) .data b01066 = int8(66) .data bALIGN101066 = int32(0) .data bALIGN201066 = int16(0) .data bALIGN301066 = int8(0) .data b01067 = int16(67) .data bALIGN101067 = int16(0) .data bALIGN201067 = int32(0) .data b01068 = int32(68) .data bALIGN101068 = int32(0) .data b01069 = float32(69.0) .data bALIGN101069 = int32(0) .data b01070 = float32(70.0) .data bALIGN101070 = int32(0) .data b01071 = int16(71) .data bALIGN101071 = int16(0) .data bALIGN201071 = int32(0) .data b01072 = float32(72.0) .data bALIGN101072 = int32(0) .data b01073 = int64(73) .data b01074 = int64(74) .data b01075 = int32(75) .data bALIGN101075 = int32(0) .data b01076 = int8(76) .data bALIGN101076 = int32(0) .data bALIGN201076 = int16(0) .data bALIGN301076 = int8(0) .data b01077 = int32(77) .data bALIGN101077 = int32(0) .data b01078 = int16(78) .data bALIGN101078 = int16(0) .data bALIGN201078 = int32(0) .data b01079 = float32(79.0) .data bALIGN101079 = int32(0) .data b01080 = float32(80.0) .data bALIGN101080 = int32(0) .data b01081 = float32(81.0) .data bALIGN101081 = int32(0) .data b01082 = int32(82) .data bALIGN101082 = int32(0) .data b01083 = int8(83) .data bALIGN101083 = int32(0) .data bALIGN201083 = int16(0) .data bALIGN301083 = int8(0) .data b01084 = int64(84) .data b01085 = int64(85) .data b01086 = int32(86) .data bALIGN101086 = int32(0) .data b01087 = int32(87) .data bALIGN101087 = int32(0) .data b01088 = int8(88) .data bALIGN101088 = int32(0) .data bALIGN201088 = int16(0) .data bALIGN301088 = int8(0) .data b01089 = int64(89) .data b01090 = int8(90) .data bALIGN101090 = int32(0) .data bALIGN201090 = int16(0) .data bALIGN301090 = int8(0) .data b01091 = int16(91) .data bALIGN101091 = int16(0) .data bALIGN201091 = int32(0) .data b01092 = float32(92.0) .data bALIGN101092 = int32(0) .data b01093 = int64(93) .data b01094 = int64(94) .data b01095 = int8(95) .data bALIGN101095 = int32(0) .data bALIGN201095 = int16(0) .data bALIGN301095 = int8(0) .data b01096 = float32(96.0) .data bALIGN101096 = int32(0) .data b01097 = int16(97) .data bALIGN101097 = int16(0) .data bALIGN201097 = int32(0) .data b01098 = float32(98.0) .data bALIGN101098 = int32(0) .data b01099 = int32(99) .data bALIGN101099 = int32(0) .data b010100 = int64(100) .data b010101 = int32(101) .data bALIGN1010101 = int32(0) .data b010102 = float32(102.0) .data bALIGN1010102 = int32(0) .data b010103 = int64(103) .data b010104 = int32(104) .data bALIGN1010104 = int32(0) .data b010105 = int16(105) .data bALIGN1010105 = int16(0) .data bALIGN2010105 = int32(0) .data b010106 = int16(106) .data bALIGN1010106 = int16(0) .data bALIGN2010106 = int32(0) .data b010107 = float32(107.0) .data bALIGN1010107 = int32(0) .data b010108 = int32(108) .data bALIGN1010108 = int32(0) .data b010109 = int16(109) .data bALIGN1010109 = int16(0) .data bALIGN2010109 = int32(0) .data b010110 = int32(110) .data bALIGN1010110 = int32(0) .data b010111 = int32(111) .data bALIGN1010111 = int32(0) .data b010112 = int32(112) .data bALIGN1010112 = int32(0) .data b010113 = int64(113) .data b010114 = int64(114) .data b010115 = int16(115) .data bALIGN1010115 = int16(0) .data bALIGN2010115 = int32(0) .data b010116 = int64(116) .data b010117 = int64(117) .data b010118 = int32(118) .data bALIGN1010118 = int32(0) .data b010119 = int64(119) .data b010120 = int64(120) .data b010121 = int64(121) .data b010122 = int16(122) .data bALIGN1010122 = int16(0) .data bALIGN2010122 = int32(0) .data b010123 = int64(123) .data b010124 = int64(124) .data b010125 = int32(125) .data bALIGN1010125 = int32(0) .data b010126 = int16(126) .data bALIGN1010126 = int16(0) .data bALIGN2010126 = int32(0) .data b010127 = int16(127) .data bALIGN1010127 = int16(0) .data bALIGN2010127 = int32(0)
.assembly extern mscorlib{} .assembly extern xunit.core {} .assembly rvastatic4{} .class public A{ .method static native int Call1(int64) {.maxstack 50 ldarg.0 conv.i8 dup dup xor xor conv.i conv.i ret } .method static native int Call2(float64) {.maxstack 50 ldarg.0 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i conv.i8 ldc.i4 32 shl or conv.i conv.i ret } .method static void V1() {.maxstack 50 ldsfld int32 [rvastatic4]A::a0100 ldc.i4 0 beq a0101 newobj instance void [mscorlib]System.Exception::.ctor() throw a0101: ldsfld int64 [rvastatic4]A::a0101 ldc.i8 1 beq a0102 newobj instance void [mscorlib]System.Exception::.ctor() throw a0102: ldsfld float32 [rvastatic4]A::a0102 ldc.r4 2.0 beq a0103 newobj instance void [mscorlib]System.Exception::.ctor() throw a0103: ldsfld int16 [rvastatic4]A::a0103 ldc.i4 3 beq a0104 newobj instance void [mscorlib]System.Exception::.ctor() throw a0104: ldsfld int16 [rvastatic4]A::a0104 ldc.i4 4 beq a0105 newobj instance void [mscorlib]System.Exception::.ctor() throw a0105: ldsfld int64 [rvastatic4]A::a0105 ldc.i8 5 beq a0106 newobj instance void [mscorlib]System.Exception::.ctor() throw a0106: ldsfld int16 [rvastatic4]A::a0106 ldc.i4 6 beq a0107 newobj instance void [mscorlib]System.Exception::.ctor() throw a0107: ldsfld int8 [rvastatic4]A::a0107 ldc.i4 7 beq a0108 newobj instance void [mscorlib]System.Exception::.ctor() throw a0108: ldsfld int64 [rvastatic4]A::a0108 ldc.i8 8 beq a0109 newobj instance void [mscorlib]System.Exception::.ctor() throw a0109: ldsfld int32 [rvastatic4]A::a0109 ldc.i4 9 beq a01010 newobj instance void [mscorlib]System.Exception::.ctor() throw a01010: ldsfld int16 [rvastatic4]A::a01010 ldc.i4 10 beq a01011 newobj instance void [mscorlib]System.Exception::.ctor() throw a01011: ldsfld float32 [rvastatic4]A::a01011 ldc.r4 11.0 beq a01012 newobj instance void [mscorlib]System.Exception::.ctor() throw a01012: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a01013 newobj instance void [mscorlib]System.Exception::.ctor() throw a01013: ldsfld float32 [rvastatic4]A::a01013 ldc.r4 13.0 beq a01014 newobj instance void [mscorlib]System.Exception::.ctor() throw a01014: ldsfld float32 [rvastatic4]A::a01014 ldc.r4 14.0 beq a01015 newobj instance void [mscorlib]System.Exception::.ctor() throw a01015: ldsfld int8 [rvastatic4]A::a01015 ldc.i4 15 beq a01016 newobj instance void [mscorlib]System.Exception::.ctor() throw a01016: ldsfld float32 [rvastatic4]A::a01016 ldc.r4 16.0 beq a01017 newobj instance void [mscorlib]System.Exception::.ctor() throw a01017: ldsfld int8 [rvastatic4]A::a01017 ldc.i4 17 beq a01018 newobj instance void [mscorlib]System.Exception::.ctor() throw a01018: ldsfld float32 [rvastatic4]A::a01018 ldc.r4 18.0 beq a01019 newobj instance void [mscorlib]System.Exception::.ctor() throw a01019: ldsfld float32 [rvastatic4]A::a01019 ldc.r4 19.0 beq a01020 newobj instance void [mscorlib]System.Exception::.ctor() throw a01020: ldsfld int8 [rvastatic4]A::a01020 ldc.i4 20 beq a01021 newobj instance void [mscorlib]System.Exception::.ctor() throw a01021: ldsfld float32 [rvastatic4]A::a01021 ldc.r4 21.0 beq a01022 newobj instance void [mscorlib]System.Exception::.ctor() throw a01022: ldsfld int64 [rvastatic4]A::a01022 ldc.i8 22 beq a01023 newobj instance void [mscorlib]System.Exception::.ctor() throw a01023: ldsfld int8 [rvastatic4]A::a01023 ldc.i4 23 beq a01024 newobj instance void [mscorlib]System.Exception::.ctor() throw a01024: ldsfld int32 [rvastatic4]A::a01024 ldc.i4 24 beq a01025 newobj instance void [mscorlib]System.Exception::.ctor() throw a01025: ldsfld int64 [rvastatic4]A::a01025 ldc.i8 25 beq a01026 newobj instance void [mscorlib]System.Exception::.ctor() throw a01026: ldsfld int16 [rvastatic4]A::a01026 ldc.i4 26 beq a01027 newobj instance void [mscorlib]System.Exception::.ctor() throw a01027: ldsfld int8 [rvastatic4]A::a01027 ldc.i4 27 beq a01028 newobj instance void [mscorlib]System.Exception::.ctor() throw a01028: ldsfld int16 [rvastatic4]A::a01028 ldc.i4 28 beq a01029 newobj instance void [mscorlib]System.Exception::.ctor() throw a01029: ldsfld int16 [rvastatic4]A::a01029 ldc.i4 29 beq a01030 newobj instance void [mscorlib]System.Exception::.ctor() throw a01030: ldsfld int8 [rvastatic4]A::a01030 ldc.i4 30 beq a01031 newobj instance void [mscorlib]System.Exception::.ctor() throw a01031: ldsfld int8 [rvastatic4]A::a01031 ldc.i4 31 beq a01032 newobj instance void [mscorlib]System.Exception::.ctor() throw a01032: ldsfld int64 [rvastatic4]A::a01032 ldc.i8 32 beq a01033 newobj instance void [mscorlib]System.Exception::.ctor() throw a01033: ldsfld float32 [rvastatic4]A::a01033 ldc.r4 33.0 beq a01034 newobj instance void [mscorlib]System.Exception::.ctor() throw a01034: ldsfld int16 [rvastatic4]A::a01034 ldc.i4 34 beq a01035 newobj instance void [mscorlib]System.Exception::.ctor() throw a01035: ldsfld int8 [rvastatic4]A::a01035 ldc.i4 35 beq a01036 newobj instance void [mscorlib]System.Exception::.ctor() throw a01036: ldsfld int8 [rvastatic4]A::a01036 ldc.i4 36 beq a01037 newobj instance void [mscorlib]System.Exception::.ctor() throw a01037: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a01038 newobj instance void [mscorlib]System.Exception::.ctor() throw a01038: ldsfld int16 [rvastatic4]A::a01038 ldc.i4 38 beq a01039 newobj instance void [mscorlib]System.Exception::.ctor() throw a01039: ldsfld int8 [rvastatic4]A::a01039 ldc.i4 39 beq a01040 newobj instance void [mscorlib]System.Exception::.ctor() throw a01040: ldsfld int8 [rvastatic4]A::a01040 ldc.i4 40 beq a01041 newobj instance void [mscorlib]System.Exception::.ctor() throw a01041: ldsfld int32 [rvastatic4]A::a01041 ldc.i4 41 beq a01042 newobj instance void [mscorlib]System.Exception::.ctor() throw a01042: ldsfld int64 [rvastatic4]A::a01042 ldc.i8 42 beq a01043 newobj instance void [mscorlib]System.Exception::.ctor() throw a01043: ldsfld int16 [rvastatic4]A::a01043 ldc.i4 43 beq a01044 newobj instance void [mscorlib]System.Exception::.ctor() throw a01044: ldsfld int64 [rvastatic4]A::a01044 ldc.i8 44 beq a01045 newobj instance void [mscorlib]System.Exception::.ctor() throw a01045: ldsfld int64 [rvastatic4]A::a01045 ldc.i8 45 beq a01046 newobj instance void [mscorlib]System.Exception::.ctor() throw a01046: ldsfld float32 [rvastatic4]A::a01046 ldc.r4 46.0 beq a01047 newobj instance void [mscorlib]System.Exception::.ctor() throw a01047: ldsfld int16 [rvastatic4]A::a01047 ldc.i4 47 beq a01048 newobj instance void [mscorlib]System.Exception::.ctor() throw a01048: ldsfld int64 [rvastatic4]A::a01048 ldc.i8 48 beq a01049 newobj instance void [mscorlib]System.Exception::.ctor() throw a01049: ldsfld int16 [rvastatic4]A::a01049 ldc.i4 49 beq a01050 newobj instance void [mscorlib]System.Exception::.ctor() throw a01050: ldsfld int32 [rvastatic4]A::a01050 ldc.i4 50 beq a01051 newobj instance void [mscorlib]System.Exception::.ctor() throw a01051: ldsfld int16 [rvastatic4]A::a01051 ldc.i4 51 beq a01052 newobj instance void [mscorlib]System.Exception::.ctor() throw a01052: ldsfld int32 [rvastatic4]A::a01052 ldc.i4 52 beq a01053 newobj instance void [mscorlib]System.Exception::.ctor() throw a01053: ldsfld int16 [rvastatic4]A::a01053 ldc.i4 53 beq a01054 newobj instance void [mscorlib]System.Exception::.ctor() throw a01054: ldsfld float32 [rvastatic4]A::a01054 ldc.r4 54.0 beq a01055 newobj instance void [mscorlib]System.Exception::.ctor() throw a01055: ldsfld int64 [rvastatic4]A::a01055 ldc.i8 55 beq a01056 newobj instance void [mscorlib]System.Exception::.ctor() throw a01056: ldsfld float32 [rvastatic4]A::a01056 ldc.r4 56.0 beq a01057 newobj instance void [mscorlib]System.Exception::.ctor() throw a01057: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 57 beq a01058 newobj instance void [mscorlib]System.Exception::.ctor() throw a01058: ldsfld int64 [rvastatic4]A::a01058 ldc.i8 58 beq a01059 newobj instance void [mscorlib]System.Exception::.ctor() throw a01059: ldsfld int64 [rvastatic4]A::a01059 ldc.i8 59 beq a01060 newobj instance void [mscorlib]System.Exception::.ctor() throw a01060: ldsfld int16 [rvastatic4]A::a01060 ldc.i4 60 beq a01061 newobj instance void [mscorlib]System.Exception::.ctor() throw a01061: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 61 beq a01062 newobj instance void [mscorlib]System.Exception::.ctor() throw a01062: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a01063 newobj instance void [mscorlib]System.Exception::.ctor() throw a01063: ldsfld int16 [rvastatic4]A::a01063 ldc.i4 63 beq a01064 newobj instance void [mscorlib]System.Exception::.ctor() throw a01064: ldsfld int32 [rvastatic4]A::a01064 ldc.i4 64 beq a01065 newobj instance void [mscorlib]System.Exception::.ctor() throw a01065: ldsfld int16 [rvastatic4]A::a01065 ldc.i4 65 beq a01066 newobj instance void [mscorlib]System.Exception::.ctor() throw a01066: ldsfld int8 [rvastatic4]A::a01066 ldc.i4 66 beq a01067 newobj instance void [mscorlib]System.Exception::.ctor() throw a01067: ldsfld int16 [rvastatic4]A::a01067 ldc.i4 67 beq a01068 newobj instance void [mscorlib]System.Exception::.ctor() throw a01068: ldsfld int32 [rvastatic4]A::a01068 ldc.i4 68 beq a01069 newobj instance void [mscorlib]System.Exception::.ctor() throw a01069: ldsfld float32 [rvastatic4]A::a01069 ldc.r4 69.0 beq a01070 newobj instance void [mscorlib]System.Exception::.ctor() throw a01070: ldsfld float32 [rvastatic4]A::a01070 ldc.r4 70.0 beq a01071 newobj instance void [mscorlib]System.Exception::.ctor() throw a01071: ldsfld int16 [rvastatic4]A::a01071 ldc.i4 71 beq a01072 newobj instance void [mscorlib]System.Exception::.ctor() throw a01072: ldsfld float32 [rvastatic4]A::a01072 ldc.r4 72.0 beq a01073 newobj instance void [mscorlib]System.Exception::.ctor() throw a01073: ldsfld int64 [rvastatic4]A::a01073 ldc.i8 73 beq a01074 newobj instance void [mscorlib]System.Exception::.ctor() throw a01074: ldsfld int64 [rvastatic4]A::a01074 ldc.i8 74 beq a01075 newobj instance void [mscorlib]System.Exception::.ctor() throw a01075: ldsfld int32 [rvastatic4]A::a01075 ldc.i4 75 beq a01076 newobj instance void [mscorlib]System.Exception::.ctor() throw a01076: ldsfld int8 [rvastatic4]A::a01076 ldc.i4 76 beq a01077 newobj instance void [mscorlib]System.Exception::.ctor() throw a01077: ldsfld int32 [rvastatic4]A::a01077 ldc.i4 77 beq a01078 newobj instance void [mscorlib]System.Exception::.ctor() throw a01078: ldsfld int16 [rvastatic4]A::a01078 ldc.i4 78 beq a01079 newobj instance void [mscorlib]System.Exception::.ctor() throw a01079: ldsfld float32 [rvastatic4]A::a01079 ldc.r4 79.0 beq a01080 newobj instance void [mscorlib]System.Exception::.ctor() throw a01080: ldsfld float32 [rvastatic4]A::a01080 ldc.r4 80.0 beq a01081 newobj instance void [mscorlib]System.Exception::.ctor() throw a01081: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 81.0 beq a01082 newobj instance void [mscorlib]System.Exception::.ctor() throw a01082: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 82 beq a01083 newobj instance void [mscorlib]System.Exception::.ctor() throw a01083: ldsfld int8 [rvastatic4]A::a01083 ldc.i4 83 beq a01084 newobj instance void [mscorlib]System.Exception::.ctor() throw a01084: ldsfld int64 [rvastatic4]A::a01084 ldc.i8 84 beq a01085 newobj instance void [mscorlib]System.Exception::.ctor() throw a01085: ldsfld int64 [rvastatic4]A::a01085 ldc.i8 85 beq a01086 newobj instance void [mscorlib]System.Exception::.ctor() throw a01086: ldsfld int32 [rvastatic4]A::a01086 ldc.i4 86 beq a01087 newobj instance void [mscorlib]System.Exception::.ctor() throw a01087: ldsfld int32 [rvastatic4]A::a01087 ldc.i4 87 beq a01088 newobj instance void [mscorlib]System.Exception::.ctor() throw a01088: ldsfld int8 [rvastatic4]A::a01088 ldc.i4 88 beq a01089 newobj instance void [mscorlib]System.Exception::.ctor() throw a01089: ldsfld int64 [rvastatic4]A::a01089 ldc.i8 89 beq a01090 newobj instance void [mscorlib]System.Exception::.ctor() throw a01090: ldsfld int8 [rvastatic4]A::a01090 ldc.i4 90 beq a01091 newobj instance void [mscorlib]System.Exception::.ctor() throw a01091: ldsfld int16 [rvastatic4]A::a01091 ldc.i4 91 beq a01092 newobj instance void [mscorlib]System.Exception::.ctor() throw a01092: ldsfld float32 [rvastatic4]A::a01092 ldc.r4 92.0 beq a01093 newobj instance void [mscorlib]System.Exception::.ctor() throw a01093: ldsfld int64 [rvastatic4]A::a01093 ldc.i8 93 beq a01094 newobj instance void [mscorlib]System.Exception::.ctor() throw a01094: ldsfld int64 [rvastatic4]A::a01094 ldc.i8 94 beq a01095 newobj instance void [mscorlib]System.Exception::.ctor() throw a01095: ldsfld int8 [rvastatic4]A::a01095 ldc.i4 95 beq a01096 newobj instance void [mscorlib]System.Exception::.ctor() throw a01096: ldsfld float32 [rvastatic4]A::a01096 ldc.r4 96.0 beq a01097 newobj instance void [mscorlib]System.Exception::.ctor() throw a01097: ldsfld int16 [rvastatic4]A::a01097 ldc.i4 97 beq a01098 newobj instance void [mscorlib]System.Exception::.ctor() throw a01098: ldsfld float32 [rvastatic4]A::a01098 ldc.r4 98.0 beq a01099 newobj instance void [mscorlib]System.Exception::.ctor() throw a01099: ldsfld int32 [rvastatic4]A::a01099 ldc.i4 99 beq a010100 newobj instance void [mscorlib]System.Exception::.ctor() throw a010100: ldsfld int64 [rvastatic4]A::a010100 ldc.i8 100 beq a010101 newobj instance void [mscorlib]System.Exception::.ctor() throw a010101: ldsfld int32 [rvastatic4]A::a010101 ldc.i4 101 beq a010102 newobj instance void [mscorlib]System.Exception::.ctor() throw a010102: ldsfld float32 [rvastatic4]A::a010102 ldc.r4 102.0 beq a010103 newobj instance void [mscorlib]System.Exception::.ctor() throw a010103: ldsfld int64 [rvastatic4]A::a010103 ldc.i8 103 beq a010104 newobj instance void [mscorlib]System.Exception::.ctor() throw a010104: ldsfld int32 [rvastatic4]A::a010104 ldc.i4 104 beq a010105 newobj instance void [mscorlib]System.Exception::.ctor() throw a010105: ldsfld int16 [rvastatic4]A::a010105 ldc.i4 105 beq a010106 newobj instance void [mscorlib]System.Exception::.ctor() throw a010106: ldsfld int16 [rvastatic4]A::a010106 ldc.i4 106 beq a010107 newobj instance void [mscorlib]System.Exception::.ctor() throw a010107: ldsfld float32 [rvastatic4]A::a010107 ldc.r4 107.0 beq a010108 newobj instance void [mscorlib]System.Exception::.ctor() throw a010108: ldsfld int32 [rvastatic4]A::a010108 ldc.i4 108 beq a010109 newobj instance void [mscorlib]System.Exception::.ctor() throw a010109: ldsfld int16 [rvastatic4]A::a010109 ldc.i4 109 beq a010110 newobj instance void [mscorlib]System.Exception::.ctor() throw a010110: ldsfld int32 [rvastatic4]A::a010110 ldc.i4 110 beq a010111 newobj instance void [mscorlib]System.Exception::.ctor() throw a010111: ldsfld int32 [rvastatic4]A::a010111 ldc.i4 111 beq a010112 newobj instance void [mscorlib]System.Exception::.ctor() throw a010112: ldsfld int32 [rvastatic4]A::a010112 ldc.i4 112 beq a010113 newobj instance void [mscorlib]System.Exception::.ctor() throw a010113: ldsfld int64 [rvastatic4]A::a010113 ldc.i8 113 beq a010114 newobj instance void [mscorlib]System.Exception::.ctor() throw a010114: ldsfld int64 [rvastatic4]A::a010114 ldc.i8 114 beq a010115 newobj instance void [mscorlib]System.Exception::.ctor() throw a010115: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 115 beq a010116 newobj instance void [mscorlib]System.Exception::.ctor() throw a010116: ldsfld int64 [rvastatic4]A::a010116 ldc.i8 116 beq a010117 newobj instance void [mscorlib]System.Exception::.ctor() throw a010117: ldsfld int64 [rvastatic4]A::a010117 ldc.i8 117 beq a010118 newobj instance void [mscorlib]System.Exception::.ctor() throw a010118: ldsfld int32 [rvastatic4]A::a010118 ldc.i4 118 beq a010119 newobj instance void [mscorlib]System.Exception::.ctor() throw a010119: ldsfld int64 [rvastatic4]A::a010119 ldc.i8 119 beq a010120 newobj instance void [mscorlib]System.Exception::.ctor() throw a010120: ldsfld int64 [rvastatic4]A::a010120 ldc.i8 120 beq a010121 newobj instance void [mscorlib]System.Exception::.ctor() throw a010121: ldsfld int64 [rvastatic4]A::a010121 ldc.i8 121 beq a010122 newobj instance void [mscorlib]System.Exception::.ctor() throw a010122: ldsfld int16 [rvastatic4]A::a010122 ldc.i4 122 beq a010123 newobj instance void [mscorlib]System.Exception::.ctor() throw a010123: ldsfld int64 [rvastatic4]A::a010123 ldc.i8 123 beq a010124 newobj instance void [mscorlib]System.Exception::.ctor() throw a010124: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 124 beq a010125 newobj instance void [mscorlib]System.Exception::.ctor() throw a010125: ldsfld int32 [rvastatic4]A::a010125 ldc.i4 125 beq a010126 newobj instance void [mscorlib]System.Exception::.ctor() throw a010126: ldsfld int16 [rvastatic4]A::a010126 ldc.i4 126 beq a010127 newobj instance void [mscorlib]System.Exception::.ctor() throw a010127: ldsfld int16 [rvastatic4]A::a010127 ldc.i4 127 beq a010128 newobj instance void [mscorlib]System.Exception::.ctor() throw a010128: ret} .method static void V2() {.maxstack 50 ldsflda int32 [rvastatic4]A::a0100 ldind.i4 ldc.i4 0 beq a0100 newobj instance void [mscorlib]System.Exception::.ctor() throw a0100: ldsflda int64 [rvastatic4]A::a0101 ldind.i8 ldc.i8 1 beq a0101 newobj instance void [mscorlib]System.Exception::.ctor() throw a0101: ldsflda float32 [rvastatic4]A::a0102 ldind.r4 ldc.r4 2.0 beq a0102 newobj instance void [mscorlib]System.Exception::.ctor() throw a0102: ldsflda int16 [rvastatic4]A::a0103 ldind.i2 ldc.i4 3 beq a0103 newobj instance void [mscorlib]System.Exception::.ctor() throw a0103: ldsflda int16 [rvastatic4]A::a0104 ldind.i2 ldc.i4 4 beq a0104 newobj instance void [mscorlib]System.Exception::.ctor() throw a0104: ldsflda int64 [rvastatic4]A::a0105 ldind.i8 ldc.i8 5 beq a0105 newobj instance void [mscorlib]System.Exception::.ctor() throw a0105: ldsflda int16 [rvastatic4]A::a0106 ldind.i2 ldc.i4 6 beq a0106 newobj instance void [mscorlib]System.Exception::.ctor() throw a0106: ldsflda int8 [rvastatic4]A::a0107 ldind.i1 ldc.i4 7 beq a0107 newobj instance void [mscorlib]System.Exception::.ctor() throw a0107: ldsflda int64 [rvastatic4]A::a0108 ldind.i8 ldc.i8 8 beq a0108 newobj instance void [mscorlib]System.Exception::.ctor() throw a0108: ldsflda int32 [rvastatic4]A::a0109 ldind.i4 ldc.i4 9 beq a0109 newobj instance void [mscorlib]System.Exception::.ctor() throw a0109: ldsflda int16 [rvastatic4]A::a01010 ldind.i2 ldc.i4 10 beq a01010 newobj instance void [mscorlib]System.Exception::.ctor() throw a01010: ldsflda float32 [rvastatic4]A::a01011 ldind.r4 ldc.r4 11.0 beq a01011 newobj instance void [mscorlib]System.Exception::.ctor() throw a01011: ldsflda int16 [rvastatic4]A::a01012 ldind.i2 ldc.i4 12 beq a01012 newobj instance void [mscorlib]System.Exception::.ctor() throw a01012: ldsflda float32 [rvastatic4]A::a01013 ldind.r4 ldc.r4 13.0 beq a01013 newobj instance void [mscorlib]System.Exception::.ctor() throw a01013: ldsflda float32 [rvastatic4]A::a01014 ldind.r4 ldc.r4 14.0 beq a01014 newobj instance void [mscorlib]System.Exception::.ctor() throw a01014: ldsflda int8 [rvastatic4]A::a01015 ldind.i1 ldc.i4 15 beq a01015 newobj instance void [mscorlib]System.Exception::.ctor() throw a01015: ldsflda float32 [rvastatic4]A::a01016 ldind.r4 ldc.r4 16.0 beq a01016 newobj instance void [mscorlib]System.Exception::.ctor() throw a01016: ldsflda int8 [rvastatic4]A::a01017 ldind.i1 ldc.i4 17 beq a01017 newobj instance void [mscorlib]System.Exception::.ctor() throw a01017: ldsflda float32 [rvastatic4]A::a01018 ldind.r4 ldc.r4 18.0 beq a01018 newobj instance void [mscorlib]System.Exception::.ctor() throw a01018: ldsflda float32 [rvastatic4]A::a01019 ldind.r4 ldc.r4 19.0 beq a01019 newobj instance void [mscorlib]System.Exception::.ctor() throw a01019: ldsflda int8 [rvastatic4]A::a01020 ldind.i1 ldc.i4 20 beq a01020 newobj instance void [mscorlib]System.Exception::.ctor() throw a01020: ldsflda float32 [rvastatic4]A::a01021 ldind.r4 ldc.r4 21.0 beq a01021 newobj instance void [mscorlib]System.Exception::.ctor() throw a01021: ldsflda int64 [rvastatic4]A::a01022 ldind.i8 ldc.i8 22 beq a01022 newobj instance void [mscorlib]System.Exception::.ctor() throw a01022: ldsflda int8 [rvastatic4]A::a01023 ldind.i1 ldc.i4 23 beq a01023 newobj instance void [mscorlib]System.Exception::.ctor() throw a01023: ldsflda int32 [rvastatic4]A::a01024 ldind.i4 ldc.i4 24 beq a01024 newobj instance void [mscorlib]System.Exception::.ctor() throw a01024: ldsflda int64 [rvastatic4]A::a01025 ldind.i8 ldc.i8 25 beq a01025 newobj instance void [mscorlib]System.Exception::.ctor() throw a01025: ldsflda int16 [rvastatic4]A::a01026 ldind.i2 ldc.i4 26 beq a01026 newobj instance void [mscorlib]System.Exception::.ctor() throw a01026: ldsflda int8 [rvastatic4]A::a01027 ldind.i1 ldc.i4 27 beq a01027 newobj instance void [mscorlib]System.Exception::.ctor() throw a01027: ldsflda int16 [rvastatic4]A::a01028 ldind.i2 ldc.i4 28 beq a01028 newobj instance void [mscorlib]System.Exception::.ctor() throw a01028: ldsflda int16 [rvastatic4]A::a01029 ldind.i2 ldc.i4 29 beq a01029 newobj instance void [mscorlib]System.Exception::.ctor() throw a01029: ldsflda int8 [rvastatic4]A::a01030 ldind.i1 ldc.i4 30 beq a01030 newobj instance void [mscorlib]System.Exception::.ctor() throw a01030: ldsflda int8 [rvastatic4]A::a01031 ldind.i1 ldc.i4 31 beq a01031 newobj instance void [mscorlib]System.Exception::.ctor() throw a01031: ldsflda int64 [rvastatic4]A::a01032 ldind.i8 ldc.i8 32 beq a01032 newobj instance void [mscorlib]System.Exception::.ctor() throw a01032: ldsflda float32 [rvastatic4]A::a01033 ldind.r4 ldc.r4 33.0 beq a01033 newobj instance void [mscorlib]System.Exception::.ctor() throw a01033: ldsflda int16 [rvastatic4]A::a01034 ldind.i2 ldc.i4 34 beq a01034 newobj instance void [mscorlib]System.Exception::.ctor() throw a01034: ldsflda int8 [rvastatic4]A::a01035 ldind.i1 ldc.i4 35 beq a01035 newobj instance void [mscorlib]System.Exception::.ctor() throw a01035: ldsflda int8 [rvastatic4]A::a01036 ldind.i1 ldc.i4 36 beq a01036 newobj instance void [mscorlib]System.Exception::.ctor() throw a01036: ldsflda int32 [rvastatic4]A::a01037 ldind.i4 ldc.i4 37 beq a01037 newobj instance void [mscorlib]System.Exception::.ctor() throw a01037: ldsflda int16 [rvastatic4]A::a01038 ldind.i2 ldc.i4 38 beq a01038 newobj instance void [mscorlib]System.Exception::.ctor() throw a01038: ldsflda int8 [rvastatic4]A::a01039 ldind.i1 ldc.i4 39 beq a01039 newobj instance void [mscorlib]System.Exception::.ctor() throw a01039: ldsflda int8 [rvastatic4]A::a01040 ldind.i1 ldc.i4 40 beq a01040 newobj instance void [mscorlib]System.Exception::.ctor() throw a01040: ldsflda int32 [rvastatic4]A::a01041 ldind.i4 ldc.i4 41 beq a01041 newobj instance void [mscorlib]System.Exception::.ctor() throw a01041: ldsflda int64 [rvastatic4]A::a01042 ldind.i8 ldc.i8 42 beq a01042 newobj instance void [mscorlib]System.Exception::.ctor() throw a01042: ldsflda int16 [rvastatic4]A::a01043 ldind.i2 ldc.i4 43 beq a01043 newobj instance void [mscorlib]System.Exception::.ctor() throw a01043: ldsflda int64 [rvastatic4]A::a01044 ldind.i8 ldc.i8 44 beq a01044 newobj instance void [mscorlib]System.Exception::.ctor() throw a01044: ldsflda int64 [rvastatic4]A::a01045 ldind.i8 ldc.i8 45 beq a01045 newobj instance void [mscorlib]System.Exception::.ctor() throw a01045: ldsflda float32 [rvastatic4]A::a01046 ldind.r4 ldc.r4 46.0 beq a01046 newobj instance void [mscorlib]System.Exception::.ctor() throw a01046: ldsflda int16 [rvastatic4]A::a01047 ldind.i2 ldc.i4 47 beq a01047 newobj instance void [mscorlib]System.Exception::.ctor() throw a01047: ldsflda int64 [rvastatic4]A::a01048 ldind.i8 ldc.i8 48 beq a01048 newobj instance void [mscorlib]System.Exception::.ctor() throw a01048: ldsflda int16 [rvastatic4]A::a01049 ldind.i2 ldc.i4 49 beq a01049 newobj instance void [mscorlib]System.Exception::.ctor() throw a01049: ldsflda int32 [rvastatic4]A::a01050 ldind.i4 ldc.i4 50 beq a01050 newobj instance void [mscorlib]System.Exception::.ctor() throw a01050: ldsflda int16 [rvastatic4]A::a01051 ldind.i2 ldc.i4 51 beq a01051 newobj instance void [mscorlib]System.Exception::.ctor() throw a01051: ldsflda int32 [rvastatic4]A::a01052 ldind.i4 ldc.i4 52 beq a01052 newobj instance void [mscorlib]System.Exception::.ctor() throw a01052: ldsflda int16 [rvastatic4]A::a01053 ldind.i2 ldc.i4 53 beq a01053 newobj instance void [mscorlib]System.Exception::.ctor() throw a01053: ldsflda float32 [rvastatic4]A::a01054 ldind.r4 ldc.r4 54.0 beq a01054 newobj instance void [mscorlib]System.Exception::.ctor() throw a01054: ldsflda int64 [rvastatic4]A::a01055 ldind.i8 ldc.i8 55 beq a01055 newobj instance void [mscorlib]System.Exception::.ctor() throw a01055: ldsflda float32 [rvastatic4]A::a01056 ldind.r4 ldc.r4 56.0 beq a01056 newobj instance void [mscorlib]System.Exception::.ctor() throw a01056: ldsflda int64 [rvastatic4]A::a01057 ldind.i8 ldc.i8 57 beq a01057 newobj instance void [mscorlib]System.Exception::.ctor() throw a01057: ldsflda int64 [rvastatic4]A::a01058 ldind.i8 ldc.i8 58 beq a01058 newobj instance void [mscorlib]System.Exception::.ctor() throw a01058: ldsflda int64 [rvastatic4]A::a01059 ldind.i8 ldc.i8 59 beq a01059 newobj instance void [mscorlib]System.Exception::.ctor() throw a01059: ldsflda int16 [rvastatic4]A::a01060 ldind.i2 ldc.i4 60 beq a01060 newobj instance void [mscorlib]System.Exception::.ctor() throw a01060: ldsflda int8 [rvastatic4]A::a01061 ldind.i1 ldc.i4 61 beq a01061 newobj instance void [mscorlib]System.Exception::.ctor() throw a01061: ldsflda int64 [rvastatic4]A::a01062 ldind.i8 ldc.i8 62 beq a01062 newobj instance void [mscorlib]System.Exception::.ctor() throw a01062: ldsflda int16 [rvastatic4]A::a01063 ldind.i2 ldc.i4 63 beq a01063 newobj instance void [mscorlib]System.Exception::.ctor() throw a01063: ldsflda int32 [rvastatic4]A::a01064 ldind.i4 ldc.i4 64 beq a01064 newobj instance void [mscorlib]System.Exception::.ctor() throw a01064: ldsflda int16 [rvastatic4]A::a01065 ldind.i2 ldc.i4 65 beq a01065 newobj instance void [mscorlib]System.Exception::.ctor() throw a01065: ldsflda int8 [rvastatic4]A::a01066 ldind.i1 ldc.i4 66 beq a01066 newobj instance void [mscorlib]System.Exception::.ctor() throw a01066: ldsflda int16 [rvastatic4]A::a01067 ldind.i2 ldc.i4 67 beq a01067 newobj instance void [mscorlib]System.Exception::.ctor() throw a01067: ldsflda int32 [rvastatic4]A::a01068 ldind.i4 ldc.i4 68 beq a01068 newobj instance void [mscorlib]System.Exception::.ctor() throw a01068: ldsflda float32 [rvastatic4]A::a01069 ldind.r4 ldc.r4 69.0 beq a01069 newobj instance void [mscorlib]System.Exception::.ctor() throw a01069: ldsflda float32 [rvastatic4]A::a01070 ldind.r4 ldc.r4 70.0 beq a01070 newobj instance void [mscorlib]System.Exception::.ctor() throw a01070: ldsflda int16 [rvastatic4]A::a01071 ldind.i2 ldc.i4 71 beq a01071 newobj instance void [mscorlib]System.Exception::.ctor() throw a01071: ldsflda float32 [rvastatic4]A::a01072 ldind.r4 ldc.r4 72.0 beq a01072 newobj instance void [mscorlib]System.Exception::.ctor() throw a01072: ldsflda int64 [rvastatic4]A::a01073 ldind.i8 ldc.i8 73 beq a01073 newobj instance void [mscorlib]System.Exception::.ctor() throw a01073: ldsflda int64 [rvastatic4]A::a01074 ldind.i8 ldc.i8 74 beq a01074 newobj instance void [mscorlib]System.Exception::.ctor() throw a01074: ldsflda int32 [rvastatic4]A::a01075 ldind.i4 ldc.i4 75 beq a01075 newobj instance void [mscorlib]System.Exception::.ctor() throw a01075: ldsflda int8 [rvastatic4]A::a01076 ldind.i1 ldc.i4 76 beq a01076 newobj instance void [mscorlib]System.Exception::.ctor() throw a01076: ldsflda int32 [rvastatic4]A::a01077 ldind.i4 ldc.i4 77 beq a01077 newobj instance void [mscorlib]System.Exception::.ctor() throw a01077: ldsflda int16 [rvastatic4]A::a01078 ldind.i2 ldc.i4 78 beq a01078 newobj instance void [mscorlib]System.Exception::.ctor() throw a01078: ldsflda float32 [rvastatic4]A::a01079 ldind.r4 ldc.r4 79.0 beq a01079 newobj instance void [mscorlib]System.Exception::.ctor() throw a01079: ldsflda float32 [rvastatic4]A::a01080 ldind.r4 ldc.r4 80.0 beq a01080 newobj instance void [mscorlib]System.Exception::.ctor() throw a01080: ldsflda float32 [rvastatic4]A::a01081 ldind.r4 ldc.r4 81.0 beq a01081 newobj instance void [mscorlib]System.Exception::.ctor() throw a01081: ldsflda int32 [rvastatic4]A::a01082 ldind.i4 ldc.i4 82 beq a01082 newobj instance void [mscorlib]System.Exception::.ctor() throw a01082: ldsflda int8 [rvastatic4]A::a01083 ldind.i1 ldc.i4 83 beq a01083 newobj instance void [mscorlib]System.Exception::.ctor() throw a01083: ldsflda int64 [rvastatic4]A::a01084 ldind.i8 ldc.i8 84 beq a01084 newobj instance void [mscorlib]System.Exception::.ctor() throw a01084: ldsflda int64 [rvastatic4]A::a01085 ldind.i8 ldc.i8 85 beq a01085 newobj instance void [mscorlib]System.Exception::.ctor() throw a01085: ldsflda int32 [rvastatic4]A::a01086 ldind.i4 ldc.i4 86 beq a01086 newobj instance void [mscorlib]System.Exception::.ctor() throw a01086: ldsflda int32 [rvastatic4]A::a01087 ldind.i4 ldc.i4 87 beq a01087 newobj instance void [mscorlib]System.Exception::.ctor() throw a01087: ldsflda int8 [rvastatic4]A::a01088 ldind.i1 ldc.i4 88 beq a01088 newobj instance void [mscorlib]System.Exception::.ctor() throw a01088: ldsflda int64 [rvastatic4]A::a01089 ldind.i8 ldc.i8 89 beq a01089 newobj instance void [mscorlib]System.Exception::.ctor() throw a01089: ldsflda int8 [rvastatic4]A::a01090 ldind.i1 ldc.i4 90 beq a01090 newobj instance void [mscorlib]System.Exception::.ctor() throw a01090: ldsflda int16 [rvastatic4]A::a01091 ldind.i2 ldc.i4 91 beq a01091 newobj instance void [mscorlib]System.Exception::.ctor() throw a01091: ldsflda float32 [rvastatic4]A::a01092 ldind.r4 ldc.r4 92.0 beq a01092 newobj instance void [mscorlib]System.Exception::.ctor() throw a01092: ldsflda int64 [rvastatic4]A::a01093 ldind.i8 ldc.i8 93 beq a01093 newobj instance void [mscorlib]System.Exception::.ctor() throw a01093: ldsflda int64 [rvastatic4]A::a01094 ldind.i8 ldc.i8 94 beq a01094 newobj instance void [mscorlib]System.Exception::.ctor() throw a01094: ldsflda int8 [rvastatic4]A::a01095 ldind.i1 ldc.i4 95 beq a01095 newobj instance void [mscorlib]System.Exception::.ctor() throw a01095: ldsflda float32 [rvastatic4]A::a01096 ldind.r4 ldc.r4 96.0 beq a01096 newobj instance void [mscorlib]System.Exception::.ctor() throw a01096: ldsflda int16 [rvastatic4]A::a01097 ldind.i2 ldc.i4 97 beq a01097 newobj instance void [mscorlib]System.Exception::.ctor() throw a01097: ldsflda float32 [rvastatic4]A::a01098 ldind.r4 ldc.r4 98.0 beq a01098 newobj instance void [mscorlib]System.Exception::.ctor() throw a01098: ldsflda int32 [rvastatic4]A::a01099 ldind.i4 ldc.i4 99 beq a01099 newobj instance void [mscorlib]System.Exception::.ctor() throw a01099: ldsflda int64 [rvastatic4]A::a010100 ldind.i8 ldc.i8 100 beq a010100 newobj instance void [mscorlib]System.Exception::.ctor() throw a010100: ldsflda int32 [rvastatic4]A::a010101 ldind.i4 ldc.i4 101 beq a010101 newobj instance void [mscorlib]System.Exception::.ctor() throw a010101: ldsflda float32 [rvastatic4]A::a010102 ldind.r4 ldc.r4 102.0 beq a010102 newobj instance void [mscorlib]System.Exception::.ctor() throw a010102: ldsflda int64 [rvastatic4]A::a010103 ldind.i8 ldc.i8 103 beq a010103 newobj instance void [mscorlib]System.Exception::.ctor() throw a010103: ldsflda int32 [rvastatic4]A::a010104 ldind.i4 ldc.i4 104 beq a010104 newobj instance void [mscorlib]System.Exception::.ctor() throw a010104: ldsflda int16 [rvastatic4]A::a010105 ldind.i2 ldc.i4 105 beq a010105 newobj instance void [mscorlib]System.Exception::.ctor() throw a010105: ldsflda int16 [rvastatic4]A::a010106 ldind.i2 ldc.i4 106 beq a010106 newobj instance void [mscorlib]System.Exception::.ctor() throw a010106: ldsflda float32 [rvastatic4]A::a010107 ldind.r4 ldc.r4 107.0 beq a010107 newobj instance void [mscorlib]System.Exception::.ctor() throw a010107: ldsflda int32 [rvastatic4]A::a010108 ldind.i4 ldc.i4 108 beq a010108 newobj instance void [mscorlib]System.Exception::.ctor() throw a010108: ldsflda int16 [rvastatic4]A::a010109 ldind.i2 ldc.i4 109 beq a010109 newobj instance void [mscorlib]System.Exception::.ctor() throw a010109: ldsflda int32 [rvastatic4]A::a010110 ldind.i4 ldc.i4 110 beq a010110 newobj instance void [mscorlib]System.Exception::.ctor() throw a010110: ldsflda int32 [rvastatic4]A::a010111 ldind.i4 ldc.i4 111 beq a010111 newobj instance void [mscorlib]System.Exception::.ctor() throw a010111: ldsflda int32 [rvastatic4]A::a010112 ldind.i4 ldc.i4 112 beq a010112 newobj instance void [mscorlib]System.Exception::.ctor() throw a010112: ldsflda int64 [rvastatic4]A::a010113 ldind.i8 ldc.i8 113 beq a010113 newobj instance void [mscorlib]System.Exception::.ctor() throw a010113: ldsflda int64 [rvastatic4]A::a010114 ldind.i8 ldc.i8 114 beq a010114 newobj instance void [mscorlib]System.Exception::.ctor() throw a010114: ldsflda int16 [rvastatic4]A::a010115 ldind.i2 ldc.i4 115 beq a010115 newobj instance void [mscorlib]System.Exception::.ctor() throw a010115: ldsflda int64 [rvastatic4]A::a010116 ldind.i8 ldc.i8 116 beq a010116 newobj instance void [mscorlib]System.Exception::.ctor() throw a010116: ldsflda int64 [rvastatic4]A::a010117 ldind.i8 ldc.i8 117 beq a010117 newobj instance void [mscorlib]System.Exception::.ctor() throw a010117: ldsflda int32 [rvastatic4]A::a010118 ldind.i4 ldc.i4 118 beq a010118 newobj instance void [mscorlib]System.Exception::.ctor() throw a010118: ldsflda int64 [rvastatic4]A::a010119 ldind.i8 ldc.i8 119 beq a010119 newobj instance void [mscorlib]System.Exception::.ctor() throw a010119: ldsflda int64 [rvastatic4]A::a010120 ldind.i8 ldc.i8 120 beq a010120 newobj instance void [mscorlib]System.Exception::.ctor() throw a010120: ldsflda int64 [rvastatic4]A::a010121 ldind.i8 ldc.i8 121 beq a010121 newobj instance void [mscorlib]System.Exception::.ctor() throw a010121: ldsflda int16 [rvastatic4]A::a010122 ldind.i2 ldc.i4 122 beq a010122 newobj instance void [mscorlib]System.Exception::.ctor() throw a010122: ldsflda int64 [rvastatic4]A::a010123 ldind.i8 ldc.i8 123 beq a010123 newobj instance void [mscorlib]System.Exception::.ctor() throw a010123: ldsflda int64 [rvastatic4]A::a010124 ldind.i8 ldc.i8 124 beq a010124 newobj instance void [mscorlib]System.Exception::.ctor() throw a010124: ldsflda int32 [rvastatic4]A::a010125 ldind.i4 ldc.i4 125 beq a010125 newobj instance void [mscorlib]System.Exception::.ctor() throw a010125: ldsflda int16 [rvastatic4]A::a010126 ldind.i2 ldc.i4 126 beq a010126 newobj instance void [mscorlib]System.Exception::.ctor() throw a010126: ldsflda int16 [rvastatic4]A::a010127 ldind.i2 ldc.i4 127 beq a010127 newobj instance void [mscorlib]System.Exception::.ctor() throw a010127: ret} .method static void V3() {.maxstack 50 ldsfld float32 [rvastatic4]A::a01079 ldc.r4 79.0 beq a010129 newobj instance void [mscorlib]System.Exception::.ctor() throw a010129: ldsfld int32 [rvastatic4]A::a010111 ldc.i4 111 beq a010130 newobj instance void [mscorlib]System.Exception::.ctor() throw a010130: ldsfld int16 [rvastatic4]A::a01034 ldc.i4 34 beq a010131 newobj instance void [mscorlib]System.Exception::.ctor() throw a010131: ldsfld int8 [rvastatic4]A::a01040 ldc.i4 40 beq a010132 newobj instance void [mscorlib]System.Exception::.ctor() throw a010132: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a010133 newobj instance void [mscorlib]System.Exception::.ctor() throw a010133: ldsfld int64 [rvastatic4]A::a01089 ldc.i8 89 beq a010134 newobj instance void [mscorlib]System.Exception::.ctor() throw a010134: ldsfld float32 [rvastatic4]A::a01070 ldc.r4 70.0 beq a010135 newobj instance void [mscorlib]System.Exception::.ctor() throw a010135: ldsfld int8 [rvastatic4]A::a01066 ldc.i4 66 beq a010136 newobj instance void [mscorlib]System.Exception::.ctor() throw a010136: ldsfld int64 [rvastatic4]A::a01048 ldc.i8 48 beq a010137 newobj instance void [mscorlib]System.Exception::.ctor() throw a010137: ldsfld float32 [rvastatic4]A::a01080 ldc.r4 80.0 beq a010138 newobj instance void [mscorlib]System.Exception::.ctor() throw a010138: ldsfld int32 [rvastatic4]A::a010104 ldc.i4 104 beq a010139 newobj instance void [mscorlib]System.Exception::.ctor() throw a010139: ldsfld int16 [rvastatic4]A::a01091 ldc.i4 91 beq a010140 newobj instance void [mscorlib]System.Exception::.ctor() throw a010140: ldsfld int32 [rvastatic4]A::a01024 ldc.i4 24 beq a010141 newobj instance void [mscorlib]System.Exception::.ctor() throw a010141: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 81.0 beq a010142 newobj instance void [mscorlib]System.Exception::.ctor() throw a010142: ldsfld int64 [rvastatic4]A::a010121 ldc.i8 121 beq a010143 newobj instance void [mscorlib]System.Exception::.ctor() throw a010143: ldsfld int8 [rvastatic4]A::a01017 ldc.i4 17 beq a010144 newobj instance void [mscorlib]System.Exception::.ctor() throw a010144: ldsfld float32 [rvastatic4]A::a010107 ldc.r4 107.0 beq a010145 newobj instance void [mscorlib]System.Exception::.ctor() throw a010145: ldsfld int16 [rvastatic4]A::a01047 ldc.i4 47 beq a010146 newobj instance void [mscorlib]System.Exception::.ctor() throw a010146: ldsfld int64 [rvastatic4]A::a01048 ldc.i8 48 beq a010147 newobj instance void [mscorlib]System.Exception::.ctor() throw a010147: ldsfld int8 [rvastatic4]A::a01020 ldc.i4 20 beq a010148 newobj instance void [mscorlib]System.Exception::.ctor() throw a010148: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 115 beq a010149 newobj instance void [mscorlib]System.Exception::.ctor() throw a010149: ldsfld int32 [rvastatic4]A::a01024 ldc.i4 24 beq a010150 newobj instance void [mscorlib]System.Exception::.ctor() throw a010150: ldsfld float32 [rvastatic4]A::a010102 ldc.r4 102.0 beq a010151 newobj instance void [mscorlib]System.Exception::.ctor() throw a010151: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 124 beq a010152 newobj instance void [mscorlib]System.Exception::.ctor() throw a010152: ldsfld int16 [rvastatic4]A::a01028 ldc.i4 28 beq a010153 newobj instance void [mscorlib]System.Exception::.ctor() throw a010153: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a010154 newobj instance void [mscorlib]System.Exception::.ctor() throw a010154: ldsfld int64 [rvastatic4]A::a0105 ldc.i8 5 beq a010155 newobj instance void [mscorlib]System.Exception::.ctor() throw a010155: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 115 beq a010156 newobj instance void [mscorlib]System.Exception::.ctor() throw a010156: ldsfld int64 [rvastatic4]A::a010113 ldc.i8 113 beq a010157 newobj instance void [mscorlib]System.Exception::.ctor() throw a010157: ldsfld int64 [rvastatic4]A::a0101 ldc.i8 1 beq a010158 newobj instance void [mscorlib]System.Exception::.ctor() throw a010158: ldsfld int16 [rvastatic4]A::a010122 ldc.i4 122 beq a010159 newobj instance void [mscorlib]System.Exception::.ctor() throw a010159: ldsfld int32 [rvastatic4]A::a010108 ldc.i4 108 beq a010160 newobj instance void [mscorlib]System.Exception::.ctor() throw a010160: ldsfld int8 [rvastatic4]A::a01090 ldc.i4 90 beq a010161 newobj instance void [mscorlib]System.Exception::.ctor() throw a010161: ldsfld int8 [rvastatic4]A::a01090 ldc.i4 90 beq a010162 newobj instance void [mscorlib]System.Exception::.ctor() throw a010162: ldsfld int32 [rvastatic4]A::a010112 ldc.i4 112 beq a010163 newobj instance void [mscorlib]System.Exception::.ctor() throw a010163: ldsfld int16 [rvastatic4]A::a01067 ldc.i4 67 beq a010164 newobj instance void [mscorlib]System.Exception::.ctor() throw a010164: ldsfld int32 [rvastatic4]A::a01064 ldc.i4 64 beq a010165 newobj instance void [mscorlib]System.Exception::.ctor() throw a010165: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 57 beq a010166 newobj instance void [mscorlib]System.Exception::.ctor() throw a010166: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a010167 newobj instance void [mscorlib]System.Exception::.ctor() throw a010167: ldsfld int64 [rvastatic4]A::a010120 ldc.i8 120 beq a010168 newobj instance void [mscorlib]System.Exception::.ctor() throw a010168: ldsfld float32 [rvastatic4]A::a01019 ldc.r4 19.0 beq a010169 newobj instance void [mscorlib]System.Exception::.ctor() throw a010169: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 124 beq a010170 newobj instance void [mscorlib]System.Exception::.ctor() throw a010170: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a010171 newobj instance void [mscorlib]System.Exception::.ctor() throw a010171: ldsfld int8 [rvastatic4]A::a0107 ldc.i4 7 beq a010172 newobj instance void [mscorlib]System.Exception::.ctor() throw a010172: ldsfld int16 [rvastatic4]A::a010106 ldc.i4 106 beq a010173 newobj instance void [mscorlib]System.Exception::.ctor() throw a010173: ldsfld int64 [rvastatic4]A::a01073 ldc.i8 73 beq a010174 newobj instance void [mscorlib]System.Exception::.ctor() throw a010174: ldsfld int64 [rvastatic4]A::a01074 ldc.i8 74 beq a010175 newobj instance void [mscorlib]System.Exception::.ctor() throw a010175: ldsfld int8 [rvastatic4]A::a01015 ldc.i4 15 beq a010176 newobj instance void [mscorlib]System.Exception::.ctor() throw a010176: ldsfld int32 [rvastatic4]A::a01077 ldc.i4 77 beq a010177 newobj instance void [mscorlib]System.Exception::.ctor() throw a010177: ldsfld int8 [rvastatic4]A::a01031 ldc.i4 31 beq a010178 newobj instance void [mscorlib]System.Exception::.ctor() throw a010178: ldsfld int16 [rvastatic4]A::a01067 ldc.i4 67 beq a010179 newobj instance void [mscorlib]System.Exception::.ctor() throw a010179: ldsfld int16 [rvastatic4]A::a01071 ldc.i4 71 beq a010180 newobj instance void [mscorlib]System.Exception::.ctor() throw a010180: ldsfld int16 [rvastatic4]A::a01047 ldc.i4 47 beq a010181 newobj instance void [mscorlib]System.Exception::.ctor() throw a010181: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 61 beq a010182 newobj instance void [mscorlib]System.Exception::.ctor() throw a010182: ldsfld int64 [rvastatic4]A::a010114 ldc.i8 114 beq a010183 newobj instance void [mscorlib]System.Exception::.ctor() throw a010183: ldsfld float32 [rvastatic4]A::a01054 ldc.r4 54.0 beq a010184 newobj instance void [mscorlib]System.Exception::.ctor() throw a010184: ldsfld int32 [rvastatic4]A::a0109 ldc.i4 9 beq a010185 newobj instance void [mscorlib]System.Exception::.ctor() throw a010185: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a010186 newobj instance void [mscorlib]System.Exception::.ctor() throw a010186: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a010187 newobj instance void [mscorlib]System.Exception::.ctor() throw a010187: ldsfld int32 [rvastatic4]A::a0100 ldc.i4 0 beq a010188 newobj instance void [mscorlib]System.Exception::.ctor() throw a010188: ldsfld int8 [rvastatic4]A::a01083 ldc.i4 83 beq a010189 newobj instance void [mscorlib]System.Exception::.ctor() throw a010189: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 82 beq a010190 newobj instance void [mscorlib]System.Exception::.ctor() throw a010190: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 81.0 beq a010191 newobj instance void [mscorlib]System.Exception::.ctor() throw a010191: ldsfld float32 [rvastatic4]A::a01046 ldc.r4 46.0 beq a010192 newobj instance void [mscorlib]System.Exception::.ctor() throw a010192: ldsfld int64 [rvastatic4]A::a01085 ldc.i8 85 beq a010193 newobj instance void [mscorlib]System.Exception::.ctor() throw a010193: ldsfld int64 [rvastatic4]A::a010123 ldc.i8 123 beq a010194 newobj instance void [mscorlib]System.Exception::.ctor() throw a010194: ldsfld int32 [rvastatic4]A::a0100 ldc.i4 0 beq a010195 newobj instance void [mscorlib]System.Exception::.ctor() throw a010195: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a010196 newobj instance void [mscorlib]System.Exception::.ctor() throw a010196: ldsfld float32 [rvastatic4]A::a01096 ldc.r4 96.0 beq a010197 newobj instance void [mscorlib]System.Exception::.ctor() throw a010197: ldsfld int16 [rvastatic4]A::a01053 ldc.i4 53 beq a010198 newobj instance void [mscorlib]System.Exception::.ctor() throw a010198: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 81.0 beq a010199 newobj instance void [mscorlib]System.Exception::.ctor() throw a010199: ldsfld int16 [rvastatic4]A::a01049 ldc.i4 49 beq a010200 newobj instance void [mscorlib]System.Exception::.ctor() throw a010200: ldsfld int32 [rvastatic4]A::a0109 ldc.i4 9 beq a010201 newobj instance void [mscorlib]System.Exception::.ctor() throw a010201: ldsfld float32 [rvastatic4]A::a01056 ldc.r4 56.0 beq a010202 newobj instance void [mscorlib]System.Exception::.ctor() throw a010202: ldsfld int64 [rvastatic4]A::a0101 ldc.i8 1 beq a010203 newobj instance void [mscorlib]System.Exception::.ctor() throw a010203: ldsfld int64 [rvastatic4]A::a010119 ldc.i8 119 beq a010204 newobj instance void [mscorlib]System.Exception::.ctor() throw a010204: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 115 beq a010205 newobj instance void [mscorlib]System.Exception::.ctor() throw a010205: ldsfld int64 [rvastatic4]A::a01094 ldc.i8 94 beq a010206 newobj instance void [mscorlib]System.Exception::.ctor() throw a010206: ldsfld int8 [rvastatic4]A::a01017 ldc.i4 17 beq a010207 newobj instance void [mscorlib]System.Exception::.ctor() throw a010207: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 82 beq a010208 newobj instance void [mscorlib]System.Exception::.ctor() throw a010208: ldsfld int16 [rvastatic4]A::a01065 ldc.i4 65 beq a010209 newobj instance void [mscorlib]System.Exception::.ctor() throw a010209: ldsfld int64 [rvastatic4]A::a010117 ldc.i8 117 beq a010210 newobj instance void [mscorlib]System.Exception::.ctor() throw a010210: ldsfld int16 [rvastatic4]A::a01038 ldc.i4 38 beq a010211 newobj instance void [mscorlib]System.Exception::.ctor() throw a010211: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 82 beq a010212 newobj instance void [mscorlib]System.Exception::.ctor() throw a010212: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a010213 newobj instance void [mscorlib]System.Exception::.ctor() throw a010213: ldsfld int32 [rvastatic4]A::a01050 ldc.i4 50 beq a010214 newobj instance void [mscorlib]System.Exception::.ctor() throw a010214: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 61 beq a010215 newobj instance void [mscorlib]System.Exception::.ctor() throw a010215: ldsfld int16 [rvastatic4]A::a01029 ldc.i4 29 beq a010216 newobj instance void [mscorlib]System.Exception::.ctor() throw a010216: ldsfld int32 [rvastatic4]A::a010104 ldc.i4 104 beq a010217 newobj instance void [mscorlib]System.Exception::.ctor() throw a010217: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 57 beq a010218 newobj instance void [mscorlib]System.Exception::.ctor() throw a010218: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 57 beq a010219 newobj instance void [mscorlib]System.Exception::.ctor() throw a010219: ldsfld int16 [rvastatic4]A::a01026 ldc.i4 26 beq a010220 newobj instance void [mscorlib]System.Exception::.ctor() throw a010220: ldsfld int64 [rvastatic4]A::a01045 ldc.i8 45 beq a010221 newobj instance void [mscorlib]System.Exception::.ctor() throw a010221: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 37 beq a010222 newobj instance void [mscorlib]System.Exception::.ctor() throw a010222: ldsfld int8 [rvastatic4]A::a01036 ldc.i4 36 beq a010223 newobj instance void [mscorlib]System.Exception::.ctor() throw a010223: ldsfld int32 [rvastatic4]A::a01064 ldc.i4 64 beq a010224 newobj instance void [mscorlib]System.Exception::.ctor() throw a010224: ldsfld int16 [rvastatic4]A::a01043 ldc.i4 43 beq a010225 newobj instance void [mscorlib]System.Exception::.ctor() throw a010225: ldsfld int32 [rvastatic4]A::a010118 ldc.i4 118 beq a010226 newobj instance void [mscorlib]System.Exception::.ctor() throw a010226: ldsfld int32 [rvastatic4]A::a01050 ldc.i4 50 beq a010227 newobj instance void [mscorlib]System.Exception::.ctor() throw a010227: ldsfld int32 [rvastatic4]A::a010111 ldc.i4 111 beq a010228 newobj instance void [mscorlib]System.Exception::.ctor() throw a010228: ldsfld float32 [rvastatic4]A::a01072 ldc.r4 72.0 beq a010229 newobj instance void [mscorlib]System.Exception::.ctor() throw a010229: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 12 beq a010230 newobj instance void [mscorlib]System.Exception::.ctor() throw a010230: ldsfld float32 [rvastatic4]A::a01046 ldc.r4 46.0 beq a010231 newobj instance void [mscorlib]System.Exception::.ctor() throw a010231: ldsfld int8 [rvastatic4]A::a01023 ldc.i4 23 beq a010232 newobj instance void [mscorlib]System.Exception::.ctor() throw a010232: ldsfld int32 [rvastatic4]A::a01077 ldc.i4 77 beq a010233 newobj instance void [mscorlib]System.Exception::.ctor() throw a010233: ldsfld float32 [rvastatic4]A::a01018 ldc.r4 18.0 beq a010234 newobj instance void [mscorlib]System.Exception::.ctor() throw a010234: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 61 beq a010235 newobj instance void [mscorlib]System.Exception::.ctor() throw a010235: ldsfld int32 [rvastatic4]A::a010118 ldc.i4 118 beq a010236 newobj instance void [mscorlib]System.Exception::.ctor() throw a010236: ldsfld int64 [rvastatic4]A::a01059 ldc.i8 59 beq a010237 newobj instance void [mscorlib]System.Exception::.ctor() throw a010237: ldsfld int16 [rvastatic4]A::a010122 ldc.i4 122 beq a010238 newobj instance void [mscorlib]System.Exception::.ctor() throw a010238: ldsfld int8 [rvastatic4]A::a01066 ldc.i4 66 beq a010239 newobj instance void [mscorlib]System.Exception::.ctor() throw a010239: ldsfld int16 [rvastatic4]A::a01043 ldc.i4 43 beq a010240 newobj instance void [mscorlib]System.Exception::.ctor() throw a010240: ldsfld int8 [rvastatic4]A::a01020 ldc.i4 20 beq a010241 newobj instance void [mscorlib]System.Exception::.ctor() throw a010241: ldsfld int64 [rvastatic4]A::a01058 ldc.i8 58 beq a010242 newobj instance void [mscorlib]System.Exception::.ctor() throw a010242: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a010243 newobj instance void [mscorlib]System.Exception::.ctor() throw a010243: ldsfld int64 [rvastatic4]A::a01094 ldc.i8 94 beq a010244 newobj instance void [mscorlib]System.Exception::.ctor() throw a010244: ldsfld int64 [rvastatic4]A::a01044 ldc.i8 44 beq a010245 newobj instance void [mscorlib]System.Exception::.ctor() throw a010245: ldsfld int16 [rvastatic4]A::a010126 ldc.i4 126 beq a010246 newobj instance void [mscorlib]System.Exception::.ctor() throw a010246: ldsfld int32 [rvastatic4]A::a010112 ldc.i4 112 beq a010247 newobj instance void [mscorlib]System.Exception::.ctor() throw a010247: ldsfld int16 [rvastatic4]A::a01034 ldc.i4 34 beq a010248 newobj instance void [mscorlib]System.Exception::.ctor() throw a010248: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 62 beq a010249 newobj instance void [mscorlib]System.Exception::.ctor() throw a010249: ldsfld int32 [rvastatic4]A::a01099 ldc.i4 99 beq a010250 newobj instance void [mscorlib]System.Exception::.ctor() throw a010250: ldsfld int64 [rvastatic4]A::a01085 ldc.i8 85 beq a010251 newobj instance void [mscorlib]System.Exception::.ctor() throw a010251: ldsfld int8 [rvastatic4]A::a01039 ldc.i4 39 beq a010252 newobj instance void [mscorlib]System.Exception::.ctor() throw a010252: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 124 beq a010253 newobj instance void [mscorlib]System.Exception::.ctor() throw a010253: ldsfld int64 [rvastatic4]A::a01055 ldc.i8 55 beq a010254 newobj instance void [mscorlib]System.Exception::.ctor() throw a010254: ldsfld int16 [rvastatic4]A::a0104 ldc.i4 4 beq a010255 newobj instance void [mscorlib]System.Exception::.ctor() throw a010255: ldsfld int64 [rvastatic4]A::a010100 ldc.i8 100 beq a010256 newobj instance void [mscorlib]System.Exception::.ctor() throw a010256: ret} .method static void V4() {.maxstack 50 ldsflda int32 [rvastatic4]A::a0100 conv.i8 ldc.i8 19349 add conv.i8 ldc.i8 19349 sub conv.i ldind.i4 ldc.i4 0 beq a0100 ldstr "a0100" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0100: ldsflda int64 [rvastatic4]A::a0101 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i8 ldc.i8 1 beq a0101 ldstr "a0101" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0101: ldsflda float32 [rvastatic4]A::a0102 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.r4 ldc.r4 2.0 beq a0102 ldstr "a0102" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0102: ldsflda int16 [rvastatic4]A::a0103 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 3 beq a0103 ldstr "a0103" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0103: ldsflda int16 [rvastatic4]A::a0104 conv.i8 ldc.i8 46081 add conv.i8 ldc.i8 46081 sub conv.i ldind.i2 ldc.i4 4 beq a0104 ldstr "a0104" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0104: ldsflda int64 [rvastatic4]A::a0105 conv.i8 dup dup xor xor conv.i ldind.i8 ldc.i8 5 beq a0105 ldstr "a0105" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0105: ldsflda int16 [rvastatic4]A::a0106 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i2 ldc.i4 6 beq a0106 ldstr "a0106" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0106: ldsflda int8 [rvastatic4]A::a0107 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 7 beq a0107 ldstr "a0107" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0107: ldsflda int64 [rvastatic4]A::a0108 conv.i8 ldc.i8 3218 add conv.i8 ldc.i8 3218 sub conv.i ldind.i8 ldc.i8 8 beq a0108 ldstr "a0108" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0108: ldsflda int32 [rvastatic4]A::a0109 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 9 beq a0109 ldstr "a0109" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0109: ldsflda int16 [rvastatic4]A::a01010 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 10 beq a01010 ldstr "a01010" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01010: ldsflda float32 [rvastatic4]A::a01011 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.r4 ldc.r4 11.0 beq a01011 ldstr "a01011" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01011: ldsflda int16 [rvastatic4]A::a01012 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 12 beq a01012 ldstr "a01012" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01012: ldsflda float32 [rvastatic4]A::a01013 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.r4 ldc.r4 13.0 beq a01013 ldstr "a01013" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01013: ldsflda float32 [rvastatic4]A::a01014 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.r4 ldc.r4 14.0 beq a01014 ldstr "a01014" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01014: ldsflda int8 [rvastatic4]A::a01015 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 15 beq a01015 ldstr "a01015" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01015: ldsflda float32 [rvastatic4]A::a01016 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.r4 ldc.r4 16.0 beq a01016 ldstr "a01016" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01016: ldsflda int8 [rvastatic4]A::a01017 conv.i8 ldc.i8 15229 add conv.i8 ldc.i8 15229 sub conv.i ldind.i1 ldc.i4 17 beq a01017 ldstr "a01017" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01017: ldsflda float32 [rvastatic4]A::a01018 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.r4 ldc.r4 18.0 beq a01018 ldstr "a01018" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01018: ldsflda float32 [rvastatic4]A::a01019 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 19.0 beq a01019 ldstr "a01019" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01019: ldsflda int8 [rvastatic4]A::a01020 conv.i8 ldc.i8 28655 add conv.i8 ldc.i8 28655 sub conv.i ldind.i1 ldc.i4 20 beq a01020 ldstr "a01020" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01020: ldsflda float32 [rvastatic4]A::a01021 conv.i8 ldc.i8 33205 add conv.i8 ldc.i8 33205 sub conv.i ldind.r4 ldc.r4 21.0 beq a01021 ldstr "a01021" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01021: ldsflda int64 [rvastatic4]A::a01022 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i8 ldc.i8 22 beq a01022 ldstr "a01022" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01022: ldsflda int8 [rvastatic4]A::a01023 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 23 beq a01023 ldstr "a01023" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01023: ldsflda int32 [rvastatic4]A::a01024 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i4 ldc.i4 24 beq a01024 ldstr "a01024" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01024: ldsflda int64 [rvastatic4]A::a01025 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i8 ldc.i8 25 beq a01025 ldstr "a01025" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01025: ldsflda int16 [rvastatic4]A::a01026 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 26 beq a01026 ldstr "a01026" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01026: ldsflda int8 [rvastatic4]A::a01027 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i1 ldc.i4 27 beq a01027 ldstr "a01027" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01027: ldsflda int16 [rvastatic4]A::a01028 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 28 beq a01028 ldstr "a01028" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01028: ldsflda int16 [rvastatic4]A::a01029 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 29 beq a01029 ldstr "a01029" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01029: ldsflda int8 [rvastatic4]A::a01030 conv.i8 dup dup xor xor conv.i ldind.i1 ldc.i4 30 beq a01030 ldstr "a01030" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01030: ldsflda int8 [rvastatic4]A::a01031 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i1 ldc.i4 31 beq a01031 ldstr "a01031" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01031: ldsflda int64 [rvastatic4]A::a01032 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 32 beq a01032 ldstr "a01032" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01032: ldsflda float32 [rvastatic4]A::a01033 conv.i8 dup dup xor xor conv.i ldind.r4 ldc.r4 33.0 beq a01033 ldstr "a01033" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01033: ldsflda int16 [rvastatic4]A::a01034 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 34 beq a01034 ldstr "a01034" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01034: ldsflda int8 [rvastatic4]A::a01035 conv.i8 dup dup xor xor conv.i ldind.i1 ldc.i4 35 beq a01035 ldstr "a01035" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01035: ldsflda int8 [rvastatic4]A::a01036 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i1 ldc.i4 36 beq a01036 ldstr "a01036" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01036: ldsflda int32 [rvastatic4]A::a01037 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i4 ldc.i4 37 beq a01037 ldstr "a01037" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01037: ldsflda int16 [rvastatic4]A::a01038 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 38 beq a01038 ldstr "a01038" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01038: ldsflda int8 [rvastatic4]A::a01039 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i1 ldc.i4 39 beq a01039 ldstr "a01039" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01039: ldsflda int8 [rvastatic4]A::a01040 conv.i8 ldc.i8 65464 add conv.i8 ldc.i8 65464 sub conv.i ldind.i1 ldc.i4 40 beq a01040 ldstr "a01040" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01040: ldsflda int32 [rvastatic4]A::a01041 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i4 ldc.i4 41 beq a01041 ldstr "a01041" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01041: ldsflda int64 [rvastatic4]A::a01042 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 42 beq a01042 ldstr "a01042" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01042: ldsflda int16 [rvastatic4]A::a01043 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 43 beq a01043 ldstr "a01043" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01043: ldsflda int64 [rvastatic4]A::a01044 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 44 beq a01044 ldstr "a01044" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01044: ldsflda int64 [rvastatic4]A::a01045 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 45 beq a01045 ldstr "a01045" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01045: ldsflda float32 [rvastatic4]A::a01046 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.r4 ldc.r4 46.0 beq a01046 ldstr "a01046" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01046: ldsflda int16 [rvastatic4]A::a01047 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 47 beq a01047 ldstr "a01047" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01047: ldsflda int64 [rvastatic4]A::a01048 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 48 beq a01048 ldstr "a01048" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01048: ldsflda int16 [rvastatic4]A::a01049 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 49 beq a01049 ldstr "a01049" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01049: ldsflda int32 [rvastatic4]A::a01050 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i4 ldc.i4 50 beq a01050 ldstr "a01050" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01050: ldsflda int16 [rvastatic4]A::a01051 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 51 beq a01051 ldstr "a01051" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01051: ldsflda int32 [rvastatic4]A::a01052 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i4 ldc.i4 52 beq a01052 ldstr "a01052" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01052: ldsflda int16 [rvastatic4]A::a01053 conv.i8 ldc.i8 26716 add conv.i8 ldc.i8 26716 sub conv.i ldind.i2 ldc.i4 53 beq a01053 ldstr "a01053" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01053: ldsflda float32 [rvastatic4]A::a01054 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.r4 ldc.r4 54.0 beq a01054 ldstr "a01054" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01054: ldsflda int64 [rvastatic4]A::a01055 conv.i8 dup dup xor xor conv.i ldind.i8 ldc.i8 55 beq a01055 ldstr "a01055" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01055: ldsflda float32 [rvastatic4]A::a01056 conv.i8 dup dup xor xor conv.i ldind.r4 ldc.r4 56.0 beq a01056 ldstr "a01056" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01056: ldsflda int64 [rvastatic4]A::a01057 conv.i8 ldc.i8 62605 add conv.i8 ldc.i8 62605 sub conv.i ldind.i8 ldc.i8 57 beq a01057 ldstr "a01057" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01057: ldsflda int64 [rvastatic4]A::a01058 conv.i8 dup dup xor xor conv.i ldind.i8 ldc.i8 58 beq a01058 ldstr "a01058" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01058: ldsflda int64 [rvastatic4]A::a01059 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 59 beq a01059 ldstr "a01059" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01059: ldsflda int16 [rvastatic4]A::a01060 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i2 ldc.i4 60 beq a01060 ldstr "a01060" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01060: ldsflda int8 [rvastatic4]A::a01061 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i1 ldc.i4 61 beq a01061 ldstr "a01061" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01061: ldsflda int64 [rvastatic4]A::a01062 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 62 beq a01062 ldstr "a01062" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01062: ldsflda int16 [rvastatic4]A::a01063 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 63 beq a01063 ldstr "a01063" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01063: ldsflda int32 [rvastatic4]A::a01064 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i4 ldc.i4 64 beq a01064 ldstr "a01064" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01064: ldsflda int16 [rvastatic4]A::a01065 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 65 beq a01065 ldstr "a01065" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01065: ldsflda int8 [rvastatic4]A::a01066 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 66 beq a01066 ldstr "a01066" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01066: ldsflda int16 [rvastatic4]A::a01067 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 67 beq a01067 ldstr "a01067" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01067: ldsflda int32 [rvastatic4]A::a01068 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 68 beq a01068 ldstr "a01068" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01068: ldsflda float32 [rvastatic4]A::a01069 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.r4 ldc.r4 69.0 beq a01069 ldstr "a01069" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01069: ldsflda float32 [rvastatic4]A::a01070 conv.i8 ldc.i8 48606 add conv.i8 ldc.i8 48606 sub conv.i ldind.r4 ldc.r4 70.0 beq a01070 ldstr "a01070" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01070: ldsflda int16 [rvastatic4]A::a01071 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i2 ldc.i4 71 beq a01071 ldstr "a01071" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01071: ldsflda float32 [rvastatic4]A::a01072 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 72.0 beq a01072 ldstr "a01072" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01072: ldsflda int64 [rvastatic4]A::a01073 conv.i8 ldc.i8 5680 add conv.i8 ldc.i8 5680 sub conv.i ldind.i8 ldc.i8 73 beq a01073 ldstr "a01073" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01073: ldsflda int64 [rvastatic4]A::a01074 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 74 beq a01074 ldstr "a01074" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01074: ldsflda int32 [rvastatic4]A::a01075 conv.i8 ldc.i8 32361 add conv.i8 ldc.i8 32361 sub conv.i ldind.i4 ldc.i4 75 beq a01075 ldstr "a01075" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01075: ldsflda int8 [rvastatic4]A::a01076 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i1 ldc.i4 76 beq a01076 ldstr "a01076" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01076: ldsflda int32 [rvastatic4]A::a01077 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 77 beq a01077 ldstr "a01077" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01077: ldsflda int16 [rvastatic4]A::a01078 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 78 beq a01078 ldstr "a01078" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01078: ldsflda float32 [rvastatic4]A::a01079 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.r4 ldc.r4 79.0 beq a01079 ldstr "a01079" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01079: ldsflda float32 [rvastatic4]A::a01080 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.r4 ldc.r4 80.0 beq a01080 ldstr "a01080" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01080: ldsflda float32 [rvastatic4]A::a01081 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 81.0 beq a01081 ldstr "a01081" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01081: ldsflda int32 [rvastatic4]A::a01082 conv.i8 ldc.i8 30180 add conv.i8 ldc.i8 30180 sub conv.i ldind.i4 ldc.i4 82 beq a01082 ldstr "a01082" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01082: ldsflda int8 [rvastatic4]A::a01083 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i1 ldc.i4 83 beq a01083 ldstr "a01083" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01083: ldsflda int64 [rvastatic4]A::a01084 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i8 ldc.i8 84 beq a01084 ldstr "a01084" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01084: ldsflda int64 [rvastatic4]A::a01085 conv.i8 ldc.i8 18787 add conv.i8 ldc.i8 18787 sub conv.i ldind.i8 ldc.i8 85 beq a01085 ldstr "a01085" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01085: ldsflda int32 [rvastatic4]A::a01086 conv.i8 dup dup xor xor conv.i ldind.i4 ldc.i4 86 beq a01086 ldstr "a01086" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01086: ldsflda int32 [rvastatic4]A::a01087 conv.i8 ldc.i8 16913 add conv.i8 ldc.i8 16913 sub conv.i ldind.i4 ldc.i4 87 beq a01087 ldstr "a01087" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01087: ldsflda int8 [rvastatic4]A::a01088 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i1 ldc.i4 88 beq a01088 ldstr "a01088" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01088: ldsflda int64 [rvastatic4]A::a01089 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 89 beq a01089 ldstr "a01089" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01089: ldsflda int8 [rvastatic4]A::a01090 conv.i8 ldc.i8 42807 add conv.i8 ldc.i8 42807 sub conv.i ldind.i1 ldc.i4 90 beq a01090 ldstr "a01090" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01090: ldsflda int16 [rvastatic4]A::a01091 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 91 beq a01091 ldstr "a01091" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01091: ldsflda float32 [rvastatic4]A::a01092 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 92.0 beq a01092 ldstr "a01092" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01092: ldsflda int64 [rvastatic4]A::a01093 conv.i8 ldc.i8 37525 add conv.i8 ldc.i8 37525 sub conv.i ldind.i8 ldc.i8 93 beq a01093 ldstr "a01093" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01093: ldsflda int64 [rvastatic4]A::a01094 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 94 beq a01094 ldstr "a01094" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01094: ldsflda int8 [rvastatic4]A::a01095 conv.i8 dup dup xor xor conv.i ldind.i1 ldc.i4 95 beq a01095 ldstr "a01095" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01095: ldsflda float32 [rvastatic4]A::a01096 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 96.0 beq a01096 ldstr "a01096" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01096: ldsflda int16 [rvastatic4]A::a01097 conv.i8 ldc.i8 41331 add conv.i8 ldc.i8 41331 sub conv.i ldind.i2 ldc.i4 97 beq a01097 ldstr "a01097" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01097: ldsflda float32 [rvastatic4]A::a01098 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 98.0 beq a01098 ldstr "a01098" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01098: ldsflda int32 [rvastatic4]A::a01099 conv.i8 ldc.i8 4072 add conv.i8 ldc.i8 4072 sub conv.i ldind.i4 ldc.i4 99 beq a01099 ldstr "a01099" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01099: ldsflda int64 [rvastatic4]A::a010100 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 100 beq a010100 ldstr "a010100" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010100: ldsflda int32 [rvastatic4]A::a010101 conv.i8 dup dup xor xor conv.i ldind.i4 ldc.i4 101 beq a010101 ldstr "a010101" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010101: ldsflda float32 [rvastatic4]A::a010102 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.r4 ldc.r4 102.0 beq a010102 ldstr "a010102" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010102: ldsflda int64 [rvastatic4]A::a010103 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 103 beq a010103 ldstr "a010103" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010103: ldsflda int32 [rvastatic4]A::a010104 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i4 ldc.i4 104 beq a010104 ldstr "a010104" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010104: ldsflda int16 [rvastatic4]A::a010105 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i2 ldc.i4 105 beq a010105 ldstr "a010105" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010105: ldsflda int16 [rvastatic4]A::a010106 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i2 ldc.i4 106 beq a010106 ldstr "a010106" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010106: ldsflda float32 [rvastatic4]A::a010107 conv.i8 ldc.i8 61555 add conv.i8 ldc.i8 61555 sub conv.i ldind.r4 ldc.r4 107.0 beq a010107 ldstr "a010107" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010107: ldsflda int32 [rvastatic4]A::a010108 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i4 ldc.i4 108 beq a010108 ldstr "a010108" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010108: ldsflda int16 [rvastatic4]A::a010109 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 109 beq a010109 ldstr "a010109" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010109: ldsflda int32 [rvastatic4]A::a010110 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 110 beq a010110 ldstr "a010110" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010110: ldsflda int32 [rvastatic4]A::a010111 conv.i8 dup dup xor xor conv.i ldind.i4 ldc.i4 111 beq a010111 ldstr "a010111" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010111: ldsflda int32 [rvastatic4]A::a010112 conv.i8 dup dup xor xor conv.i ldind.i4 ldc.i4 112 beq a010112 ldstr "a010112" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010112: ldsflda int64 [rvastatic4]A::a010113 conv.i8 ldc.i8 45274 add conv.i8 ldc.i8 45274 sub conv.i ldind.i8 ldc.i8 113 beq a010113 ldstr "a010113" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010113: ldsflda int64 [rvastatic4]A::a010114 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 114 beq a010114 ldstr "a010114" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010114: ldsflda int16 [rvastatic4]A::a010115 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 115 beq a010115 ldstr "a010115" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010115: ldsflda int64 [rvastatic4]A::a010116 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 116 beq a010116 ldstr "a010116" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010116: ldsflda int64 [rvastatic4]A::a010117 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i8 ldc.i8 117 beq a010117 ldstr "a010117" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010117: ldsflda int32 [rvastatic4]A::a010118 conv.i8 ldc.i8 9701 add conv.i8 ldc.i8 9701 sub conv.i ldind.i4 ldc.i4 118 beq a010118 ldstr "a010118" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010118: ldsflda int64 [rvastatic4]A::a010119 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i8 ldc.i8 119 beq a010119 ldstr "a010119" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010119: ldsflda int64 [rvastatic4]A::a010120 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i8 ldc.i8 120 beq a010120 ldstr "a010120" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010120: ldsflda int64 [rvastatic4]A::a010121 conv.i8 dup ldc.i8 0x0000000000ffffff and ldc.i4 32 shl conv.i8 ldc.i4 32 shr.un or conv.i ldind.i8 ldc.i8 121 beq a010121 ldstr "a010121" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010121: ldsflda int16 [rvastatic4]A::a010122 conv.r8 ldc.r8 234.098 add conv.r8 ldc.r8 -234.098 add conv.i ldind.i2 ldc.i4 122 beq a010122 ldstr "a010122" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010122: ldsflda int64 [rvastatic4]A::a010123 conv.i8 ldc.i8 2 mul ldc.i4 1 shr.un conv.i ldind.i8 ldc.i8 123 beq a010123 ldstr "a010123" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010123: ldsflda int64 [rvastatic4]A::a010124 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i8 ldc.i8 124 beq a010124 ldstr "a010124" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010124: ldsflda int32 [rvastatic4]A::a010125 conv.i8 conv.r8 conv.u8 conv.i conv.i8 conv.r8 conv.u8 conv.i ldind.i4 ldc.i4 125 beq a010125 ldstr "a010125" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010125: ldsflda int16 [rvastatic4]A::a010126 conv.i8 dup dup xor xor conv.i ldind.i2 ldc.i4 126 beq a010126 ldstr "a010126" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010126: ldsflda int16 [rvastatic4]A::a010127 conv.i8 dup ldc.i8 0xffffffff00000000 and ldc.i4 32 shr.un conv.i8 ldc.i4 32 shl or conv.i ldind.i2 ldc.i4 127 beq a010127 ldstr "a010127" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010127: ret} .method static void V5() {.maxstack 50 ldsflda int32 [rvastatic4]A::a0100 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 0 beq a0100 ldstr "a0100" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0100: ldsflda int64 [rvastatic4]A::a0101 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 1 beq a0101 ldstr "a0101" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0101: ldsflda float32 [rvastatic4]A::a0102 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 2.0 beq a0102 ldstr "a0102" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0102: ldsflda int16 [rvastatic4]A::a0103 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 3 beq a0103 ldstr "a0103" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0103: ldsflda int16 [rvastatic4]A::a0104 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 4 beq a0104 ldstr "a0104" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0104: ldsflda int64 [rvastatic4]A::a0105 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 5 beq a0105 ldstr "a0105" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0105: ldsflda int16 [rvastatic4]A::a0106 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 6 beq a0106 ldstr "a0106" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0106: ldsflda int8 [rvastatic4]A::a0107 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 7 beq a0107 ldstr "a0107" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0107: ldsflda int64 [rvastatic4]A::a0108 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 8 beq a0108 ldstr "a0108" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0108: ldsflda int32 [rvastatic4]A::a0109 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 9 beq a0109 ldstr "a0109" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a0109: ldsflda int16 [rvastatic4]A::a01010 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 10 beq a01010 ldstr "a01010" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01010: ldsflda float32 [rvastatic4]A::a01011 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 11.0 beq a01011 ldstr "a01011" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01011: ldsflda int16 [rvastatic4]A::a01012 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 12 beq a01012 ldstr "a01012" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01012: ldsflda float32 [rvastatic4]A::a01013 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 13.0 beq a01013 ldstr "a01013" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01013: ldsflda float32 [rvastatic4]A::a01014 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.r4 ldc.r4 14.0 beq a01014 ldstr "a01014" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01014: ldsflda int8 [rvastatic4]A::a01015 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 15 beq a01015 ldstr "a01015" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01015: ldsflda float32 [rvastatic4]A::a01016 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 16.0 beq a01016 ldstr "a01016" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01016: ldsflda int8 [rvastatic4]A::a01017 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 17 beq a01017 ldstr "a01017" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01017: ldsflda float32 [rvastatic4]A::a01018 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.r4 ldc.r4 18.0 beq a01018 ldstr "a01018" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01018: ldsflda float32 [rvastatic4]A::a01019 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 19.0 beq a01019 ldstr "a01019" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01019: ldsflda int8 [rvastatic4]A::a01020 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 20 beq a01020 ldstr "a01020" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01020: ldsflda float32 [rvastatic4]A::a01021 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 21.0 beq a01021 ldstr "a01021" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01021: ldsflda int64 [rvastatic4]A::a01022 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 22 beq a01022 ldstr "a01022" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01022: ldsflda int8 [rvastatic4]A::a01023 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 23 beq a01023 ldstr "a01023" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01023: ldsflda int32 [rvastatic4]A::a01024 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 24 beq a01024 ldstr "a01024" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01024: ldsflda int64 [rvastatic4]A::a01025 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 25 beq a01025 ldstr "a01025" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01025: ldsflda int16 [rvastatic4]A::a01026 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 26 beq a01026 ldstr "a01026" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01026: ldsflda int8 [rvastatic4]A::a01027 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 27 beq a01027 ldstr "a01027" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01027: ldsflda int16 [rvastatic4]A::a01028 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 28 beq a01028 ldstr "a01028" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01028: ldsflda int16 [rvastatic4]A::a01029 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 29 beq a01029 ldstr "a01029" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01029: ldsflda int8 [rvastatic4]A::a01030 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 30 beq a01030 ldstr "a01030" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01030: ldsflda int8 [rvastatic4]A::a01031 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 31 beq a01031 ldstr "a01031" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01031: ldsflda int64 [rvastatic4]A::a01032 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 32 beq a01032 ldstr "a01032" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01032: ldsflda float32 [rvastatic4]A::a01033 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 33.0 beq a01033 ldstr "a01033" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01033: ldsflda int16 [rvastatic4]A::a01034 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 34 beq a01034 ldstr "a01034" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01034: ldsflda int8 [rvastatic4]A::a01035 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 35 beq a01035 ldstr "a01035" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01035: ldsflda int8 [rvastatic4]A::a01036 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 36 beq a01036 ldstr "a01036" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01036: ldsflda int32 [rvastatic4]A::a01037 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 37 beq a01037 ldstr "a01037" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01037: ldsflda int16 [rvastatic4]A::a01038 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 38 beq a01038 ldstr "a01038" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01038: ldsflda int8 [rvastatic4]A::a01039 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 39 beq a01039 ldstr "a01039" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01039: ldsflda int8 [rvastatic4]A::a01040 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 40 beq a01040 ldstr "a01040" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01040: ldsflda int32 [rvastatic4]A::a01041 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 41 beq a01041 ldstr "a01041" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01041: ldsflda int64 [rvastatic4]A::a01042 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 42 beq a01042 ldstr "a01042" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01042: ldsflda int16 [rvastatic4]A::a01043 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 43 beq a01043 ldstr "a01043" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01043: ldsflda int64 [rvastatic4]A::a01044 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 44 beq a01044 ldstr "a01044" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01044: ldsflda int64 [rvastatic4]A::a01045 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 45 beq a01045 ldstr "a01045" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01045: ldsflda float32 [rvastatic4]A::a01046 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 46.0 beq a01046 ldstr "a01046" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01046: ldsflda int16 [rvastatic4]A::a01047 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 47 beq a01047 ldstr "a01047" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01047: ldsflda int64 [rvastatic4]A::a01048 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 48 beq a01048 ldstr "a01048" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01048: ldsflda int16 [rvastatic4]A::a01049 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 49 beq a01049 ldstr "a01049" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01049: ldsflda int32 [rvastatic4]A::a01050 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 50 beq a01050 ldstr "a01050" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01050: ldsflda int16 [rvastatic4]A::a01051 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 51 beq a01051 ldstr "a01051" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01051: ldsflda int32 [rvastatic4]A::a01052 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 52 beq a01052 ldstr "a01052" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01052: ldsflda int16 [rvastatic4]A::a01053 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 53 beq a01053 ldstr "a01053" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01053: ldsflda float32 [rvastatic4]A::a01054 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 54.0 beq a01054 ldstr "a01054" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01054: ldsflda int64 [rvastatic4]A::a01055 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 55 beq a01055 ldstr "a01055" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01055: ldsflda float32 [rvastatic4]A::a01056 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.r4 ldc.r4 56.0 beq a01056 ldstr "a01056" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01056: ldsflda int64 [rvastatic4]A::a01057 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 57 beq a01057 ldstr "a01057" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01057: ldsflda int64 [rvastatic4]A::a01058 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 58 beq a01058 ldstr "a01058" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01058: ldsflda int64 [rvastatic4]A::a01059 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 59 beq a01059 ldstr "a01059" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01059: ldsflda int16 [rvastatic4]A::a01060 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 60 beq a01060 ldstr "a01060" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01060: ldsflda int8 [rvastatic4]A::a01061 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 61 beq a01061 ldstr "a01061" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01061: ldsflda int64 [rvastatic4]A::a01062 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 62 beq a01062 ldstr "a01062" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01062: ldsflda int16 [rvastatic4]A::a01063 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 63 beq a01063 ldstr "a01063" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01063: ldsflda int32 [rvastatic4]A::a01064 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 64 beq a01064 ldstr "a01064" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01064: ldsflda int16 [rvastatic4]A::a01065 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 65 beq a01065 ldstr "a01065" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01065: ldsflda int8 [rvastatic4]A::a01066 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 66 beq a01066 ldstr "a01066" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01066: ldsflda int16 [rvastatic4]A::a01067 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 67 beq a01067 ldstr "a01067" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01067: ldsflda int32 [rvastatic4]A::a01068 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 68 beq a01068 ldstr "a01068" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01068: ldsflda float32 [rvastatic4]A::a01069 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 69.0 beq a01069 ldstr "a01069" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01069: ldsflda float32 [rvastatic4]A::a01070 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 70.0 beq a01070 ldstr "a01070" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01070: ldsflda int16 [rvastatic4]A::a01071 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 71 beq a01071 ldstr "a01071" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01071: ldsflda float32 [rvastatic4]A::a01072 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 72.0 beq a01072 ldstr "a01072" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01072: ldsflda int64 [rvastatic4]A::a01073 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 73 beq a01073 ldstr "a01073" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01073: ldsflda int64 [rvastatic4]A::a01074 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 74 beq a01074 ldstr "a01074" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01074: ldsflda int32 [rvastatic4]A::a01075 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 75 beq a01075 ldstr "a01075" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01075: ldsflda int8 [rvastatic4]A::a01076 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 76 beq a01076 ldstr "a01076" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01076: ldsflda int32 [rvastatic4]A::a01077 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 77 beq a01077 ldstr "a01077" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01077: ldsflda int16 [rvastatic4]A::a01078 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 78 beq a01078 ldstr "a01078" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01078: ldsflda float32 [rvastatic4]A::a01079 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.r4 ldc.r4 79.0 beq a01079 ldstr "a01079" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01079: ldsflda float32 [rvastatic4]A::a01080 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 80.0 beq a01080 ldstr "a01080" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01080: ldsflda float32 [rvastatic4]A::a01081 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 81.0 beq a01081 ldstr "a01081" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01081: ldsflda int32 [rvastatic4]A::a01082 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 82 beq a01082 ldstr "a01082" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01082: ldsflda int8 [rvastatic4]A::a01083 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 83 beq a01083 ldstr "a01083" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01083: ldsflda int64 [rvastatic4]A::a01084 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 84 beq a01084 ldstr "a01084" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01084: ldsflda int64 [rvastatic4]A::a01085 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 85 beq a01085 ldstr "a01085" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01085: ldsflda int32 [rvastatic4]A::a01086 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i4 ldc.i4 86 beq a01086 ldstr "a01086" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01086: ldsflda int32 [rvastatic4]A::a01087 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 87 beq a01087 ldstr "a01087" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01087: ldsflda int8 [rvastatic4]A::a01088 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 88 beq a01088 ldstr "a01088" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01088: ldsflda int64 [rvastatic4]A::a01089 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 89 beq a01089 ldstr "a01089" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01089: ldsflda int8 [rvastatic4]A::a01090 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i1 ldc.i4 90 beq a01090 ldstr "a01090" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01090: ldsflda int16 [rvastatic4]A::a01091 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 91 beq a01091 ldstr "a01091" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01091: ldsflda float32 [rvastatic4]A::a01092 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 92.0 beq a01092 ldstr "a01092" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01092: ldsflda int64 [rvastatic4]A::a01093 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 93 beq a01093 ldstr "a01093" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01093: ldsflda int64 [rvastatic4]A::a01094 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 94 beq a01094 ldstr "a01094" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01094: ldsflda int8 [rvastatic4]A::a01095 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i1 ldc.i4 95 beq a01095 ldstr "a01095" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01095: ldsflda float32 [rvastatic4]A::a01096 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 96.0 beq a01096 ldstr "a01096" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01096: ldsflda int16 [rvastatic4]A::a01097 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 97 beq a01097 ldstr "a01097" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01097: ldsflda float32 [rvastatic4]A::a01098 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 98.0 beq a01098 ldstr "a01098" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01098: ldsflda int32 [rvastatic4]A::a01099 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 99 beq a01099 ldstr "a01099" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a01099: ldsflda int64 [rvastatic4]A::a010100 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 100 beq a010100 ldstr "a010100" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010100: ldsflda int32 [rvastatic4]A::a010101 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 101 beq a010101 ldstr "a010101" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010101: ldsflda float32 [rvastatic4]A::a010102 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 102.0 beq a010102 ldstr "a010102" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010102: ldsflda int64 [rvastatic4]A::a010103 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 103 beq a010103 ldstr "a010103" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010103: ldsflda int32 [rvastatic4]A::a010104 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 104 beq a010104 ldstr "a010104" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010104: ldsflda int16 [rvastatic4]A::a010105 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 105 beq a010105 ldstr "a010105" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010105: ldsflda int16 [rvastatic4]A::a010106 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 106 beq a010106 ldstr "a010106" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010106: ldsflda float32 [rvastatic4]A::a010107 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.r4 ldc.r4 107.0 beq a010107 ldstr "a010107" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010107: ldsflda int32 [rvastatic4]A::a010108 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 108 beq a010108 ldstr "a010108" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010108: ldsflda int16 [rvastatic4]A::a010109 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 109 beq a010109 ldstr "a010109" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010109: ldsflda int32 [rvastatic4]A::a010110 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 110 beq a010110 ldstr "a010110" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010110: ldsflda int32 [rvastatic4]A::a010111 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 111 beq a010111 ldstr "a010111" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010111: ldsflda int32 [rvastatic4]A::a010112 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 112 beq a010112 ldstr "a010112" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010112: ldsflda int64 [rvastatic4]A::a010113 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 113 beq a010113 ldstr "a010113" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010113: ldsflda int64 [rvastatic4]A::a010114 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 114 beq a010114 ldstr "a010114" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010114: ldsflda int16 [rvastatic4]A::a010115 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 115 beq a010115 ldstr "a010115" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010115: ldsflda int64 [rvastatic4]A::a010116 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 116 beq a010116 ldstr "a010116" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010116: ldsflda int64 [rvastatic4]A::a010117 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 117 beq a010117 ldstr "a010117" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010117: ldsflda int32 [rvastatic4]A::a010118 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 118 beq a010118 ldstr "a010118" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010118: ldsflda int64 [rvastatic4]A::a010119 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 119 beq a010119 ldstr "a010119" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010119: ldsflda int64 [rvastatic4]A::a010120 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 120 beq a010120 ldstr "a010120" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010120: ldsflda int64 [rvastatic4]A::a010121 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 121 beq a010121 ldstr "a010121" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010121: ldsflda int16 [rvastatic4]A::a010122 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i2 ldc.i4 122 beq a010122 ldstr "a010122" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010122: ldsflda int64 [rvastatic4]A::a010123 conv.i8 call native int [rvastatic4]A::Call1(int64) ldind.i8 ldc.i8 123 beq a010123 ldstr "a010123" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010123: ldsflda int64 [rvastatic4]A::a010124 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i8 ldc.i8 124 beq a010124 ldstr "a010124" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010124: ldsflda int32 [rvastatic4]A::a010125 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i4 ldc.i4 125 beq a010125 ldstr "a010125" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010125: ldsflda int16 [rvastatic4]A::a010126 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 126 beq a010126 ldstr "a010126" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010126: ldsflda int16 [rvastatic4]A::a010127 conv.r8 call native int [rvastatic4]A::Call2(float64) ldind.i2 ldc.i4 127 beq a010127 ldstr "a010127" newobj instance void [mscorlib]System.Exception::.ctor(string) throw a010127: ret} .method static void V6() {.maxstack 50 ldsfld int32 [rvastatic4]A::a0100 ldc.i4 1 add stsfld int32 [rvastatic4]A::a0100 ldsfld int32 [rvastatic4]A::a0100 ldc.i4 1 beq a0100 newobj instance void [mscorlib]System.Exception::.ctor() throw a0100: ldsfld int64 [rvastatic4]A::a0101 ldc.i8 1 add stsfld int64 [rvastatic4]A::a0101 ldsfld int64 [rvastatic4]A::a0101 ldc.i8 2 beq a0101 newobj instance void [mscorlib]System.Exception::.ctor() throw a0101: ldsfld float32 [rvastatic4]A::a0102 ldc.r4 1 add stsfld float32 [rvastatic4]A::a0102 ldsfld float32 [rvastatic4]A::a0102 ldc.r4 3.0 beq a0102 newobj instance void [mscorlib]System.Exception::.ctor() throw a0102: ldsfld int16 [rvastatic4]A::a0103 ldc.i4 1 add stsfld int16 [rvastatic4]A::a0103 ldsfld int16 [rvastatic4]A::a0103 ldc.i4 4 beq a0103 newobj instance void [mscorlib]System.Exception::.ctor() throw a0103: ldsfld int16 [rvastatic4]A::a0104 ldc.i4 1 add stsfld int16 [rvastatic4]A::a0104 ldsfld int16 [rvastatic4]A::a0104 ldc.i4 5 beq a0104 newobj instance void [mscorlib]System.Exception::.ctor() throw a0104: ldsfld int64 [rvastatic4]A::a0105 ldc.i8 1 add stsfld int64 [rvastatic4]A::a0105 ldsfld int64 [rvastatic4]A::a0105 ldc.i8 6 beq a0105 newobj instance void [mscorlib]System.Exception::.ctor() throw a0105: ldsfld int16 [rvastatic4]A::a0106 ldc.i4 1 add stsfld int16 [rvastatic4]A::a0106 ldsfld int16 [rvastatic4]A::a0106 ldc.i4 7 beq a0106 newobj instance void [mscorlib]System.Exception::.ctor() throw a0106: ldsfld int8 [rvastatic4]A::a0107 ldc.i4 1 add stsfld int8 [rvastatic4]A::a0107 ldsfld int8 [rvastatic4]A::a0107 ldc.i4 8 beq a0107 newobj instance void [mscorlib]System.Exception::.ctor() throw a0107: ldsfld int64 [rvastatic4]A::a0108 ldc.i8 1 add stsfld int64 [rvastatic4]A::a0108 ldsfld int64 [rvastatic4]A::a0108 ldc.i8 9 beq a0108 newobj instance void [mscorlib]System.Exception::.ctor() throw a0108: ldsfld int32 [rvastatic4]A::a0109 ldc.i4 1 add stsfld int32 [rvastatic4]A::a0109 ldsfld int32 [rvastatic4]A::a0109 ldc.i4 10 beq a0109 newobj instance void [mscorlib]System.Exception::.ctor() throw a0109: ldsfld int16 [rvastatic4]A::a01010 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01010 ldsfld int16 [rvastatic4]A::a01010 ldc.i4 11 beq a01010 newobj instance void [mscorlib]System.Exception::.ctor() throw a01010: ldsfld float32 [rvastatic4]A::a01011 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01011 ldsfld float32 [rvastatic4]A::a01011 ldc.r4 12.0 beq a01011 newobj instance void [mscorlib]System.Exception::.ctor() throw a01011: ldsfld int16 [rvastatic4]A::a01012 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01012 ldsfld int16 [rvastatic4]A::a01012 ldc.i4 13 beq a01012 newobj instance void [mscorlib]System.Exception::.ctor() throw a01012: ldsfld float32 [rvastatic4]A::a01013 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01013 ldsfld float32 [rvastatic4]A::a01013 ldc.r4 14.0 beq a01013 newobj instance void [mscorlib]System.Exception::.ctor() throw a01013: ldsfld float32 [rvastatic4]A::a01014 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01014 ldsfld float32 [rvastatic4]A::a01014 ldc.r4 15.0 beq a01014 newobj instance void [mscorlib]System.Exception::.ctor() throw a01014: ldsfld int8 [rvastatic4]A::a01015 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01015 ldsfld int8 [rvastatic4]A::a01015 ldc.i4 16 beq a01015 newobj instance void [mscorlib]System.Exception::.ctor() throw a01015: ldsfld float32 [rvastatic4]A::a01016 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01016 ldsfld float32 [rvastatic4]A::a01016 ldc.r4 17.0 beq a01016 newobj instance void [mscorlib]System.Exception::.ctor() throw a01016: ldsfld int8 [rvastatic4]A::a01017 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01017 ldsfld int8 [rvastatic4]A::a01017 ldc.i4 18 beq a01017 newobj instance void [mscorlib]System.Exception::.ctor() throw a01017: ldsfld float32 [rvastatic4]A::a01018 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01018 ldsfld float32 [rvastatic4]A::a01018 ldc.r4 19.0 beq a01018 newobj instance void [mscorlib]System.Exception::.ctor() throw a01018: ldsfld float32 [rvastatic4]A::a01019 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01019 ldsfld float32 [rvastatic4]A::a01019 ldc.r4 20.0 beq a01019 newobj instance void [mscorlib]System.Exception::.ctor() throw a01019: ldsfld int8 [rvastatic4]A::a01020 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01020 ldsfld int8 [rvastatic4]A::a01020 ldc.i4 21 beq a01020 newobj instance void [mscorlib]System.Exception::.ctor() throw a01020: ldsfld float32 [rvastatic4]A::a01021 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01021 ldsfld float32 [rvastatic4]A::a01021 ldc.r4 22.0 beq a01021 newobj instance void [mscorlib]System.Exception::.ctor() throw a01021: ldsfld int64 [rvastatic4]A::a01022 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01022 ldsfld int64 [rvastatic4]A::a01022 ldc.i8 23 beq a01022 newobj instance void [mscorlib]System.Exception::.ctor() throw a01022: ldsfld int8 [rvastatic4]A::a01023 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01023 ldsfld int8 [rvastatic4]A::a01023 ldc.i4 24 beq a01023 newobj instance void [mscorlib]System.Exception::.ctor() throw a01023: ldsfld int32 [rvastatic4]A::a01024 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01024 ldsfld int32 [rvastatic4]A::a01024 ldc.i4 25 beq a01024 newobj instance void [mscorlib]System.Exception::.ctor() throw a01024: ldsfld int64 [rvastatic4]A::a01025 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01025 ldsfld int64 [rvastatic4]A::a01025 ldc.i8 26 beq a01025 newobj instance void [mscorlib]System.Exception::.ctor() throw a01025: ldsfld int16 [rvastatic4]A::a01026 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01026 ldsfld int16 [rvastatic4]A::a01026 ldc.i4 27 beq a01026 newobj instance void [mscorlib]System.Exception::.ctor() throw a01026: ldsfld int8 [rvastatic4]A::a01027 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01027 ldsfld int8 [rvastatic4]A::a01027 ldc.i4 28 beq a01027 newobj instance void [mscorlib]System.Exception::.ctor() throw a01027: ldsfld int16 [rvastatic4]A::a01028 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01028 ldsfld int16 [rvastatic4]A::a01028 ldc.i4 29 beq a01028 newobj instance void [mscorlib]System.Exception::.ctor() throw a01028: ldsfld int16 [rvastatic4]A::a01029 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01029 ldsfld int16 [rvastatic4]A::a01029 ldc.i4 30 beq a01029 newobj instance void [mscorlib]System.Exception::.ctor() throw a01029: ldsfld int8 [rvastatic4]A::a01030 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01030 ldsfld int8 [rvastatic4]A::a01030 ldc.i4 31 beq a01030 newobj instance void [mscorlib]System.Exception::.ctor() throw a01030: ldsfld int8 [rvastatic4]A::a01031 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01031 ldsfld int8 [rvastatic4]A::a01031 ldc.i4 32 beq a01031 newobj instance void [mscorlib]System.Exception::.ctor() throw a01031: ldsfld int64 [rvastatic4]A::a01032 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01032 ldsfld int64 [rvastatic4]A::a01032 ldc.i8 33 beq a01032 newobj instance void [mscorlib]System.Exception::.ctor() throw a01032: ldsfld float32 [rvastatic4]A::a01033 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01033 ldsfld float32 [rvastatic4]A::a01033 ldc.r4 34.0 beq a01033 newobj instance void [mscorlib]System.Exception::.ctor() throw a01033: ldsfld int16 [rvastatic4]A::a01034 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01034 ldsfld int16 [rvastatic4]A::a01034 ldc.i4 35 beq a01034 newobj instance void [mscorlib]System.Exception::.ctor() throw a01034: ldsfld int8 [rvastatic4]A::a01035 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01035 ldsfld int8 [rvastatic4]A::a01035 ldc.i4 36 beq a01035 newobj instance void [mscorlib]System.Exception::.ctor() throw a01035: ldsfld int8 [rvastatic4]A::a01036 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01036 ldsfld int8 [rvastatic4]A::a01036 ldc.i4 37 beq a01036 newobj instance void [mscorlib]System.Exception::.ctor() throw a01036: ldsfld int32 [rvastatic4]A::a01037 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01037 ldsfld int32 [rvastatic4]A::a01037 ldc.i4 38 beq a01037 newobj instance void [mscorlib]System.Exception::.ctor() throw a01037: ldsfld int16 [rvastatic4]A::a01038 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01038 ldsfld int16 [rvastatic4]A::a01038 ldc.i4 39 beq a01038 newobj instance void [mscorlib]System.Exception::.ctor() throw a01038: ldsfld int8 [rvastatic4]A::a01039 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01039 ldsfld int8 [rvastatic4]A::a01039 ldc.i4 40 beq a01039 newobj instance void [mscorlib]System.Exception::.ctor() throw a01039: ldsfld int8 [rvastatic4]A::a01040 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01040 ldsfld int8 [rvastatic4]A::a01040 ldc.i4 41 beq a01040 newobj instance void [mscorlib]System.Exception::.ctor() throw a01040: ldsfld int32 [rvastatic4]A::a01041 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01041 ldsfld int32 [rvastatic4]A::a01041 ldc.i4 42 beq a01041 newobj instance void [mscorlib]System.Exception::.ctor() throw a01041: ldsfld int64 [rvastatic4]A::a01042 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01042 ldsfld int64 [rvastatic4]A::a01042 ldc.i8 43 beq a01042 newobj instance void [mscorlib]System.Exception::.ctor() throw a01042: ldsfld int16 [rvastatic4]A::a01043 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01043 ldsfld int16 [rvastatic4]A::a01043 ldc.i4 44 beq a01043 newobj instance void [mscorlib]System.Exception::.ctor() throw a01043: ldsfld int64 [rvastatic4]A::a01044 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01044 ldsfld int64 [rvastatic4]A::a01044 ldc.i8 45 beq a01044 newobj instance void [mscorlib]System.Exception::.ctor() throw a01044: ldsfld int64 [rvastatic4]A::a01045 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01045 ldsfld int64 [rvastatic4]A::a01045 ldc.i8 46 beq a01045 newobj instance void [mscorlib]System.Exception::.ctor() throw a01045: ldsfld float32 [rvastatic4]A::a01046 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01046 ldsfld float32 [rvastatic4]A::a01046 ldc.r4 47.0 beq a01046 newobj instance void [mscorlib]System.Exception::.ctor() throw a01046: ldsfld int16 [rvastatic4]A::a01047 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01047 ldsfld int16 [rvastatic4]A::a01047 ldc.i4 48 beq a01047 newobj instance void [mscorlib]System.Exception::.ctor() throw a01047: ldsfld int64 [rvastatic4]A::a01048 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01048 ldsfld int64 [rvastatic4]A::a01048 ldc.i8 49 beq a01048 newobj instance void [mscorlib]System.Exception::.ctor() throw a01048: ldsfld int16 [rvastatic4]A::a01049 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01049 ldsfld int16 [rvastatic4]A::a01049 ldc.i4 50 beq a01049 newobj instance void [mscorlib]System.Exception::.ctor() throw a01049: ldsfld int32 [rvastatic4]A::a01050 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01050 ldsfld int32 [rvastatic4]A::a01050 ldc.i4 51 beq a01050 newobj instance void [mscorlib]System.Exception::.ctor() throw a01050: ldsfld int16 [rvastatic4]A::a01051 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01051 ldsfld int16 [rvastatic4]A::a01051 ldc.i4 52 beq a01051 newobj instance void [mscorlib]System.Exception::.ctor() throw a01051: ldsfld int32 [rvastatic4]A::a01052 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01052 ldsfld int32 [rvastatic4]A::a01052 ldc.i4 53 beq a01052 newobj instance void [mscorlib]System.Exception::.ctor() throw a01052: ldsfld int16 [rvastatic4]A::a01053 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01053 ldsfld int16 [rvastatic4]A::a01053 ldc.i4 54 beq a01053 newobj instance void [mscorlib]System.Exception::.ctor() throw a01053: ldsfld float32 [rvastatic4]A::a01054 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01054 ldsfld float32 [rvastatic4]A::a01054 ldc.r4 55.0 beq a01054 newobj instance void [mscorlib]System.Exception::.ctor() throw a01054: ldsfld int64 [rvastatic4]A::a01055 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01055 ldsfld int64 [rvastatic4]A::a01055 ldc.i8 56 beq a01055 newobj instance void [mscorlib]System.Exception::.ctor() throw a01055: ldsfld float32 [rvastatic4]A::a01056 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01056 ldsfld float32 [rvastatic4]A::a01056 ldc.r4 57.0 beq a01056 newobj instance void [mscorlib]System.Exception::.ctor() throw a01056: ldsfld int64 [rvastatic4]A::a01057 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01057 ldsfld int64 [rvastatic4]A::a01057 ldc.i8 58 beq a01057 newobj instance void [mscorlib]System.Exception::.ctor() throw a01057: ldsfld int64 [rvastatic4]A::a01058 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01058 ldsfld int64 [rvastatic4]A::a01058 ldc.i8 59 beq a01058 newobj instance void [mscorlib]System.Exception::.ctor() throw a01058: ldsfld int64 [rvastatic4]A::a01059 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01059 ldsfld int64 [rvastatic4]A::a01059 ldc.i8 60 beq a01059 newobj instance void [mscorlib]System.Exception::.ctor() throw a01059: ldsfld int16 [rvastatic4]A::a01060 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01060 ldsfld int16 [rvastatic4]A::a01060 ldc.i4 61 beq a01060 newobj instance void [mscorlib]System.Exception::.ctor() throw a01060: ldsfld int8 [rvastatic4]A::a01061 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01061 ldsfld int8 [rvastatic4]A::a01061 ldc.i4 62 beq a01061 newobj instance void [mscorlib]System.Exception::.ctor() throw a01061: ldsfld int64 [rvastatic4]A::a01062 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01062 ldsfld int64 [rvastatic4]A::a01062 ldc.i8 63 beq a01062 newobj instance void [mscorlib]System.Exception::.ctor() throw a01062: ldsfld int16 [rvastatic4]A::a01063 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01063 ldsfld int16 [rvastatic4]A::a01063 ldc.i4 64 beq a01063 newobj instance void [mscorlib]System.Exception::.ctor() throw a01063: ldsfld int32 [rvastatic4]A::a01064 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01064 ldsfld int32 [rvastatic4]A::a01064 ldc.i4 65 beq a01064 newobj instance void [mscorlib]System.Exception::.ctor() throw a01064: ldsfld int16 [rvastatic4]A::a01065 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01065 ldsfld int16 [rvastatic4]A::a01065 ldc.i4 66 beq a01065 newobj instance void [mscorlib]System.Exception::.ctor() throw a01065: ldsfld int8 [rvastatic4]A::a01066 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01066 ldsfld int8 [rvastatic4]A::a01066 ldc.i4 67 beq a01066 newobj instance void [mscorlib]System.Exception::.ctor() throw a01066: ldsfld int16 [rvastatic4]A::a01067 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01067 ldsfld int16 [rvastatic4]A::a01067 ldc.i4 68 beq a01067 newobj instance void [mscorlib]System.Exception::.ctor() throw a01067: ldsfld int32 [rvastatic4]A::a01068 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01068 ldsfld int32 [rvastatic4]A::a01068 ldc.i4 69 beq a01068 newobj instance void [mscorlib]System.Exception::.ctor() throw a01068: ldsfld float32 [rvastatic4]A::a01069 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01069 ldsfld float32 [rvastatic4]A::a01069 ldc.r4 70.0 beq a01069 newobj instance void [mscorlib]System.Exception::.ctor() throw a01069: ldsfld float32 [rvastatic4]A::a01070 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01070 ldsfld float32 [rvastatic4]A::a01070 ldc.r4 71.0 beq a01070 newobj instance void [mscorlib]System.Exception::.ctor() throw a01070: ldsfld int16 [rvastatic4]A::a01071 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01071 ldsfld int16 [rvastatic4]A::a01071 ldc.i4 72 beq a01071 newobj instance void [mscorlib]System.Exception::.ctor() throw a01071: ldsfld float32 [rvastatic4]A::a01072 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01072 ldsfld float32 [rvastatic4]A::a01072 ldc.r4 73.0 beq a01072 newobj instance void [mscorlib]System.Exception::.ctor() throw a01072: ldsfld int64 [rvastatic4]A::a01073 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01073 ldsfld int64 [rvastatic4]A::a01073 ldc.i8 74 beq a01073 newobj instance void [mscorlib]System.Exception::.ctor() throw a01073: ldsfld int64 [rvastatic4]A::a01074 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01074 ldsfld int64 [rvastatic4]A::a01074 ldc.i8 75 beq a01074 newobj instance void [mscorlib]System.Exception::.ctor() throw a01074: ldsfld int32 [rvastatic4]A::a01075 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01075 ldsfld int32 [rvastatic4]A::a01075 ldc.i4 76 beq a01075 newobj instance void [mscorlib]System.Exception::.ctor() throw a01075: ldsfld int8 [rvastatic4]A::a01076 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01076 ldsfld int8 [rvastatic4]A::a01076 ldc.i4 77 beq a01076 newobj instance void [mscorlib]System.Exception::.ctor() throw a01076: ldsfld int32 [rvastatic4]A::a01077 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01077 ldsfld int32 [rvastatic4]A::a01077 ldc.i4 78 beq a01077 newobj instance void [mscorlib]System.Exception::.ctor() throw a01077: ldsfld int16 [rvastatic4]A::a01078 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01078 ldsfld int16 [rvastatic4]A::a01078 ldc.i4 79 beq a01078 newobj instance void [mscorlib]System.Exception::.ctor() throw a01078: ldsfld float32 [rvastatic4]A::a01079 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01079 ldsfld float32 [rvastatic4]A::a01079 ldc.r4 80.0 beq a01079 newobj instance void [mscorlib]System.Exception::.ctor() throw a01079: ldsfld float32 [rvastatic4]A::a01080 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01080 ldsfld float32 [rvastatic4]A::a01080 ldc.r4 81.0 beq a01080 newobj instance void [mscorlib]System.Exception::.ctor() throw a01080: ldsfld float32 [rvastatic4]A::a01081 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01081 ldsfld float32 [rvastatic4]A::a01081 ldc.r4 82.0 beq a01081 newobj instance void [mscorlib]System.Exception::.ctor() throw a01081: ldsfld int32 [rvastatic4]A::a01082 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01082 ldsfld int32 [rvastatic4]A::a01082 ldc.i4 83 beq a01082 newobj instance void [mscorlib]System.Exception::.ctor() throw a01082: ldsfld int8 [rvastatic4]A::a01083 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01083 ldsfld int8 [rvastatic4]A::a01083 ldc.i4 84 beq a01083 newobj instance void [mscorlib]System.Exception::.ctor() throw a01083: ldsfld int64 [rvastatic4]A::a01084 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01084 ldsfld int64 [rvastatic4]A::a01084 ldc.i8 85 beq a01084 newobj instance void [mscorlib]System.Exception::.ctor() throw a01084: ldsfld int64 [rvastatic4]A::a01085 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01085 ldsfld int64 [rvastatic4]A::a01085 ldc.i8 86 beq a01085 newobj instance void [mscorlib]System.Exception::.ctor() throw a01085: ldsfld int32 [rvastatic4]A::a01086 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01086 ldsfld int32 [rvastatic4]A::a01086 ldc.i4 87 beq a01086 newobj instance void [mscorlib]System.Exception::.ctor() throw a01086: ldsfld int32 [rvastatic4]A::a01087 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01087 ldsfld int32 [rvastatic4]A::a01087 ldc.i4 88 beq a01087 newobj instance void [mscorlib]System.Exception::.ctor() throw a01087: ldsfld int8 [rvastatic4]A::a01088 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01088 ldsfld int8 [rvastatic4]A::a01088 ldc.i4 89 beq a01088 newobj instance void [mscorlib]System.Exception::.ctor() throw a01088: ldsfld int64 [rvastatic4]A::a01089 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01089 ldsfld int64 [rvastatic4]A::a01089 ldc.i8 90 beq a01089 newobj instance void [mscorlib]System.Exception::.ctor() throw a01089: ldsfld int8 [rvastatic4]A::a01090 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01090 ldsfld int8 [rvastatic4]A::a01090 ldc.i4 91 beq a01090 newobj instance void [mscorlib]System.Exception::.ctor() throw a01090: ldsfld int16 [rvastatic4]A::a01091 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01091 ldsfld int16 [rvastatic4]A::a01091 ldc.i4 92 beq a01091 newobj instance void [mscorlib]System.Exception::.ctor() throw a01091: ldsfld float32 [rvastatic4]A::a01092 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01092 ldsfld float32 [rvastatic4]A::a01092 ldc.r4 93.0 beq a01092 newobj instance void [mscorlib]System.Exception::.ctor() throw a01092: ldsfld int64 [rvastatic4]A::a01093 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01093 ldsfld int64 [rvastatic4]A::a01093 ldc.i8 94 beq a01093 newobj instance void [mscorlib]System.Exception::.ctor() throw a01093: ldsfld int64 [rvastatic4]A::a01094 ldc.i8 1 add stsfld int64 [rvastatic4]A::a01094 ldsfld int64 [rvastatic4]A::a01094 ldc.i8 95 beq a01094 newobj instance void [mscorlib]System.Exception::.ctor() throw a01094: ldsfld int8 [rvastatic4]A::a01095 ldc.i4 1 add stsfld int8 [rvastatic4]A::a01095 ldsfld int8 [rvastatic4]A::a01095 ldc.i4 96 beq a01095 newobj instance void [mscorlib]System.Exception::.ctor() throw a01095: ldsfld float32 [rvastatic4]A::a01096 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01096 ldsfld float32 [rvastatic4]A::a01096 ldc.r4 97.0 beq a01096 newobj instance void [mscorlib]System.Exception::.ctor() throw a01096: ldsfld int16 [rvastatic4]A::a01097 ldc.i4 1 add stsfld int16 [rvastatic4]A::a01097 ldsfld int16 [rvastatic4]A::a01097 ldc.i4 98 beq a01097 newobj instance void [mscorlib]System.Exception::.ctor() throw a01097: ldsfld float32 [rvastatic4]A::a01098 ldc.r4 1 add stsfld float32 [rvastatic4]A::a01098 ldsfld float32 [rvastatic4]A::a01098 ldc.r4 99.0 beq a01098 newobj instance void [mscorlib]System.Exception::.ctor() throw a01098: ldsfld int32 [rvastatic4]A::a01099 ldc.i4 1 add stsfld int32 [rvastatic4]A::a01099 ldsfld int32 [rvastatic4]A::a01099 ldc.i4 100 beq a01099 newobj instance void [mscorlib]System.Exception::.ctor() throw a01099: ldsfld int64 [rvastatic4]A::a010100 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010100 ldsfld int64 [rvastatic4]A::a010100 ldc.i8 101 beq a010100 newobj instance void [mscorlib]System.Exception::.ctor() throw a010100: ldsfld int32 [rvastatic4]A::a010101 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010101 ldsfld int32 [rvastatic4]A::a010101 ldc.i4 102 beq a010101 newobj instance void [mscorlib]System.Exception::.ctor() throw a010101: ldsfld float32 [rvastatic4]A::a010102 ldc.r4 1 add stsfld float32 [rvastatic4]A::a010102 ldsfld float32 [rvastatic4]A::a010102 ldc.r4 103.0 beq a010102 newobj instance void [mscorlib]System.Exception::.ctor() throw a010102: ldsfld int64 [rvastatic4]A::a010103 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010103 ldsfld int64 [rvastatic4]A::a010103 ldc.i8 104 beq a010103 newobj instance void [mscorlib]System.Exception::.ctor() throw a010103: ldsfld int32 [rvastatic4]A::a010104 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010104 ldsfld int32 [rvastatic4]A::a010104 ldc.i4 105 beq a010104 newobj instance void [mscorlib]System.Exception::.ctor() throw a010104: ldsfld int16 [rvastatic4]A::a010105 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010105 ldsfld int16 [rvastatic4]A::a010105 ldc.i4 106 beq a010105 newobj instance void [mscorlib]System.Exception::.ctor() throw a010105: ldsfld int16 [rvastatic4]A::a010106 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010106 ldsfld int16 [rvastatic4]A::a010106 ldc.i4 107 beq a010106 newobj instance void [mscorlib]System.Exception::.ctor() throw a010106: ldsfld float32 [rvastatic4]A::a010107 ldc.r4 1 add stsfld float32 [rvastatic4]A::a010107 ldsfld float32 [rvastatic4]A::a010107 ldc.r4 108.0 beq a010107 newobj instance void [mscorlib]System.Exception::.ctor() throw a010107: ldsfld int32 [rvastatic4]A::a010108 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010108 ldsfld int32 [rvastatic4]A::a010108 ldc.i4 109 beq a010108 newobj instance void [mscorlib]System.Exception::.ctor() throw a010108: ldsfld int16 [rvastatic4]A::a010109 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010109 ldsfld int16 [rvastatic4]A::a010109 ldc.i4 110 beq a010109 newobj instance void [mscorlib]System.Exception::.ctor() throw a010109: ldsfld int32 [rvastatic4]A::a010110 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010110 ldsfld int32 [rvastatic4]A::a010110 ldc.i4 111 beq a010110 newobj instance void [mscorlib]System.Exception::.ctor() throw a010110: ldsfld int32 [rvastatic4]A::a010111 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010111 ldsfld int32 [rvastatic4]A::a010111 ldc.i4 112 beq a010111 newobj instance void [mscorlib]System.Exception::.ctor() throw a010111: ldsfld int32 [rvastatic4]A::a010112 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010112 ldsfld int32 [rvastatic4]A::a010112 ldc.i4 113 beq a010112 newobj instance void [mscorlib]System.Exception::.ctor() throw a010112: ldsfld int64 [rvastatic4]A::a010113 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010113 ldsfld int64 [rvastatic4]A::a010113 ldc.i8 114 beq a010113 newobj instance void [mscorlib]System.Exception::.ctor() throw a010113: ldsfld int64 [rvastatic4]A::a010114 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010114 ldsfld int64 [rvastatic4]A::a010114 ldc.i8 115 beq a010114 newobj instance void [mscorlib]System.Exception::.ctor() throw a010114: ldsfld int16 [rvastatic4]A::a010115 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010115 ldsfld int16 [rvastatic4]A::a010115 ldc.i4 116 beq a010115 newobj instance void [mscorlib]System.Exception::.ctor() throw a010115: ldsfld int64 [rvastatic4]A::a010116 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010116 ldsfld int64 [rvastatic4]A::a010116 ldc.i8 117 beq a010116 newobj instance void [mscorlib]System.Exception::.ctor() throw a010116: ldsfld int64 [rvastatic4]A::a010117 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010117 ldsfld int64 [rvastatic4]A::a010117 ldc.i8 118 beq a010117 newobj instance void [mscorlib]System.Exception::.ctor() throw a010117: ldsfld int32 [rvastatic4]A::a010118 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010118 ldsfld int32 [rvastatic4]A::a010118 ldc.i4 119 beq a010118 newobj instance void [mscorlib]System.Exception::.ctor() throw a010118: ldsfld int64 [rvastatic4]A::a010119 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010119 ldsfld int64 [rvastatic4]A::a010119 ldc.i8 120 beq a010119 newobj instance void [mscorlib]System.Exception::.ctor() throw a010119: ldsfld int64 [rvastatic4]A::a010120 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010120 ldsfld int64 [rvastatic4]A::a010120 ldc.i8 121 beq a010120 newobj instance void [mscorlib]System.Exception::.ctor() throw a010120: ldsfld int64 [rvastatic4]A::a010121 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010121 ldsfld int64 [rvastatic4]A::a010121 ldc.i8 122 beq a010121 newobj instance void [mscorlib]System.Exception::.ctor() throw a010121: ldsfld int16 [rvastatic4]A::a010122 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010122 ldsfld int16 [rvastatic4]A::a010122 ldc.i4 123 beq a010122 newobj instance void [mscorlib]System.Exception::.ctor() throw a010122: ldsfld int64 [rvastatic4]A::a010123 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010123 ldsfld int64 [rvastatic4]A::a010123 ldc.i8 124 beq a010123 newobj instance void [mscorlib]System.Exception::.ctor() throw a010123: ldsfld int64 [rvastatic4]A::a010124 ldc.i8 1 add stsfld int64 [rvastatic4]A::a010124 ldsfld int64 [rvastatic4]A::a010124 ldc.i8 125 beq a010124 newobj instance void [mscorlib]System.Exception::.ctor() throw a010124: ldsfld int32 [rvastatic4]A::a010125 ldc.i4 1 add stsfld int32 [rvastatic4]A::a010125 ldsfld int32 [rvastatic4]A::a010125 ldc.i4 126 beq a010125 newobj instance void [mscorlib]System.Exception::.ctor() throw a010125: ldsfld int16 [rvastatic4]A::a010126 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010126 ldsfld int16 [rvastatic4]A::a010126 ldc.i4 127 beq a010126 newobj instance void [mscorlib]System.Exception::.ctor() throw a010126: ldsfld int16 [rvastatic4]A::a010127 ldc.i4 1 add stsfld int16 [rvastatic4]A::a010127 ldsfld int16 [rvastatic4]A::a010127 ldc.i4 128 beq a010127 newobj instance void [mscorlib]System.Exception::.ctor() throw a010127: ret} .method static int32 Main(string[] args){.entrypoint .maxstack 5 .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( 01 00 00 00 ) call void [rvastatic4]A::V1() call void [rvastatic4]A::V2() call void [rvastatic4]A::V3() call void [rvastatic4]A::V4() call void [rvastatic4]A::V5() call void [rvastatic4]A::V6() ldc.i4 100 ret} .field public static int32 a0100 at b0100 .field private static int32 aALIGN10100 at bALIGN10100 .field public static int64 a0101 at b0101 .field public static float32 a0102 at b0102 .field private static int32 aALIGN10102 at bALIGN10102 .field public static int16 a0103 at b0103 .field private static int16 aALIGN10103 at bALIGN10103 .field private static int32 aALIGN20103 at bALIGN20103 .field public static int16 a0104 at b0104 .field private static int16 aALIGN10104 at bALIGN10104 .field private static int32 aALIGN20104 at bALIGN20104 .field public static int64 a0105 at b0105 .field public static int16 a0106 at b0106 .field private static int16 aALIGN10106 at bALIGN10106 .field private static int32 aALIGN20106 at bALIGN20106 .field public static int8 a0107 at b0107 .field private static int32 aALIGN10107 at bALIGN10107 .field private static int16 aALIGN20107 at bALIGN20107 .field private static int8 aALIGN20107 at bALIGN30107 .field public static int64 a0108 at b0108 .field public static int32 a0109 at b0109 .field private static int32 aALIGN10109 at bALIGN10109 .field public static int16 a01010 at b01010 .field private static int16 aALIGN101010 at bALIGN101010 .field private static int32 aALIGN201010 at bALIGN201010 .field public static float32 a01011 at b01011 .field private static int32 aALIGN101011 at bALIGN101011 .field public static int16 a01012 at b01012 .field private static int16 aALIGN101012 at bALIGN101012 .field private static int32 aALIGN201012 at bALIGN201012 .field public static float32 a01013 at b01013 .field private static int32 aALIGN101013 at bALIGN101013 .field public static float32 a01014 at b01014 .field private static int32 aALIGN101014 at bALIGN101014 .field public static int8 a01015 at b01015 .field private static int32 aALIGN101015 at bALIGN101015 .field private static int16 aALIGN201015 at bALIGN201015 .field private static int8 aALIGN201015 at bALIGN301015 .field public static float32 a01016 at b01016 .field private static int32 aALIGN101016 at bALIGN101016 .field public static int8 a01017 at b01017 .field private static int32 aALIGN101017 at bALIGN101017 .field private static int16 aALIGN201017 at bALIGN201017 .field private static int8 aALIGN201017 at bALIGN301017 .field public static float32 a01018 at b01018 .field private static int32 aALIGN101018 at bALIGN101018 .field public static float32 a01019 at b01019 .field private static int32 aALIGN101019 at bALIGN101019 .field public static int8 a01020 at b01020 .field private static int32 aALIGN101020 at bALIGN101020 .field private static int16 aALIGN201020 at bALIGN201020 .field private static int8 aALIGN201020 at bALIGN301020 .field public static float32 a01021 at b01021 .field private static int32 aALIGN101021 at bALIGN101021 .field public static int64 a01022 at b01022 .field public static int8 a01023 at b01023 .field private static int32 aALIGN101023 at bALIGN101023 .field private static int16 aALIGN201023 at bALIGN201023 .field private static int8 aALIGN201023 at bALIGN301023 .field public static int32 a01024 at b01024 .field private static int32 aALIGN101024 at bALIGN101024 .field public static int64 a01025 at b01025 .field public static int16 a01026 at b01026 .field private static int16 aALIGN101026 at bALIGN101026 .field private static int32 aALIGN201026 at bALIGN201026 .field public static int8 a01027 at b01027 .field private static int32 aALIGN101027 at bALIGN101027 .field private static int16 aALIGN201027 at bALIGN201027 .field private static int8 aALIGN201027 at bALIGN301027 .field public static int16 a01028 at b01028 .field private static int16 aALIGN101028 at bALIGN101028 .field private static int32 aALIGN201028 at bALIGN201028 .field public static int16 a01029 at b01029 .field private static int16 aALIGN101029 at bALIGN101029 .field private static int32 aALIGN201029 at bALIGN201029 .field public static int8 a01030 at b01030 .field private static int32 aALIGN101030 at bALIGN101030 .field private static int16 aALIGN201030 at bALIGN201030 .field private static int8 aALIGN201030 at bALIGN301030 .field public static int8 a01031 at b01031 .field private static int32 aALIGN101031 at bALIGN101031 .field private static int16 aALIGN201031 at bALIGN201031 .field private static int8 aALIGN201031 at bALIGN301031 .field public static int64 a01032 at b01032 .field public static float32 a01033 at b01033 .field private static int32 aALIGN101033 at bALIGN101033 .field public static int16 a01034 at b01034 .field private static int16 aALIGN101034 at bALIGN101034 .field private static int32 aALIGN201034 at bALIGN201034 .field public static int8 a01035 at b01035 .field private static int32 aALIGN101035 at bALIGN101035 .field private static int16 aALIGN201035 at bALIGN201035 .field private static int8 aALIGN201035 at bALIGN301035 .field public static int8 a01036 at b01036 .field private static int32 aALIGN101036 at bALIGN101036 .field private static int16 aALIGN201036 at bALIGN201036 .field private static int8 aALIGN201036 at bALIGN301036 .field public static int32 a01037 at b01037 .field private static int32 aALIGN101037 at bALIGN101037 .field public static int16 a01038 at b01038 .field private static int16 aALIGN101038 at bALIGN101038 .field private static int32 aALIGN201038 at bALIGN201038 .field public static int8 a01039 at b01039 .field private static int32 aALIGN101039 at bALIGN101039 .field private static int16 aALIGN201039 at bALIGN201039 .field private static int8 aALIGN201039 at bALIGN301039 .field public static int8 a01040 at b01040 .field private static int32 aALIGN101040 at bALIGN101040 .field private static int16 aALIGN201040 at bALIGN201040 .field private static int8 aALIGN201040 at bALIGN301040 .field public static int32 a01041 at b01041 .field private static int32 aALIGN101041 at bALIGN101041 .field public static int64 a01042 at b01042 .field public static int16 a01043 at b01043 .field private static int16 aALIGN101043 at bALIGN101043 .field private static int32 aALIGN201043 at bALIGN201043 .field public static int64 a01044 at b01044 .field public static int64 a01045 at b01045 .field public static float32 a01046 at b01046 .field private static int32 aALIGN101046 at bALIGN101046 .field public static int16 a01047 at b01047 .field private static int16 aALIGN101047 at bALIGN101047 .field private static int32 aALIGN201047 at bALIGN201047 .field public static int64 a01048 at b01048 .field public static int16 a01049 at b01049 .field private static int16 aALIGN101049 at bALIGN101049 .field private static int32 aALIGN201049 at bALIGN201049 .field public static int32 a01050 at b01050 .field private static int32 aALIGN101050 at bALIGN101050 .field public static int16 a01051 at b01051 .field private static int16 aALIGN101051 at bALIGN101051 .field private static int32 aALIGN201051 at bALIGN201051 .field public static int32 a01052 at b01052 .field private static int32 aALIGN101052 at bALIGN101052 .field public static int16 a01053 at b01053 .field private static int16 aALIGN101053 at bALIGN101053 .field private static int32 aALIGN201053 at bALIGN201053 .field public static float32 a01054 at b01054 .field private static int32 aALIGN101054 at bALIGN101054 .field public static int64 a01055 at b01055 .field public static float32 a01056 at b01056 .field private static int32 aALIGN101056 at bALIGN101056 .field public static int64 a01057 at b01057 .field public static int64 a01058 at b01058 .field public static int64 a01059 at b01059 .field public static int16 a01060 at b01060 .field private static int16 aALIGN101060 at bALIGN101060 .field private static int32 aALIGN201060 at bALIGN201060 .field public static int8 a01061 at b01061 .field private static int32 aALIGN101061 at bALIGN101061 .field private static int16 aALIGN201061 at bALIGN201061 .field private static int8 aALIGN201061 at bALIGN301061 .field public static int64 a01062 at b01062 .field public static int16 a01063 at b01063 .field private static int16 aALIGN101063 at bALIGN101063 .field private static int32 aALIGN201063 at bALIGN201063 .field public static int32 a01064 at b01064 .field private static int32 aALIGN101064 at bALIGN101064 .field public static int16 a01065 at b01065 .field private static int16 aALIGN101065 at bALIGN101065 .field private static int32 aALIGN201065 at bALIGN201065 .field public static int8 a01066 at b01066 .field private static int32 aALIGN101066 at bALIGN101066 .field private static int16 aALIGN201066 at bALIGN201066 .field private static int8 aALIGN201066 at bALIGN301066 .field public static int16 a01067 at b01067 .field private static int16 aALIGN101067 at bALIGN101067 .field private static int32 aALIGN201067 at bALIGN201067 .field public static int32 a01068 at b01068 .field private static int32 aALIGN101068 at bALIGN101068 .field public static float32 a01069 at b01069 .field private static int32 aALIGN101069 at bALIGN101069 .field public static float32 a01070 at b01070 .field private static int32 aALIGN101070 at bALIGN101070 .field public static int16 a01071 at b01071 .field private static int16 aALIGN101071 at bALIGN101071 .field private static int32 aALIGN201071 at bALIGN201071 .field public static float32 a01072 at b01072 .field private static int32 aALIGN101072 at bALIGN101072 .field public static int64 a01073 at b01073 .field public static int64 a01074 at b01074 .field public static int32 a01075 at b01075 .field private static int32 aALIGN101075 at bALIGN101075 .field public static int8 a01076 at b01076 .field private static int32 aALIGN101076 at bALIGN101076 .field private static int16 aALIGN201076 at bALIGN201076 .field private static int8 aALIGN201076 at bALIGN301076 .field public static int32 a01077 at b01077 .field private static int32 aALIGN101077 at bALIGN101077 .field public static int16 a01078 at b01078 .field private static int16 aALIGN101078 at bALIGN101078 .field private static int32 aALIGN201078 at bALIGN201078 .field public static float32 a01079 at b01079 .field private static int32 aALIGN101079 at bALIGN101079 .field public static float32 a01080 at b01080 .field private static int32 aALIGN101080 at bALIGN101080 .field public static float32 a01081 at b01081 .field private static int32 aALIGN101081 at bALIGN101081 .field public static int32 a01082 at b01082 .field private static int32 aALIGN101082 at bALIGN101082 .field public static int8 a01083 at b01083 .field private static int32 aALIGN101083 at bALIGN101083 .field private static int16 aALIGN201083 at bALIGN201083 .field private static int8 aALIGN201083 at bALIGN301083 .field public static int64 a01084 at b01084 .field public static int64 a01085 at b01085 .field public static int32 a01086 at b01086 .field private static int32 aALIGN101086 at bALIGN101086 .field public static int32 a01087 at b01087 .field private static int32 aALIGN101087 at bALIGN101087 .field public static int8 a01088 at b01088 .field private static int32 aALIGN101088 at bALIGN101088 .field private static int16 aALIGN201088 at bALIGN201088 .field private static int8 aALIGN201088 at bALIGN301088 .field public static int64 a01089 at b01089 .field public static int8 a01090 at b01090 .field private static int32 aALIGN101090 at bALIGN101090 .field private static int16 aALIGN201090 at bALIGN201090 .field private static int8 aALIGN201090 at bALIGN301090 .field public static int16 a01091 at b01091 .field private static int16 aALIGN101091 at bALIGN101091 .field private static int32 aALIGN201091 at bALIGN201091 .field public static float32 a01092 at b01092 .field private static int32 aALIGN101092 at bALIGN101092 .field public static int64 a01093 at b01093 .field public static int64 a01094 at b01094 .field public static int8 a01095 at b01095 .field private static int32 aALIGN101095 at bALIGN101095 .field private static int16 aALIGN201095 at bALIGN201095 .field private static int8 aALIGN201095 at bALIGN301095 .field public static float32 a01096 at b01096 .field private static int32 aALIGN101096 at bALIGN101096 .field public static int16 a01097 at b01097 .field private static int16 aALIGN101097 at bALIGN101097 .field private static int32 aALIGN201097 at bALIGN201097 .field public static float32 a01098 at b01098 .field private static int32 aALIGN101098 at bALIGN101098 .field public static int32 a01099 at b01099 .field private static int32 aALIGN101099 at bALIGN101099 .field public static int64 a010100 at b010100 .field public static int32 a010101 at b010101 .field private static int32 aALIGN1010101 at bALIGN1010101 .field public static float32 a010102 at b010102 .field private static int32 aALIGN1010102 at bALIGN1010102 .field public static int64 a010103 at b010103 .field public static int32 a010104 at b010104 .field private static int32 aALIGN1010104 at bALIGN1010104 .field public static int16 a010105 at b010105 .field private static int16 aALIGN1010105 at bALIGN1010105 .field private static int32 aALIGN2010105 at bALIGN2010105 .field public static int16 a010106 at b010106 .field private static int16 aALIGN1010106 at bALIGN1010106 .field private static int32 aALIGN2010106 at bALIGN2010106 .field public static float32 a010107 at b010107 .field private static int32 aALIGN1010107 at bALIGN1010107 .field public static int32 a010108 at b010108 .field private static int32 aALIGN1010108 at bALIGN1010108 .field public static int16 a010109 at b010109 .field private static int16 aALIGN1010109 at bALIGN1010109 .field private static int32 aALIGN2010109 at bALIGN2010109 .field public static int32 a010110 at b010110 .field private static int32 aALIGN1010110 at bALIGN1010110 .field public static int32 a010111 at b010111 .field private static int32 aALIGN1010111 at bALIGN1010111 .field public static int32 a010112 at b010112 .field private static int32 aALIGN1010112 at bALIGN1010112 .field public static int64 a010113 at b010113 .field public static int64 a010114 at b010114 .field public static int16 a010115 at b010115 .field private static int16 aALIGN1010115 at bALIGN1010115 .field private static int32 aALIGN2010115 at bALIGN2010115 .field public static int64 a010116 at b010116 .field public static int64 a010117 at b010117 .field public static int32 a010118 at b010118 .field private static int32 aALIGN1010118 at bALIGN1010118 .field public static int64 a010119 at b010119 .field public static int64 a010120 at b010120 .field public static int64 a010121 at b010121 .field public static int16 a010122 at b010122 .field private static int16 aALIGN1010122 at bALIGN1010122 .field private static int32 aALIGN2010122 at bALIGN2010122 .field public static int64 a010123 at b010123 .field public static int64 a010124 at b010124 .field public static int32 a010125 at b010125 .field private static int32 aALIGN1010125 at bALIGN1010125 .field public static int16 a010126 at b010126 .field private static int16 aALIGN1010126 at bALIGN1010126 .field private static int32 aALIGN2010126 at bALIGN2010126 .field public static int16 a010127 at b010127 .field private static int16 aALIGN1010127 at bALIGN1010127 .field private static int32 aALIGN2010127 at bALIGN2010127 } .data b0100 = int32(0) .data bALIGN10100 = int32(0) .data b0101 = int64(1) .data b0102 = float32(2.0) .data bALIGN10102 = int32(0) .data b0103 = int16(3) .data bALIGN10103 = int16(0) .data bALIGN20103 = int32(0) .data b0104 = int16(4) .data bALIGN10104 = int16(0) .data bALIGN20104 = int32(0) .data b0105 = int64(5) .data b0106 = int16(6) .data bALIGN10106 = int16(0) .data bALIGN20106 = int32(0) .data b0107 = int8(7) .data bALIGN10107 = int32(0) .data bALIGN20107 = int16(0) .data bALIGN30107 = int8(0) .data b0108 = int64(8) .data b0109 = int32(9) .data bALIGN10109 = int32(0) .data b01010 = int16(10) .data bALIGN101010 = int16(0) .data bALIGN201010 = int32(0) .data b01011 = float32(11.0) .data bALIGN101011 = int32(0) .data b01012 = int16(12) .data bALIGN101012 = int16(0) .data bALIGN201012 = int32(0) .data b01013 = float32(13.0) .data bALIGN101013 = int32(0) .data b01014 = float32(14.0) .data bALIGN101014 = int32(0) .data b01015 = int8(15) .data bALIGN101015 = int32(0) .data bALIGN201015 = int16(0) .data bALIGN301015 = int8(0) .data b01016 = float32(16.0) .data bALIGN101016 = int32(0) .data b01017 = int8(17) .data bALIGN101017 = int32(0) .data bALIGN201017 = int16(0) .data bALIGN301017 = int8(0) .data b01018 = float32(18.0) .data bALIGN101018 = int32(0) .data b01019 = float32(19.0) .data bALIGN101019 = int32(0) .data b01020 = int8(20) .data bALIGN101020 = int32(0) .data bALIGN201020 = int16(0) .data bALIGN301020 = int8(0) .data b01021 = float32(21.0) .data bALIGN101021 = int32(0) .data b01022 = int64(22) .data b01023 = int8(23) .data bALIGN101023 = int32(0) .data bALIGN201023 = int16(0) .data bALIGN301023 = int8(0) .data b01024 = int32(24) .data bALIGN101024 = int32(0) .data b01025 = int64(25) .data b01026 = int16(26) .data bALIGN101026 = int16(0) .data bALIGN201026 = int32(0) .data b01027 = int8(27) .data bALIGN101027 = int32(0) .data bALIGN201027 = int16(0) .data bALIGN301027 = int8(0) .data b01028 = int16(28) .data bALIGN101028 = int16(0) .data bALIGN201028 = int32(0) .data b01029 = int16(29) .data bALIGN101029 = int16(0) .data bALIGN201029 = int32(0) .data b01030 = int8(30) .data bALIGN101030 = int32(0) .data bALIGN201030 = int16(0) .data bALIGN301030 = int8(0) .data b01031 = int8(31) .data bALIGN101031 = int32(0) .data bALIGN201031 = int16(0) .data bALIGN301031 = int8(0) .data b01032 = int64(32) .data b01033 = float32(33.0) .data bALIGN101033 = int32(0) .data b01034 = int16(34) .data bALIGN101034 = int16(0) .data bALIGN201034 = int32(0) .data b01035 = int8(35) .data bALIGN101035 = int32(0) .data bALIGN201035 = int16(0) .data bALIGN301035 = int8(0) .data b01036 = int8(36) .data bALIGN101036 = int32(0) .data bALIGN201036 = int16(0) .data bALIGN301036 = int8(0) .data b01037 = int32(37) .data bALIGN101037 = int32(0) .data b01038 = int16(38) .data bALIGN101038 = int16(0) .data bALIGN201038 = int32(0) .data b01039 = int8(39) .data bALIGN101039 = int32(0) .data bALIGN201039 = int16(0) .data bALIGN301039 = int8(0) .data b01040 = int8(40) .data bALIGN101040 = int32(0) .data bALIGN201040 = int16(0) .data bALIGN301040 = int8(0) .data b01041 = int32(41) .data bALIGN101041 = int32(0) .data b01042 = int64(42) .data b01043 = int16(43) .data bALIGN101043 = int16(0) .data bALIGN201043 = int32(0) .data b01044 = int64(44) .data b01045 = int64(45) .data b01046 = float32(46.0) .data bALIGN101046 = int32(0) .data b01047 = int16(47) .data bALIGN101047 = int16(0) .data bALIGN201047 = int32(0) .data b01048 = int64(48) .data b01049 = int16(49) .data bALIGN101049 = int16(0) .data bALIGN201049 = int32(0) .data b01050 = int32(50) .data bALIGN101050 = int32(0) .data b01051 = int16(51) .data bALIGN101051 = int16(0) .data bALIGN201051 = int32(0) .data b01052 = int32(52) .data bALIGN101052 = int32(0) .data b01053 = int16(53) .data bALIGN101053 = int16(0) .data bALIGN201053 = int32(0) .data b01054 = float32(54.0) .data bALIGN101054 = int32(0) .data b01055 = int64(55) .data b01056 = float32(56.0) .data bALIGN101056 = int32(0) .data b01057 = int64(57) .data b01058 = int64(58) .data b01059 = int64(59) .data b01060 = int16(60) .data bALIGN101060 = int16(0) .data bALIGN201060 = int32(0) .data b01061 = int8(61) .data bALIGN101061 = int32(0) .data bALIGN201061 = int16(0) .data bALIGN301061 = int8(0) .data b01062 = int64(62) .data b01063 = int16(63) .data bALIGN101063 = int16(0) .data bALIGN201063 = int32(0) .data b01064 = int32(64) .data bALIGN101064 = int32(0) .data b01065 = int16(65) .data bALIGN101065 = int16(0) .data bALIGN201065 = int32(0) .data b01066 = int8(66) .data bALIGN101066 = int32(0) .data bALIGN201066 = int16(0) .data bALIGN301066 = int8(0) .data b01067 = int16(67) .data bALIGN101067 = int16(0) .data bALIGN201067 = int32(0) .data b01068 = int32(68) .data bALIGN101068 = int32(0) .data b01069 = float32(69.0) .data bALIGN101069 = int32(0) .data b01070 = float32(70.0) .data bALIGN101070 = int32(0) .data b01071 = int16(71) .data bALIGN101071 = int16(0) .data bALIGN201071 = int32(0) .data b01072 = float32(72.0) .data bALIGN101072 = int32(0) .data b01073 = int64(73) .data b01074 = int64(74) .data b01075 = int32(75) .data bALIGN101075 = int32(0) .data b01076 = int8(76) .data bALIGN101076 = int32(0) .data bALIGN201076 = int16(0) .data bALIGN301076 = int8(0) .data b01077 = int32(77) .data bALIGN101077 = int32(0) .data b01078 = int16(78) .data bALIGN101078 = int16(0) .data bALIGN201078 = int32(0) .data b01079 = float32(79.0) .data bALIGN101079 = int32(0) .data b01080 = float32(80.0) .data bALIGN101080 = int32(0) .data b01081 = float32(81.0) .data bALIGN101081 = int32(0) .data b01082 = int32(82) .data bALIGN101082 = int32(0) .data b01083 = int8(83) .data bALIGN101083 = int32(0) .data bALIGN201083 = int16(0) .data bALIGN301083 = int8(0) .data b01084 = int64(84) .data b01085 = int64(85) .data b01086 = int32(86) .data bALIGN101086 = int32(0) .data b01087 = int32(87) .data bALIGN101087 = int32(0) .data b01088 = int8(88) .data bALIGN101088 = int32(0) .data bALIGN201088 = int16(0) .data bALIGN301088 = int8(0) .data b01089 = int64(89) .data b01090 = int8(90) .data bALIGN101090 = int32(0) .data bALIGN201090 = int16(0) .data bALIGN301090 = int8(0) .data b01091 = int16(91) .data bALIGN101091 = int16(0) .data bALIGN201091 = int32(0) .data b01092 = float32(92.0) .data bALIGN101092 = int32(0) .data b01093 = int64(93) .data b01094 = int64(94) .data b01095 = int8(95) .data bALIGN101095 = int32(0) .data bALIGN201095 = int16(0) .data bALIGN301095 = int8(0) .data b01096 = float32(96.0) .data bALIGN101096 = int32(0) .data b01097 = int16(97) .data bALIGN101097 = int16(0) .data bALIGN201097 = int32(0) .data b01098 = float32(98.0) .data bALIGN101098 = int32(0) .data b01099 = int32(99) .data bALIGN101099 = int32(0) .data b010100 = int64(100) .data b010101 = int32(101) .data bALIGN1010101 = int32(0) .data b010102 = float32(102.0) .data bALIGN1010102 = int32(0) .data b010103 = int64(103) .data b010104 = int32(104) .data bALIGN1010104 = int32(0) .data b010105 = int16(105) .data bALIGN1010105 = int16(0) .data bALIGN2010105 = int32(0) .data b010106 = int16(106) .data bALIGN1010106 = int16(0) .data bALIGN2010106 = int32(0) .data b010107 = float32(107.0) .data bALIGN1010107 = int32(0) .data b010108 = int32(108) .data bALIGN1010108 = int32(0) .data b010109 = int16(109) .data bALIGN1010109 = int16(0) .data bALIGN2010109 = int32(0) .data b010110 = int32(110) .data bALIGN1010110 = int32(0) .data b010111 = int32(111) .data bALIGN1010111 = int32(0) .data b010112 = int32(112) .data bALIGN1010112 = int32(0) .data b010113 = int64(113) .data b010114 = int64(114) .data b010115 = int16(115) .data bALIGN1010115 = int16(0) .data bALIGN2010115 = int32(0) .data b010116 = int64(116) .data b010117 = int64(117) .data b010118 = int32(118) .data bALIGN1010118 = int32(0) .data b010119 = int64(119) .data b010120 = int64(120) .data b010121 = int64(121) .data b010122 = int16(122) .data bALIGN1010122 = int16(0) .data bALIGN2010122 = int32(0) .data b010123 = int64(123) .data b010124 = int64(124) .data b010125 = int32(125) .data bALIGN1010125 = int32(0) .data b010126 = int16(126) .data bALIGN1010126 = int16(0) .data bALIGN2010126 = int32(0) .data b010127 = int16(127) .data bALIGN1010127 = int16(0) .data bALIGN2010127 = int32(0)
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingElementCollection.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 { public sealed class SettingElementCollection : ConfigurationElementCollection { public override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.BasicMap; } } protected override string ElementName { get { return "setting"; } } protected override ConfigurationElement CreateNewElement() { return new SettingElement(); } protected override object GetElementKey(ConfigurationElement element) { return ((SettingElement)element).Key; } public SettingElement Get(string elementKey) { return (SettingElement)BaseGet(elementKey); } public void Add(SettingElement element) { BaseAdd(element); } public void Remove(SettingElement element) { BaseRemove(GetElementKey(element)); } public void Clear() { BaseClear(); } } }
// 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 { public sealed class SettingElementCollection : ConfigurationElementCollection { public override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.BasicMap; } } protected override string ElementName { get { return "setting"; } } protected override ConfigurationElement CreateNewElement() { return new SettingElement(); } protected override object GetElementKey(ConfigurationElement element) { return ((SettingElement)element).Key; } public SettingElement Get(string elementKey) { return (SettingElement)BaseGet(elementKey); } public void Add(SettingElement element) { BaseAdd(element); } public void Remove(SettingElement element) { BaseRemove(GetElementKey(element)); } public void Clear() { BaseClear(); } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/IL_Conformance/Old/objectmodel/field_tests.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 field_tests{} .class public field_tests { .field public int8 i1Field .field public int16 i2Field .field public int32 i4Field .field public int64 i8Field .field public float32 r4Field .field public float64 r8Field .field public class field_tests ptrField .field public static int8 i1SField .field public static int16 i2SField .field public static int32 i4SField .field public static int64 i8SField .field public static float32 r4SField .field public static float64 r8SField .field public static class field_tests ptrSField .method public void .ctor() { .maxstack 10 ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } .method public void initialize() { .maxstack 10 ldarg 0 ldc.i4 0x1 stfld int8 field_tests::i1Field ldarg 0 ldc.i4 0x2 stfld int16 field_tests::i2Field ldarg 0 ldc.i4 0x4 stfld int32 field_tests::i4Field ldarg 0 ldc.i8 0x8 stfld int64 field_tests::i8Field ldarg 0 ldc.r4 4.4 stfld float32 field_tests::r4Field ldarg 0 ldc.r8 8.8 stfld float64 field_tests::r8Field ldarg 0 ldarg 0 stfld class field_tests field_tests::ptrField ldc.i4 0x1 stsfld int8 field_tests::i1SField ldc.i4 0x2 stsfld int16 field_tests::i2SField ldc.i4 0x4 stsfld int32 field_tests::i4SField ldc.i8 0x8 stsfld int64 field_tests::i8SField ldc.r4 4.4 stsfld float32 field_tests::r4SField ldc.r8 8.8 stsfld float64 field_tests::r8SField ldarg 0 stsfld class field_tests field_tests::ptrSField ret } .method public static int32 main(class [mscorlib]System.String[]) { .entrypoint .maxstack 10 .locals (class field_tests) newobj instance void field_tests::.ctor() dup stloc 0 call instance void field_tests::initialize() ldloc 0 ldfld int8 field_tests::i1Field ldc.i4 0x1 ceq brfalse FAIL ldloc 0 ldfld int16 field_tests::i2Field ldc.i4 0x2 ceq brfalse FAIL ldloc 0 ldfld int32 field_tests::i4Field ldc.i4 0x4 ceq brfalse FAIL ldloc 0 ldfld int64 field_tests::i8Field ldc.i8 0x8 ceq brfalse FAIL ldloc 0 ldfld float32 field_tests::r4Field ldc.r4 4.4 ceq brfalse FAIL ldloc 0 ldfld float64 field_tests::r8Field ldc.r8 8.8 ceq brfalse FAIL ldloc 0 ldfld class field_tests field_tests::ptrField isinst field_tests brfalse FAIL ldsfld int8 field_tests::i1SField ldc.i4 0x1 ceq brfalse FAIL ldsfld int16 field_tests::i2SField ldc.i4 0x2 ceq brfalse FAIL ldsfld int32 field_tests::i4SField ldc.i4 0x4 ceq brfalse FAIL ldsfld int64 field_tests::i8SField ldc.i8 0x8 ceq brfalse FAIL ldsfld float32 field_tests::r4SField ldc.r4 4.4 ceq brfalse FAIL ldsfld float64 field_tests::r8SField ldc.r8 8.8 ceq brfalse FAIL ldsfld class field_tests field_tests::ptrSField isinst field_tests brfalse FAIL PASS: ldc.i4 100 ret FAIL: ldc.i4 0x0 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 field_tests{} .class public field_tests { .field public int8 i1Field .field public int16 i2Field .field public int32 i4Field .field public int64 i8Field .field public float32 r4Field .field public float64 r8Field .field public class field_tests ptrField .field public static int8 i1SField .field public static int16 i2SField .field public static int32 i4SField .field public static int64 i8SField .field public static float32 r4SField .field public static float64 r8SField .field public static class field_tests ptrSField .method public void .ctor() { .maxstack 10 ldarg.0 call instance void [mscorlib]System.Object::.ctor() ret } .method public void initialize() { .maxstack 10 ldarg 0 ldc.i4 0x1 stfld int8 field_tests::i1Field ldarg 0 ldc.i4 0x2 stfld int16 field_tests::i2Field ldarg 0 ldc.i4 0x4 stfld int32 field_tests::i4Field ldarg 0 ldc.i8 0x8 stfld int64 field_tests::i8Field ldarg 0 ldc.r4 4.4 stfld float32 field_tests::r4Field ldarg 0 ldc.r8 8.8 stfld float64 field_tests::r8Field ldarg 0 ldarg 0 stfld class field_tests field_tests::ptrField ldc.i4 0x1 stsfld int8 field_tests::i1SField ldc.i4 0x2 stsfld int16 field_tests::i2SField ldc.i4 0x4 stsfld int32 field_tests::i4SField ldc.i8 0x8 stsfld int64 field_tests::i8SField ldc.r4 4.4 stsfld float32 field_tests::r4SField ldc.r8 8.8 stsfld float64 field_tests::r8SField ldarg 0 stsfld class field_tests field_tests::ptrSField ret } .method public static int32 main(class [mscorlib]System.String[]) { .entrypoint .maxstack 10 .locals (class field_tests) newobj instance void field_tests::.ctor() dup stloc 0 call instance void field_tests::initialize() ldloc 0 ldfld int8 field_tests::i1Field ldc.i4 0x1 ceq brfalse FAIL ldloc 0 ldfld int16 field_tests::i2Field ldc.i4 0x2 ceq brfalse FAIL ldloc 0 ldfld int32 field_tests::i4Field ldc.i4 0x4 ceq brfalse FAIL ldloc 0 ldfld int64 field_tests::i8Field ldc.i8 0x8 ceq brfalse FAIL ldloc 0 ldfld float32 field_tests::r4Field ldc.r4 4.4 ceq brfalse FAIL ldloc 0 ldfld float64 field_tests::r8Field ldc.r8 8.8 ceq brfalse FAIL ldloc 0 ldfld class field_tests field_tests::ptrField isinst field_tests brfalse FAIL ldsfld int8 field_tests::i1SField ldc.i4 0x1 ceq brfalse FAIL ldsfld int16 field_tests::i2SField ldc.i4 0x2 ceq brfalse FAIL ldsfld int32 field_tests::i4SField ldc.i4 0x4 ceq brfalse FAIL ldsfld int64 field_tests::i8SField ldc.i8 0x8 ceq brfalse FAIL ldsfld float32 field_tests::r4SField ldc.r4 4.4 ceq brfalse FAIL ldsfld float64 field_tests::r8SField ldc.r8 8.8 ceq brfalse FAIL ldsfld class field_tests field_tests::ptrSField isinst field_tests brfalse FAIL PASS: ldc.i4 100 ret FAIL: ldc.i4 0x0 ret } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./eng/testing/ILLinkDescriptors/ILLink.Descriptors.Castle.xml
<linker> <assembly fullname="Castle.Core"> <namespace fullname="Castle.DynamicProxy" /> <type fullname="Castle.DynamicProxy.Internal.CompositionInvocation" /> <type fullname="Castle.DynamicProxy.Internal.InheritanceInvocation" /> </assembly> <assembly fullname="Moq"> <type fullname="Moq.Internals.InterfaceProxy"> <method signature="System.Void .ctor()" /> </type> </assembly> </linker>
<linker> <assembly fullname="Castle.Core"> <namespace fullname="Castle.DynamicProxy" /> <type fullname="Castle.DynamicProxy.Internal.CompositionInvocation" /> <type fullname="Castle.DynamicProxy.Internal.InheritanceInvocation" /> </assembly> <assembly fullname="Moq"> <type fullname="Moq.Internals.InterfaceProxy"> <method signature="System.Void .ctor()" /> </type> </assembly> </linker>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/coreclr/nativeaot/System.Private.CoreLib/src/System/Type.CoreRT.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; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading; using Internal.Reflection.Augments; using Internal.Reflection.Core.NonPortable; using Internal.Runtime.Augments; using Internal.Runtime.CompilerServices; namespace System { public abstract partial class Type : MemberInfo, IReflect { public bool IsInterface => (GetAttributeFlagsImpl() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface; [Intrinsic] public static Type? GetTypeFromHandle(RuntimeTypeHandle handle) => handle.IsNull ? null : GetTypeFromEETypePtr(handle.ToEETypePtr()); internal static Type GetTypeFromEETypePtr(EETypePtr eeType) { // If we support the writable data section on EETypes, the runtime type associated with the MethodTable // is cached there. If writable data is not supported, we need to do a lookup in the runtime type // unifier's hash table. if (Internal.Runtime.MethodTable.SupportsWritableData) { ref GCHandle handle = ref eeType.GetWritableData<GCHandle>(); if (handle.IsAllocated) { return Unsafe.As<Type>(handle.Target); } else { return GetTypeFromEETypePtrSlow(eeType, ref handle); } } else { return RuntimeTypeUnifier.GetRuntimeTypeForEEType(eeType); } } [MethodImpl(MethodImplOptions.NoInlining)] private static Type GetTypeFromEETypePtrSlow(EETypePtr eeType, ref GCHandle handle) { // Note: this is bypassing the "fast" unifier cache (based on a simple IntPtr // identity of MethodTable pointers). There is another unifier behind that cache // that ensures this code is race-free. Type result = RuntimeTypeUnifier.GetRuntimeTypeBypassCache(eeType); GCHandle tempHandle = GCHandle.Alloc(result); // We don't want to leak a handle if there's a race if (Interlocked.CompareExchange(ref Unsafe.As<GCHandle, IntPtr>(ref handle), (IntPtr)tempHandle, default) != default) { tempHandle.Free(); } return result; } [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName) => GetType(typeName, throwOnError: false, ignoreCase: false); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, bool throwOnError) => GetType(typeName, throwOnError: throwOnError, ignoreCase: false); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, bool throwOnError, bool ignoreCase) => GetType(typeName, null, null, throwOnError: throwOnError, ignoreCase: ignoreCase); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver) => GetType(typeName, assemblyResolver, typeResolver, throwOnError: false, ignoreCase: false); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver, bool throwOnError) => GetType(typeName, assemblyResolver, typeResolver, throwOnError: throwOnError, ignoreCase: false); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver, bool throwOnError, bool ignoreCase) => RuntimeAugments.Callbacks.GetType(typeName, assemblyResolver, typeResolver, throwOnError: throwOnError, ignoreCase: ignoreCase, defaultAssembly: 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.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Threading; using Internal.Reflection.Augments; using Internal.Reflection.Core.NonPortable; using Internal.Runtime.Augments; using Internal.Runtime.CompilerServices; namespace System { public abstract partial class Type : MemberInfo, IReflect { public bool IsInterface => (GetAttributeFlagsImpl() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface; [Intrinsic] public static Type? GetTypeFromHandle(RuntimeTypeHandle handle) => handle.IsNull ? null : GetTypeFromEETypePtr(handle.ToEETypePtr()); internal static Type GetTypeFromEETypePtr(EETypePtr eeType) { // If we support the writable data section on EETypes, the runtime type associated with the MethodTable // is cached there. If writable data is not supported, we need to do a lookup in the runtime type // unifier's hash table. if (Internal.Runtime.MethodTable.SupportsWritableData) { ref GCHandle handle = ref eeType.GetWritableData<GCHandle>(); if (handle.IsAllocated) { return Unsafe.As<Type>(handle.Target); } else { return GetTypeFromEETypePtrSlow(eeType, ref handle); } } else { return RuntimeTypeUnifier.GetRuntimeTypeForEEType(eeType); } } [MethodImpl(MethodImplOptions.NoInlining)] private static Type GetTypeFromEETypePtrSlow(EETypePtr eeType, ref GCHandle handle) { // Note: this is bypassing the "fast" unifier cache (based on a simple IntPtr // identity of MethodTable pointers). There is another unifier behind that cache // that ensures this code is race-free. Type result = RuntimeTypeUnifier.GetRuntimeTypeBypassCache(eeType); GCHandle tempHandle = GCHandle.Alloc(result); // We don't want to leak a handle if there's a race if (Interlocked.CompareExchange(ref Unsafe.As<GCHandle, IntPtr>(ref handle), (IntPtr)tempHandle, default) != default) { tempHandle.Free(); } return result; } [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName) => GetType(typeName, throwOnError: false, ignoreCase: false); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, bool throwOnError) => GetType(typeName, throwOnError: throwOnError, ignoreCase: false); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, bool throwOnError, bool ignoreCase) => GetType(typeName, null, null, throwOnError: throwOnError, ignoreCase: ignoreCase); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver) => GetType(typeName, assemblyResolver, typeResolver, throwOnError: false, ignoreCase: false); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver, bool throwOnError) => GetType(typeName, assemblyResolver, typeResolver, throwOnError: throwOnError, ignoreCase: false); [Intrinsic] [RequiresUnreferencedCode("The type might be removed")] public static Type GetType(string typeName, Func<AssemblyName, Assembly?>? assemblyResolver, Func<Assembly?, string, bool, Type?>? typeResolver, bool throwOnError, bool ignoreCase) => RuntimeAugments.Callbacks.GetType(typeName, assemblyResolver, typeResolver, throwOnError: throwOnError, ignoreCase: ignoreCase, defaultAssembly: null); } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Internal.IL; using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem.Interop { public static class InteropTypes { public static MetadataType GetGC(TypeSystemContext context) { return context.SystemModule.GetKnownType("System", "GC"); } public static MetadataType GetSafeHandle(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "SafeHandle"); } public static MetadataType GetCriticalHandle(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "CriticalHandle"); } public static MetadataType GetHandleRef(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "HandleRef"); } public static MetadataType GetPInvokeMarshal(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "PInvokeMarshal"); } public static MetadataType GetMarshal(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "Marshal"); } public static MetadataType GetMemoryMarshal(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "MemoryMarshal"); } public static MetadataType GetStubHelpers(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.StubHelpers", "StubHelpers"); } public static MetadataType GetNativeFunctionPointerWrapper(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "NativeFunctionPointerWrapper"); } public static MetadataType GetMarshalDirectiveException(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "MarshalDirectiveException"); } public static MetadataType GetVariant(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "Variant"); } public static bool IsSafeHandle(TypeSystemContext context, TypeDesc type) { return IsOrDerivesFromType(type, GetSafeHandle(context)); } public static bool IsCriticalHandle(TypeSystemContext context, TypeDesc type) { return IsOrDerivesFromType(type, GetCriticalHandle(context)); } private static bool IsCoreNamedType(TypeSystemContext context, TypeDesc type, string @namespace, string name) { return type is MetadataType mdType && mdType.Name == name && mdType.Namespace == @namespace && mdType.Module == context.SystemModule; } public static bool IsHandleRef(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Runtime.InteropServices", "HandleRef"); } public static bool IsSystemDateTime(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "DateTime"); } public static bool IsStringBuilder(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Text", "StringBuilder"); } public static bool IsSystemDecimal(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Decimal"); } public static bool IsSystemDelegate(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Delegate"); } public static bool IsSystemMulticastDelegate(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "MulticastDelegate"); } public static bool IsSystemGuid(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Guid"); } public static bool IsSystemArgIterator(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "ArgIterator"); } public static bool IsSystemByReference(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "ByReference`1"); } public static bool IsSystemSpan(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Span`1"); } public static bool IsSystemReadOnlySpan(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "ReadOnlySpan`1"); } public static bool IsSystemNullable(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Nullable`1"); } public static bool IsSystemRuntimeIntrinsicsVector64T(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector64`1"); } public static bool IsSystemRuntimeIntrinsicsVector128T(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector128`1"); } public static bool IsSystemRuntimeIntrinsicsVector256T(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector256`1"); } public static bool IsSystemNumericsVectorT(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Numerics", "Vector`1"); } private static bool IsOrDerivesFromType(TypeDesc type, MetadataType targetType) { while (type != null) { if (type == targetType) return true; type = type.BaseType; } return false; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Internal.IL; using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem.Interop { public static class InteropTypes { public static MetadataType GetGC(TypeSystemContext context) { return context.SystemModule.GetKnownType("System", "GC"); } public static MetadataType GetSafeHandle(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "SafeHandle"); } public static MetadataType GetCriticalHandle(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "CriticalHandle"); } public static MetadataType GetHandleRef(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "HandleRef"); } public static MetadataType GetPInvokeMarshal(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "PInvokeMarshal"); } public static MetadataType GetMarshal(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "Marshal"); } public static MetadataType GetMemoryMarshal(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "MemoryMarshal"); } public static MetadataType GetStubHelpers(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.StubHelpers", "StubHelpers"); } public static MetadataType GetNativeFunctionPointerWrapper(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "NativeFunctionPointerWrapper"); } public static MetadataType GetMarshalDirectiveException(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "MarshalDirectiveException"); } public static MetadataType GetVariant(TypeSystemContext context) { return context.SystemModule.GetKnownType("System.Runtime.InteropServices", "Variant"); } public static bool IsSafeHandle(TypeSystemContext context, TypeDesc type) { return IsOrDerivesFromType(type, GetSafeHandle(context)); } public static bool IsCriticalHandle(TypeSystemContext context, TypeDesc type) { return IsOrDerivesFromType(type, GetCriticalHandle(context)); } private static bool IsCoreNamedType(TypeSystemContext context, TypeDesc type, string @namespace, string name) { return type is MetadataType mdType && mdType.Name == name && mdType.Namespace == @namespace && mdType.Module == context.SystemModule; } public static bool IsHandleRef(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Runtime.InteropServices", "HandleRef"); } public static bool IsSystemDateTime(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "DateTime"); } public static bool IsStringBuilder(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Text", "StringBuilder"); } public static bool IsSystemDecimal(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Decimal"); } public static bool IsSystemDelegate(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Delegate"); } public static bool IsSystemMulticastDelegate(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "MulticastDelegate"); } public static bool IsSystemGuid(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Guid"); } public static bool IsSystemArgIterator(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "ArgIterator"); } public static bool IsSystemByReference(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "ByReference`1"); } public static bool IsSystemSpan(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Span`1"); } public static bool IsSystemReadOnlySpan(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "ReadOnlySpan`1"); } public static bool IsSystemNullable(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System", "Nullable`1"); } public static bool IsSystemRuntimeIntrinsicsVector64T(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector64`1"); } public static bool IsSystemRuntimeIntrinsicsVector128T(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector128`1"); } public static bool IsSystemRuntimeIntrinsicsVector256T(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector256`1"); } public static bool IsSystemNumericsVectorT(TypeSystemContext context, TypeDesc type) { return IsCoreNamedType(context, type, "System.Numerics", "Vector`1"); } private static bool IsOrDerivesFromType(TypeDesc type, MetadataType targetType) { while (type != null) { if (type == targetType) return true; type = type.BaseType; } return false; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Regression/CLR-x86-JIT/v2.1/b561129/b561129.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <CLRTestPriority>1</CLRTestPriority> </PropertyGroup> <PropertyGroup> <DebugType>Full</DebugType> <Optimize>True</Optimize> </PropertyGroup> <ItemGroup> <Compile Include="$(MSBuildProjectName).cs" /> </ItemGroup> </Project>
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/GC/Regressions/v2.0-rtm/494226/494226.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.Runtime.InteropServices; public class Test_494226 { [System.Security.SecuritySafeCritical] public static int Main() { List<GCHandle> list = new List<GCHandle>(); List<byte[]> blist = new List<byte[]>(); try { for (int i = 0; i < 1024 * 1024 * 20; i++) { byte[] b = new byte[10]; b[0] = 0xC; if (i % 1024 * 1024 * 10 == 0) { list.Add(GCHandle.Alloc(b, GCHandleType.Pinned)); } blist.Add(b); } } catch (OutOfMemoryException) { // we need to bail here } Console.WriteLine("Test passed"); return 100; } } /* Test_494226 passes if the following assert is not hit: (*card_word)==0 MSCORWKS! WKS::gc_heap::find_card_dword + 0x1CC (0x5d9a2441) MSCORWKS! WKS::gc_heap::find_card + 0x35 (0x5d9a2588) MSCORWKS! WKS::gc_heap::mark_through_cards_for_segments + 0x33C (0x5d9a2a79) MSCORWKS! WKS::gc_heap::relocate_phase + 0x1B4 (0x5d9ab25f) MSCORWKS! WKS::gc_heap::plan_phase + 0x1AA4 (0x5d9b6ad8) MSCORWKS! WKS::gc_heap::gc1 + 0x8E (0x5d9b75c1) MSCORWKS! WKS::gc_heap::garbage_collect + 0x5BE (0x5d9b8d2c) MSCORWKS! WKS::GCHeap::GarbageCollectGeneration + 0x2AD (0x5d9b9107) MSCORWKS! WKS::gc_heap::try_allocate_more_space + 0x165 (0x5d9b934c) MSCORWKS! WKS::gc_heap::allocate_more_space + 0x11 (0x5d9b9b82) c:\vbl\ndp\clr\src\vm\gc.cpp, Line: 15024 */
// 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.Runtime.InteropServices; public class Test_494226 { [System.Security.SecuritySafeCritical] public static int Main() { List<GCHandle> list = new List<GCHandle>(); List<byte[]> blist = new List<byte[]>(); try { for (int i = 0; i < 1024 * 1024 * 20; i++) { byte[] b = new byte[10]; b[0] = 0xC; if (i % 1024 * 1024 * 10 == 0) { list.Add(GCHandle.Alloc(b, GCHandleType.Pinned)); } blist.Add(b); } } catch (OutOfMemoryException) { // we need to bail here } Console.WriteLine("Test passed"); return 100; } } /* Test_494226 passes if the following assert is not hit: (*card_word)==0 MSCORWKS! WKS::gc_heap::find_card_dword + 0x1CC (0x5d9a2441) MSCORWKS! WKS::gc_heap::find_card + 0x35 (0x5d9a2588) MSCORWKS! WKS::gc_heap::mark_through_cards_for_segments + 0x33C (0x5d9a2a79) MSCORWKS! WKS::gc_heap::relocate_phase + 0x1B4 (0x5d9ab25f) MSCORWKS! WKS::gc_heap::plan_phase + 0x1AA4 (0x5d9b6ad8) MSCORWKS! WKS::gc_heap::gc1 + 0x8E (0x5d9b75c1) MSCORWKS! WKS::gc_heap::garbage_collect + 0x5BE (0x5d9b8d2c) MSCORWKS! WKS::GCHeap::GarbageCollectGeneration + 0x2AD (0x5d9b9107) MSCORWKS! WKS::gc_heap::try_allocate_more_space + 0x165 (0x5d9b934c) MSCORWKS! WKS::gc_heap::allocate_more_space + 0x11 (0x5d9b9b82) c:\vbl\ndp\clr\src\vm\gc.cpp, Line: 15024 */
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/Loader/classloader/StaticVirtualMethods/GenericContext/gen.bat
call ..\..\..\..\..\..\dotnet.cmd run --project Generator\generatetest.csproj -- .
call ..\..\..\..\..\..\dotnet.cmd run --project Generator\generatetest.csproj -- .
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/mono/mono/tests/assembly-load-reference/README
Test loading references of assemblies loaded using LoadFrom and LoadFile. There are three variations of the same two tests: LoadFromMain and LoadFileMain. The differences are where we place the two additional assemblies Mid and Dep. Mid references Dep. samedir/ Main, Mid and Dep are all in the same directory - both LoadFile and LoadFrom expected to work. mainanddep/ Main and Dep are in the base dir, Mid is in mid/ - both LoadFrom and LoadFrom expected to work separatedir/ Main is in the base dir, Mid and Dep are in mid/ - LoadFrom expected to work, LoadFile expected to fail.
Test loading references of assemblies loaded using LoadFrom and LoadFile. There are three variations of the same two tests: LoadFromMain and LoadFileMain. The differences are where we place the two additional assemblies Mid and Dep. Mid references Dep. samedir/ Main, Mid and Dep are all in the same directory - both LoadFile and LoadFrom expected to work. mainanddep/ Main and Dep are in the base dir, Mid is in mid/ - both LoadFrom and LoadFrom expected to work separatedir/ Main is in the base dir, Mid and Dep are in mid/ - LoadFrom expected to work, LoadFile expected to fail.
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/tests/JIT/Methodical/divrem/div/negSignedMod.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; internal class Test_negSignedMod { private static int Main() { Console.WriteLine(TimeSpan.FromTicks(-2567240321185713219).Seconds); if (TimeSpan.FromTicks(-2567240321185713219).Seconds != -38) return 101; return 100; } }
// 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; internal class Test_negSignedMod { private static int Main() { Console.WriteLine(TimeSpan.FromTicks(-2567240321185713219).Seconds); if (TimeSpan.FromTicks(-2567240321185713219).Seconds != -38) return 101; return 100; } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // ParallelEnumerable.cs // // The standard IEnumerable-based LINQ-to-Objects query provider. This class basically // mirrors the System.Linq.Enumerable class, but (1) takes as input a special "parallel // enumerable" data type and (2) uses an alternative implementation of the operators. // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System; using System.Collections.Generic; using System.Threading; using System.Diagnostics; using System.Linq.Parallel; using System.Collections.Concurrent; using System.Collections; using System.Threading.Tasks; using System.Diagnostics.CodeAnalysis; namespace System.Linq { //----------------------------------------------------------------------------------- // Languages like C# and VB that support query comprehensions translate queries // into calls to a query provider which creates executable representations of the // query. The LINQ-to-Objects provider is implemented as a static class with an // extension method per-query operator; when invoked, these return enumerable // objects that implement the querying behavior. // // We have a new sequence class for two reasons: // // (1) Developers can opt in to parallel query execution piecemeal, by using // a special AsParallel API to wrap the data source. // (2) Parallel LINQ uses a new representation for queries when compared to LINQ, // which we must return from the new sequence operator implementations. // // Comments and documentation will be somewhat light in this file. Please refer // to the "official" Standard Query Operators specification for details on each API: // http://download.microsoft.com/download/5/8/6/5868081c-68aa-40de-9a45-a3803d8134b8/Standard_Query_Operators.doc // // Notes: // The Standard Query Operators herein should be semantically equivalent to // the specification linked to above. In some cases, we offer operators that // aren't available in the sequential LINQ library; in each case, we will note // why this is needed. // /// <summary> /// Provides a set of methods for querying objects that implement /// ParallelQuery{TSource}. This is the parallel equivalent of /// <see cref="System.Linq.Enumerable"/>. /// </summary> public static class ParallelEnumerable { // We pass this string constant to an attribute constructor. Unfortunately, we cannot access resources from // an attribute constructor, so we have to store this string in source code. private const string RIGHT_SOURCE_NOT_PARALLEL_STR = "The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than " + "System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method " + "to convert the right data source to System.Linq.ParallelQuery<T>."; // When running in single partition mode, PLINQ operations will occur on a single partition and will not // be executed in parallel, but will retain PLINQ semantics (exceptions wrapped as aggregates, etc). [System.Runtime.Versioning.SupportedOSPlatformGuard("browser")] internal static bool SinglePartitionMode => OperatingSystem.IsBrowser(); //----------------------------------------------------------------------------------- // Converts any IEnumerable<TSource> into something that can be the target of parallel // query execution. // // Arguments: // source - the enumerable data source // options - query analysis options to override the defaults // degreeOfParallelism - the DOP to use instead of the system default, if any // // Notes: // If the argument is already a parallel enumerable, such as a query operator, // no new objects are allocated. Otherwise, a very simple wrapper is instantiated // that exposes the IEnumerable as a ParallelQuery. // /// <summary> /// Enables parallelization of a query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">An <see cref="System.Collections.Generic.IEnumerable{T}"/> /// to convert to a <see cref="System.Linq.ParallelQuery{T}"/>.</param> /// <returns>The source as a <see cref="System.Linq.ParallelQuery{T}"/> to bind to /// ParallelEnumerable extension methods.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> AsParallel<TSource>(this IEnumerable<TSource> source!!) { return new ParallelEnumerableWrapper<TSource>(source); } /// <summary> /// Enables parallelization of a query, as sourced by a partitioner /// responsible for splitting the input sequence into partitions. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A partitioner over the input sequence.</param> /// <returns>The <paramref name="source"/> as a ParallelQuery to bind to ParallelEnumerable extension methods.</returns> /// <remarks> /// The source partitioner's GetOrderedPartitions method is used when ordering is enabled, /// whereas the partitioner's GetPartitions is used if ordering is not enabled (the default). /// The source partitioner's GetDynamicPartitions and GetDynamicOrderedPartitions are not used. /// </remarks> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> AsParallel<TSource>(this Partitioner<TSource> source!!) { return new PartitionerQueryOperator<TSource>(source); } /// <summary> /// Enables treatment of a data source as if it was ordered, overriding the default of unordered. /// AsOrdered may only be invoked on sequences returned by AsParallel, ParallelEnumerable.Range, /// and ParallelEnumerable.Repeat. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The input sequence.</param> /// <exception cref="System.InvalidOperationException"> /// Thrown if <paramref name="source"/> is not one of AsParallel, ParallelEnumerable.Range, or ParallelEnumerable.Repeat. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <remarks> /// A natural tension exists between performance and preserving order in parallel processing. By default, /// a parallelized query behaves as if the ordering of the results is arbitrary /// unless AsOrdered is applied or there is an explicit OrderBy operator in the query. /// </remarks> /// <returns>The source sequence which will maintain ordering in the query.</returns> public static ParallelQuery<TSource> AsOrdered<TSource>(this ParallelQuery<TSource> source!!) { if (!(source is ParallelEnumerableWrapper<TSource> || source is IParallelPartitionable<TSource>)) { if (source is PartitionerQueryOperator<TSource> partitionerOp) { if (!partitionerOp.Orderable) { throw new InvalidOperationException(SR.ParallelQuery_PartitionerNotOrderable); } } else { throw new InvalidOperationException(SR.ParallelQuery_InvalidAsOrderedCall); } } return new OrderingQueryOperator<TSource>(QueryOperator<TSource>.AsQueryOperator(source), true); } /// <summary> /// Enables treatment of a data source as if it was ordered, overriding the default of unordered. /// AsOrdered may only be invoked on sequences returned by AsParallel, ParallelEnumerable.Range, /// and ParallelEnumerable.Repeat. /// </summary> /// <param name="source">The input sequence.</param> /// <exception cref="InvalidOperationException"> /// Thrown if the <paramref name="source"/> is not one of AsParallel, ParallelEnumerable.Range, or ParallelEnumerable.Repeat. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <remarks> /// A natural tension exists between performance and preserving order in parallel processing. By default, /// a parallelized query behaves as if the ordering of the results is arbitrary unless AsOrdered /// is applied or there is an explicit OrderBy operator in the query. /// </remarks> /// <returns>The source sequence which will maintain ordering in the query.</returns> public static ParallelQuery AsOrdered(this ParallelQuery source!!) { ParallelEnumerableWrapper? wrapper = source as ParallelEnumerableWrapper; if (wrapper == null) { throw new InvalidOperationException(SR.ParallelQuery_InvalidNonGenericAsOrderedCall); } return new OrderingQueryOperator<object?>(QueryOperator<object?>.AsQueryOperator(wrapper), true); } /// <summary> /// Allows an intermediate query to be treated as if no ordering is implied among the elements. /// </summary> /// <remarks> /// AsUnordered may provide /// performance benefits when ordering is not required in a portion of a query. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The input sequence.</param> /// <returns>The source sequence with arbitrary order.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> AsUnordered<TSource>(this ParallelQuery<TSource> source!!) { return new OrderingQueryOperator<TSource>(QueryOperator<TSource>.AsQueryOperator(source), false); } /// <summary> /// Enables parallelization of a query. /// </summary> /// <param name="source">An <see cref="System.Collections.Generic.IEnumerable{T}"/> to convert /// to a <see cref="System.Linq.ParallelQuery{T}"/>.</param> /// <returns> /// The source as a ParallelQuery to bind to /// ParallelEnumerable extension methods. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery AsParallel(this IEnumerable source!!) { return new ParallelEnumerableWrapper(source); } //----------------------------------------------------------------------------------- // Converts a parallel enumerable into something that forces sequential execution. // // Arguments: // source - the parallel enumerable data source // /// <summary> /// Converts a <see cref="ParallelQuery{T}"/> into an /// <see cref="System.Collections.Generic.IEnumerable{T}"/> to force sequential /// evaluation of the query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A <see cref="ParallelQuery{T}"/> to convert to an <see cref="System.Collections.Generic.IEnumerable{T}"/>.</param> /// <returns>The source as an <see cref="System.Collections.Generic.IEnumerable{T}"/> /// to bind to sequential extension methods.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static IEnumerable<TSource> AsSequential<TSource>(this ParallelQuery<TSource> source!!) { // Ditch the wrapper, if there is one. if (source is ParallelEnumerableWrapper<TSource> wrapper) { return wrapper.WrappedEnumerable; } else { return source; } } /// <summary> /// Sets the degree of parallelism to use in a query. Degree of parallelism is the maximum number of concurrently /// executing tasks that will be used to process the query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A ParallelQuery on which to set the limit on the degrees of parallelism.</param> /// <param name="degreeOfParallelism">The degree of parallelism for the query.</param> /// <returns>ParallelQuery representing the same query as source, with the limit on the degrees of parallelism set.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// WithDegreeOfParallelism is used multiple times in the query. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="degreeOfParallelism"/> is less than 1 or greater than 512. /// </exception> public static ParallelQuery<TSource> WithDegreeOfParallelism<TSource>(this ParallelQuery<TSource> source!!, int degreeOfParallelism) { if (degreeOfParallelism < 1 || degreeOfParallelism > Scheduling.MAX_SUPPORTED_DOP) { throw new ArgumentOutOfRangeException(nameof(degreeOfParallelism)); } QuerySettings settings = QuerySettings.Empty; settings.DegreeOfParallelism = degreeOfParallelism; return new QueryExecutionOption<TSource>( QueryOperator<TSource>.AsQueryOperator(source), settings); } /// <summary> /// Sets the <see cref="System.Threading.CancellationToken"/> to associate with the query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A ParallelQuery on which to set the option.</param> /// <param name="cancellationToken">A cancellation token.</param> /// <returns>ParallelQuery representing the same query as source, but with the <seealso cref="System.Threading.CancellationToken"/> /// registered.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// WithCancellation is used multiple times in the query. /// </exception> public static ParallelQuery<TSource> WithCancellation<TSource>(this ParallelQuery<TSource> source!!, CancellationToken cancellationToken) { QuerySettings settings = QuerySettings.Empty; settings.CancellationState = new CancellationState(cancellationToken); return new QueryExecutionOption<TSource>( QueryOperator<TSource>.AsQueryOperator(source), settings); } /// <summary> /// Sets the execution mode of the query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A ParallelQuery on which to set the option.</param> /// <param name="executionMode">The mode in which to execute the query.</param> /// <returns>ParallelQuery representing the same query as source, but with the /// <seealso cref="System.Linq.ParallelExecutionMode"/> registered.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="executionMode"/> is not a valid <see cref="System.Linq.ParallelExecutionMode"/> value. /// </exception> /// <exception cref="System.InvalidOperationException"> /// WithExecutionMode is used multiple times in the query. /// </exception> public static ParallelQuery<TSource> WithExecutionMode<TSource>(this ParallelQuery<TSource> source!!, ParallelExecutionMode executionMode) { if (executionMode != ParallelExecutionMode.Default && executionMode != ParallelExecutionMode.ForceParallelism) { throw new ArgumentException(SR.ParallelEnumerable_WithQueryExecutionMode_InvalidMode); } QuerySettings settings = QuerySettings.Empty; settings.ExecutionMode = executionMode; return new QueryExecutionOption<TSource>( QueryOperator<TSource>.AsQueryOperator(source), settings); } /// <summary> /// Sets the merge options for this query, which specify how the query will buffer output. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A ParallelQuery on which to set the option.</param> /// <param name="mergeOptions">The merge options to set for this query.</param> /// <returns>ParallelQuery representing the same query as source, but with the /// <seealso cref="ParallelMergeOptions"/> registered.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="mergeOptions"/> is not a valid <see cref="System.Linq.ParallelMergeOptions"/> value. /// </exception> /// <exception cref="System.InvalidOperationException"> /// WithMergeOptions is used multiple times in the query. /// </exception> public static ParallelQuery<TSource> WithMergeOptions<TSource>(this ParallelQuery<TSource> source!!, ParallelMergeOptions mergeOptions) { if (mergeOptions != ParallelMergeOptions.Default && mergeOptions != ParallelMergeOptions.AutoBuffered && mergeOptions != ParallelMergeOptions.NotBuffered && mergeOptions != ParallelMergeOptions.FullyBuffered) { throw new ArgumentException(SR.ParallelEnumerable_WithMergeOptions_InvalidOptions); } QuerySettings settings = QuerySettings.Empty; settings.MergeOptions = mergeOptions; return new QueryExecutionOption<TSource>( QueryOperator<TSource>.AsQueryOperator(source), settings); } //----------------------------------------------------------------------------------- // Range generates a sequence of numbers that can be used as input to a query. // /// <summary> /// Generates a parallel sequence of integral numbers within a specified range. /// </summary> /// <param name="start">The value of the first integer in the sequence.</param> /// <param name="count">The number of sequential integers to generate.</param> /// <returns>An <b>IEnumerable&lt;Int32&gt;</b> in C# or <B>IEnumerable(Of Int32)</B> in /// Visual Basic that contains a range of sequential integral numbers.</returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="count"/> is less than 0 /// -or- /// <paramref name="start"/> + <paramref name="count"/> - 1 is larger than <see cref="int.MaxValue"/>. /// </exception> public static ParallelQuery<int> Range(int start, int count) { if (count < 0 || (count > 0 && int.MaxValue - (count - 1) < start)) throw new ArgumentOutOfRangeException(nameof(count)); return new RangeEnumerable(start, count); } //----------------------------------------------------------------------------------- // Repeat just generates a sequence of size 'count' containing 'element'. // /// <summary> /// Generates a parallel sequence that contains one repeated value. /// </summary> /// <typeparam name="TResult">The type of the value to be repeated in the result sequence.</typeparam> /// <param name="element">The value to be repeated.</param> /// <param name="count">The number of times to repeat the value in the generated sequence.</param> /// <returns>A sequence that contains a repeated value.</returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="count"/> is less than 0. /// </exception> public static ParallelQuery<TResult> Repeat<TResult>(TResult element, int count) { if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); return new RepeatEnumerable<TResult>(element, count); } //----------------------------------------------------------------------------------- // Returns an always-empty sequence. // /// <summary> /// Returns an empty ParallelQuery{TResult} that has the specified type argument. /// </summary> /// <typeparam name="TResult">The type to assign to the type parameter of the returned /// generic sequence.</typeparam> /// <returns>An empty sequence whose type argument is <typeparamref name="TResult"/>.</returns> public static ParallelQuery<TResult> Empty<TResult>() { return System.Linq.Parallel.EmptyEnumerable<TResult>.Instance; } //----------------------------------------------------------------------------------- // A new query operator that allows an arbitrary user-specified "action" to be // tacked on to the query tree. The action will be invoked for every element in the // underlying data source, avoiding a costly final merge in the query's execution, // which can lead to much better scalability. The caveat is that these occur in // parallel, so the user providing an action must take care to eliminate shared state // accesses or to synchronize as appropriate. // // Arguments: // source - the data source over which the actions will be invoked // action - a delegate representing the per-element action to be invoked // // Notes: // Neither source nor action may be null, otherwise this method throws. // /// <summary> /// Invokes in parallel the specified action for each element in the <paramref name="source"/>. /// </summary> /// <remarks> /// This is an efficient way to process the output from a parallelized query because it does /// not require a merge step at the end. However, order of execution is non-deterministic. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The <see cref="ParallelQuery{T}"/> whose elements will be processed by /// <paramref name="action"/>.</param> /// <param name="action">An Action to invoke on each element.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="action"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static void ForAll<TSource>(this ParallelQuery<TSource> source!!, Action<TSource> action!!) { // We just instantiate the forall operator and invoke it synchronously on this thread. // By the time it returns, the entire query has been executed and the actions run.. new ForAllOperator<TSource>(source, action).RunSynchronously(); } /*=================================================================================== * BASIC OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Where is an operator that filters any elements from the data source for which the // user-supplied predicate returns false. // /// <summary> /// Filters in parallel a sequence of values based on a predicate. /// </summary> /// <typeparam name="TSource">The type of the elements of source.</typeparam> /// <param name="source">A sequence to filter.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns>A sequence that contains elements from the input sequence that satisfy /// the condition.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Where<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new WhereQueryOperator<TSource>(source, predicate); } /// <summary> /// Filters in parallel a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function. /// </summary> /// <typeparam name="TSource">The type of the elements of source.</typeparam> /// <param name="source">A sequence to filter.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns>A sequence that contains elements from the input sequence that satisfy the condition.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Where<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, int, bool> predicate!!) { return new IndexedWhereQueryOperator<TSource>(source, predicate); } //----------------------------------------------------------------------------------- // Select merely maps a selector delegate over each element in the data source. // /// <summary> /// Projects in parallel each element of a sequence into a new form. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of elements returned by <b>selector</b>.</typeparam> /// <param name="source">A sequence of values to invoke a transform function on.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>A sequence whose elements are the result of invoking the transform function on each /// element of <paramref name="source"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Select<TSource, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, TResult> selector!!) { return new SelectQueryOperator<TSource, TResult>(source, selector); } /// <summary> /// Projects in parallel each element of a sequence into a new form by incorporating the element's index. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of elements returned by <b>selector</b>.</typeparam> /// <param name="source">A sequence of values to invoke a transform function on.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>A sequence whose elements are the result of invoking the transform function on each /// element of <paramref name="source"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Select<TSource, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, int, TResult> selector!!) { return new IndexedSelectQueryOperator<TSource, TResult>(source, selector); } //----------------------------------------------------------------------------------- // Zip combines an outer and inner data source into a single output data stream. // /// <summary> /// Merges in parallel two sequences by using the specified predicate function. /// </summary> /// <typeparam name="TFirst">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TSecond">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TResult">The type of the return elements.</typeparam> /// <param name="first">The first sequence to zip.</param> /// <param name="second">The second sequence to zip.</param> /// <param name="resultSelector">A function to create a result element from two matching elements.</param> /// <returns> /// A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// resultSelector pairwise on two sequences. If the sequence lengths are unequal, this truncates /// to the length of the shorter sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Zip<TFirst, TSecond, TResult>( this ParallelQuery<TFirst> first!!, ParallelQuery<TSecond> second!!, Func<TFirst, TSecond, TResult> resultSelector!!) { return new ZipQueryOperator<TFirst, TSecond, TResult>(first, second, resultSelector); } /// <summary> /// This Zip overload should never be called. /// This method is marked as obsolete and always throws /// <see cref="System.NotSupportedException"/> when invoked. /// </summary> /// <typeparam name="TFirst">This type parameter is not used.</typeparam> /// <typeparam name="TSecond">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Zip with a left data source of type /// <see cref="System.Linq.ParallelQuery{TFirst}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSecond}"/>. /// Otherwise, the Zip operator would appear to be bind to the parallel implementation, but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> Zip<TFirst, TSecond, TResult>( this ParallelQuery<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Join is an inner join operator, i.e. elements from outer with no inner matches // will yield no results in the output data stream. // /// <summary> /// Correlates in parallel the elements of two sequences based on matching keys. /// The default equality comparer is used to compare keys. /// </summary> /// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam> /// <typeparam name="TResult">The type of the result elements.</typeparam> /// <param name="outer">The first sequence to join.</param> /// <param name="inner">The sequence to join to the first sequence.</param> /// <param name="outerKeySelector">A function to extract the join key from each element of /// the first sequence.</param> /// <param name="innerKeySelector">A function to extract the join key from each element of /// the second sequence.</param> /// <param name="resultSelector">A function to create a result element from two matching elements.</param> /// <returns>A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// an inner join on two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="outer"/> or <paramref name="inner"/> or <paramref name="outerKeySelector"/> or /// <paramref name="innerKeySelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector) { return Join<TOuter, TInner, TKey, TResult>( outer, inner, outerKeySelector, innerKeySelector, resultSelector, null); } /// <summary> /// This Join overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when invoked. /// </summary> /// <typeparam name="TOuter">This type parameter is not used.</typeparam> /// <typeparam name="TInner">This type parameter is not used.</typeparam> /// <typeparam name="TKey">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="outer">This parameter is not used.</param> /// <param name="inner">This parameter is not used.</param> /// <param name="outerKeySelector">This parameter is not used.</param> /// <param name="innerKeySelector">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage Join with a left data source of type /// <see cref="System.Linq.ParallelQuery{TOuter}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TInner}"/>. /// Otherwise, the Join operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Correlates in parallel the elements of two sequences based on matching keys. /// A specified IEqualityComparer{T} is used to compare keys. /// </summary> /// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam> /// <typeparam name="TResult">The type of the result elements.</typeparam> /// <param name="outer">The first sequence to join.</param> /// <param name="inner">The sequence to join to the first sequence.</param> /// <param name="outerKeySelector">A function to extract the join key from each element /// of the first sequence.</param> /// <param name="innerKeySelector">A function to extract the join key from each element /// of the second sequence.</param> /// <param name="resultSelector">A function to create a result element from two matching elements.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to hash and compare keys.</param> /// <returns>A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// an inner join on two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="outer"/> or <paramref name="inner"/> or <paramref name="outerKeySelector"/> or /// <paramref name="innerKeySelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer!!, ParallelQuery<TInner> inner!!, Func<TOuter, TKey> outerKeySelector!!, Func<TInner, TKey> innerKeySelector!!, Func<TOuter, TInner, TResult> resultSelector!!, IEqualityComparer<TKey>? comparer) { return new JoinQueryOperator<TOuter, TInner, TKey, TResult>( outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } /// <summary> /// This Join overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when invoked. /// </summary> /// <typeparam name="TOuter">This type parameter is not used.</typeparam> /// <typeparam name="TInner">This type parameter is not used.</typeparam> /// <typeparam name="TKey">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="outer">This parameter is not used.</param> /// <param name="inner">This parameter is not used.</param> /// <param name="outerKeySelector">This parameter is not used.</param> /// <param name="innerKeySelector">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Join with a left data source of type /// <see cref="System.Linq.ParallelQuery{TOuter}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TInner}"/>. /// Otherwise, the Join operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // GroupJoin is an outer join operator, i.e. elements from outer with no inner matches // will yield results (empty lists) in the output data stream. // /// <summary> /// Correlates in parallel the elements of two sequences based on equality of keys and groups the results. /// The default equality comparer is used to compare keys. /// </summary> /// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam> /// <typeparam name="TResult">The type of the result elements.</typeparam> /// <param name="outer">The first sequence to join.</param> /// <param name="inner">The sequence to join to the first sequence.</param> /// <param name="outerKeySelector">A function to extract the join key from each element /// of the first sequence.</param> /// <param name="innerKeySelector">A function to extract the join key from each element /// of the second sequence.</param> /// <param name="resultSelector">A function to create a result element from an element from /// the first sequence and a collection of matching elements from the second sequence.</param> /// <returns>A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// a grouped join on two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="outer"/> or <paramref name="inner"/> or <paramref name="outerKeySelector"/> or /// <paramref name="innerKeySelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector) { return GroupJoin<TOuter, TInner, TKey, TResult>( outer, inner, outerKeySelector, innerKeySelector, resultSelector, null); } /// <summary> /// This GroupJoin overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TOuter">This type parameter is not used.</typeparam> /// <typeparam name="TInner">This type parameter is not used.</typeparam> /// <typeparam name="TKey">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="outer">This parameter is not used.</param> /// <param name="inner">This parameter is not used.</param> /// <param name="outerKeySelector">This parameter is not used.</param> /// <param name="innerKeySelector">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of GroupJoin with a left data source of type /// <see cref="System.Linq.ParallelQuery{TOuter}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TInner}"/>. /// Otherwise, the GroupJoin operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. ///</remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Correlates in parallel the elements of two sequences based on key equality and groups the results. /// A specified IEqualityComparer{T} is used to compare keys. /// </summary> /// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam> /// <typeparam name="TResult">The type of the result elements.</typeparam> /// <param name="outer">The first sequence to join.</param> /// <param name="inner">The sequence to join to the first sequence.</param> /// <param name="outerKeySelector">A function to extract the join key from each element /// of the first sequence.</param> /// <param name="innerKeySelector">A function to extract the join key from each element /// of the second sequence.</param> /// <param name="resultSelector">A function to create a result element from an element from /// the first sequence and a collection of matching elements from the second sequence.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to hash and compare keys.</param> /// <returns>A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// a grouped join on two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="outer"/> or <paramref name="inner"/> or <paramref name="outerKeySelector"/> or /// <paramref name="innerKeySelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer!!, ParallelQuery<TInner> inner!!, Func<TOuter, TKey> outerKeySelector!!, Func<TInner, TKey> innerKeySelector!!, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector!!, IEqualityComparer<TKey>? comparer) { return new GroupJoinQueryOperator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } /// <summary> /// This GroupJoin overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TOuter">This type parameter is not used.</typeparam> /// <typeparam name="TInner">This type parameter is not used.</typeparam> /// <typeparam name="TKey">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="outer">This parameter is not used.</param> /// <param name="inner">This parameter is not used.</param> /// <param name="outerKeySelector">This parameter is not used.</param> /// <param name="innerKeySelector">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of GroupJoin with a left data source of type /// <see cref="System.Linq.ParallelQuery{TOuter}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TInner}"/>. /// Otherwise, the GroupJoin operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // SelectMany is a kind of nested loops join. For each element in the outer data // source, we enumerate each element in the inner data source, yielding the result // with some kind of selection routine. A few different flavors are supported. // /// <summary> /// Projects in parallel each element of a sequence to an IEnumerable{T} /// and flattens the resulting sequences into one sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of the elements of the sequence returned by <B>selector</B>.</typeparam> /// <param name="source">A sequence of values to project.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>A sequence whose elements are the result of invoking the one-to-many transform /// function on each element of the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> SelectMany<TSource, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, IEnumerable<TResult>> selector!!) { return new SelectManyQueryOperator<TSource, TResult, TResult>(source, selector, null, null); } /// <summary> /// Projects in parallel each element of a sequence to an IEnumerable{T}, and flattens the resulting /// sequences into one sequence. The index of each source element is used in the projected form of /// that element. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of the elements of the sequence returned by <B>selector</B>.</typeparam> /// <param name="source">A sequence of values to project.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>A sequence whose elements are the result of invoking the one-to-many transform /// function on each element of the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> SelectMany<TSource, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, int, IEnumerable<TResult>> selector!!) { return new SelectManyQueryOperator<TSource, TResult, TResult>(source, null, selector, null); } /// <summary> /// Projects each element of a sequence to an IEnumerable{T}, /// flattens the resulting sequences into one sequence, and invokes a result selector /// function on each element therein. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TCollection">The type of the intermediate elements collected by <paramref name="collectionSelector"/>.</typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="source">A sequence of values to project.</param> /// <param name="collectionSelector">A transform function to apply to each source element; /// the second parameter of the function represents the index of the source element.</param> /// <param name="resultSelector">A function to create a result element from an element from /// the first sequence and a collection of matching elements from the second sequence.</param> /// <returns>A sequence whose elements are the result of invoking the one-to-many transform /// function <paramref name="collectionSelector"/> on each element of <paramref name="source"/> and then mapping /// each of those sequence elements and their corresponding source element to a result element.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="collectionSelector"/> or /// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> SelectMany<TSource, TCollection, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, IEnumerable<TCollection>> collectionSelector!!, Func<TSource, TCollection, TResult> resultSelector!!) { return new SelectManyQueryOperator<TSource, TCollection, TResult>(source, collectionSelector, null, resultSelector); } /// <summary> /// Projects each element of a sequence to an IEnumerable{T}, flattens the resulting /// sequences into one sequence, and invokes a result selector function on each element /// therein. The index of each source element is used in the intermediate projected /// form of that element. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TCollection">The type of the intermediate elements collected by /// <paramref name="collectionSelector"/>.</typeparam> /// <typeparam name="TResult">The type of elements to return.</typeparam> /// <param name="source">A sequence of values to project.</param> /// <param name="collectionSelector">A transform function to apply to each source element; /// the second parameter of the function represents the index of the source element.</param> /// <param name="resultSelector">A function to create a result element from an element from /// the first sequence and a collection of matching elements from the second sequence.</param> /// <returns> /// A sequence whose elements are the result of invoking the one-to-many transform /// function <paramref name="collectionSelector"/> on each element of <paramref name="source"/> and then mapping /// each of those sequence elements and their corresponding source element to a /// result element. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="collectionSelector"/> or /// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> SelectMany<TSource, TCollection, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, int, IEnumerable<TCollection>> collectionSelector!!, Func<TSource, TCollection, TResult> resultSelector!!) { return new SelectManyQueryOperator<TSource, TCollection, TResult>(source, null, collectionSelector, resultSelector); } //----------------------------------------------------------------------------------- // OrderBy and ThenBy establish an ordering among elements, using user-specified key // selection and key comparison routines. There are also descending sort variants. // /// <summary> /// Sorts in parallel the elements of a sequence in ascending order according to a key. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// To achieve a stable sort, change a query of the form: /// <code>var ordered = source.OrderBy((e) => e.k);</code> /// to instead be formed as: /// <code>var ordered = source.Select((e,i) => new { E=e, I=i }).OrderBy((v) => v.i).Select((v) => v.e);</code> /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence of values to order.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> OrderBy<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!) { return new OrderedParallelQuery<TSource>( new SortQueryOperator<TSource, TKey>(source, keySelector, null, false)); } /// <summary> /// Sorts in parallel the elements of a sequence in ascending order by using a specified comparer. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence of values to order.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An IComparer{TKey} to compare keys.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted according /// to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> OrderBy<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IComparer<TKey>? comparer) { return new OrderedParallelQuery<TSource>( new SortQueryOperator<TSource, TKey>(source, keySelector, comparer, false)); } /// <summary> /// Sorts in parallel the elements of a sequence in descending order according to a key. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence of values to order.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// descending according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> OrderByDescending<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!) { return new OrderedParallelQuery<TSource>(new SortQueryOperator<TSource, TKey>(source, keySelector, null, true)); } /// <summary> /// Sorts the elements of a sequence in descending order by using a specified comparer. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence of values to order.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An IComparer{TKey} to compare keys.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted descending /// according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> OrderByDescending<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IComparer<TKey>? comparer) { return new OrderedParallelQuery<TSource>( new SortQueryOperator<TSource, TKey>(source, keySelector, comparer, true)); } /// <summary> /// Performs in parallel a subsequent ordering of the elements in a sequence /// in ascending order according to a key. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">An OrderedParallelQuery{TSource} than /// contains elements to sort.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are /// sorted according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> ThenBy<TSource, TKey>( this OrderedParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!) { return new OrderedParallelQuery<TSource>( (QueryOperator<TSource>)source.OrderedEnumerable.CreateOrderedEnumerable<TKey>(keySelector, null, false)); } /// <summary> /// Performs in parallel a subsequent ordering of the elements in a sequence in /// ascending order by using a specified comparer. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">An OrderedParallelQuery{TSource} that contains /// elements to sort.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An IComparer{TKey} to compare keys.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// public static OrderedParallelQuery<TSource> ThenBy<TSource, TKey>( this OrderedParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IComparer<TKey>? comparer) { return new OrderedParallelQuery<TSource>( (QueryOperator<TSource>)source.OrderedEnumerable.CreateOrderedEnumerable<TKey>(keySelector, comparer, false)); } /// <summary> /// Performs in parallel a subsequent ordering of the elements in a sequence in /// descending order, according to a key. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">An OrderedParallelQuery{TSource} than contains /// elements to sort.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// descending according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// public static OrderedParallelQuery<TSource> ThenByDescending<TSource, TKey>( this OrderedParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!) { return new OrderedParallelQuery<TSource>( (QueryOperator<TSource>)source.OrderedEnumerable.CreateOrderedEnumerable<TKey>(keySelector, null, true)); } /// <summary> /// Performs in parallel a subsequent ordering of the elements in a sequence in descending /// order by using a specified comparer. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">An OrderedParallelQuery{TSource} than contains /// elements to sort.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An IComparer{TKey} to compare keys.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// descending according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// public static OrderedParallelQuery<TSource> ThenByDescending<TSource, TKey>( this OrderedParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IComparer<TKey>? comparer) { return new OrderedParallelQuery<TSource>( (QueryOperator<TSource>)source.OrderedEnumerable.CreateOrderedEnumerable<TKey>(keySelector, comparer, true)); } //----------------------------------------------------------------------------------- // A GroupBy operation groups inputs based on a key-selection routine, yielding a // one-to-many value of key-to-elements to the consumer. // /// <summary> /// Groups in parallel the elements of a sequence according to a specified key selector function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a /// group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> /// is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector) { return GroupBy<TSource, TKey>(source, keySelector, null); } /// <summary> /// Groups in parallel the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An equality comparer to compare keys.</param> /// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a /// group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IEqualityComparer<TKey>? comparer) { return new GroupByQueryOperator<TSource, TKey, TSource>(source, keySelector, null, comparer); } /// <summary> /// Groups in parallel the elements of a sequence according to a specified key selector function and /// projects the elements for each group by using a specified function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the elements in each /// IGrouping{TKey, TElement}.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="elementSelector">A function to map each source element to an element in an /// IGrouping{Key, TElement}.</param> /// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a /// group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) { return GroupBy<TSource, TKey, TElement>(source, keySelector, elementSelector, null); } /// <summary> /// Groups in parallel the elements of a sequence according to a key selector function. /// The keys are compared by using a comparer and each group's elements are projected by /// using a specified function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the elements in each /// IGrouping{TKey, TElement}.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="elementSelector">A function to map each source element to an element in an /// IGrouping{Key, TElement}.</param> /// <param name="comparer">An equality comparer to compare keys.</param> /// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a /// group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, Func<TSource, TElement> elementSelector!!, IEqualityComparer<TKey>? comparer) { return new GroupByQueryOperator<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer); } // // @PERF: We implement the GroupBy overloads that accept a resultSelector using a GroupBy followed by a Select. This // adds some extra overhead, perhaps the most significant of which is an extra delegate invocation per element. // // One possible solution is to create two different versions of the GroupByOperator class, where one has a TResult // generic type and the other does not. Since this results in code duplication, we will avoid doing that for now. // // Another possible solution is to only have the more general GroupByOperator. Unfortunately, implementing the less // general overload (TResult == TElement) using the more general overload would likely result in unnecessary boxing // and unboxing of each processed element in the cases where TResult is a value type, so that solution comes with // a significant cost, too. // /// <summary> /// Groups in parallel the elements of a sequence according to a specified /// key selector function and creates a result value from each group and its key. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="resultSelector">A function to create a result value from each group.</param> /// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a /// projection over a group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupBy<TSource, TKey, TResult>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector!!) { return source.GroupBy<TSource, TKey>(keySelector) .Select<IGrouping<TKey, TSource>, TResult>(delegate (IGrouping<TKey, TSource> grouping) { return resultSelector(grouping.Key, grouping); }); } /// <summary> /// Groups in parallel the elements of a sequence according to a specified key selector function /// and creates a result value from each group and its key. The keys are compared /// by using a specified comparer. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="resultSelector">A function to create a result value from each group.</param> /// <param name="comparer">An equality comparer to compare keys.</param> /// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a /// projection over a group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupBy<TSource, TKey, TResult>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector!!, IEqualityComparer<TKey>? comparer) { return source.GroupBy<TSource, TKey>(keySelector, comparer).Select<IGrouping<TKey, TSource>, TResult>( delegate (IGrouping<TKey, TSource> grouping) { return resultSelector(grouping.Key, grouping); }); } /// <summary> /// Groups in parallel the elements of a sequence according to a specified key /// selector function and creates a result value from each group and its key. /// The elements of each group are projected by using a specified function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the elements in each /// IGrouping{TKey, TElement}.</typeparam> /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="elementSelector">A function to map each source element to an element in an /// IGrouping{Key, TElement}.</param> /// <param name="resultSelector">A function to create a result value from each group.</param> /// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a /// projection over a group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="elementSelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupBy<TSource, TKey, TElement, TResult>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector!!) { return source.GroupBy<TSource, TKey, TElement>(keySelector, elementSelector) .Select<IGrouping<TKey, TElement>, TResult>(delegate (IGrouping<TKey, TElement> grouping) { return resultSelector(grouping.Key, grouping); }); } /// <summary> /// Groups the elements of a sequence according to a specified key selector function and /// creates a result value from each group and its key. Key values are compared by using a /// specified comparer, and the elements of each group are projected by using a specified function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the elements in each /// IGrouping{TKey, TElement}.</typeparam> /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="elementSelector">A function to map each source element to an element in an /// IGrouping{Key, TElement}.</param> /// <param name="resultSelector">A function to create a result value from each group.</param> /// <param name="comparer">An equality comparer to compare keys.</param> /// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a /// projection over a group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="elementSelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupBy<TSource, TKey, TElement, TResult>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector!!, IEqualityComparer<TKey>? comparer) { return source.GroupBy<TSource, TKey, TElement>(keySelector, elementSelector, comparer) .Select<IGrouping<TKey, TElement>, TResult>(delegate (IGrouping<TKey, TElement> grouping) { return resultSelector(grouping.Key, grouping); }); } /*=================================================================================== * AGGREGATION OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Internal helper method that constructs an aggregation query operator and performs // the actual execution/reduction before returning the result. // // Arguments: // source - the data source over which aggregation is performed // reduce - the binary reduction operator // options - whether the operator is associative, commutative, both, or neither // // Return Value: // The result of aggregation. // private static T PerformAggregation<T>(this ParallelQuery<T> source, Func<T, T, T> reduce, T seed, bool seedIsSpecified, bool throwIfEmpty, QueryAggregationOptions options) { Debug.Assert(source != null); Debug.Assert(reduce != null); Debug.Assert(options.IsValidQueryAggregationOption(), "enum is out of range"); AssociativeAggregationOperator<T, T, T> op = new AssociativeAggregationOperator<T, T, T>( source, seed, null, seedIsSpecified, reduce, reduce, delegate (T obj) { return obj; }, throwIfEmpty, options); return op.Aggregate(); } /// <summary> /// Run an aggregation sequentially. If the user-provided reduction function throws an exception, wrap /// it with an AggregateException. /// </summary> /// <param name="source"></param> /// <param name="seed"></param> /// <param name="seedIsSpecified"> /// if true, use the seed provided in the method argument /// if false, use the first element of the sequence as the seed instead /// </param> /// <param name="func"></param> private static TAccumulate PerformSequentialAggregation<TSource, TAccumulate>( this ParallelQuery<TSource> source, TAccumulate seed, bool seedIsSpecified, Func<TAccumulate, TSource, TAccumulate> func) { Debug.Assert(source != null); Debug.Assert(func != null); Debug.Assert(seedIsSpecified || typeof(TSource) == typeof(TAccumulate)); using (IEnumerator<TSource> enumerator = source.GetEnumerator()) { TAccumulate acc; if (seedIsSpecified) { acc = seed; } else { // Take the first element as the seed if (!enumerator.MoveNext()) { throw new InvalidOperationException(SR.NoElements); } acc = (TAccumulate)(object)enumerator.Current!; } while (enumerator.MoveNext()) { TSource elem = enumerator.Current; // If the user delegate throws an exception, wrap it with an AggregateException try { acc = func(acc, elem); } catch (Exception e) { throw new AggregateException(e); } } return acc; } } //----------------------------------------------------------------------------------- // General purpose aggregation operators, allowing pluggable binary prefix operations. // /// <summary> /// Applies in parallel an accumulator function over a sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="func">An accumulator function to be invoked on each element.</param> /// <returns>The final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="func"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Aggregate<TSource>( this ParallelQuery<TSource> source, Func<TSource, TSource, TSource> func) { return Aggregate<TSource>(source, func, QueryAggregationOptions.AssociativeCommutative); } internal static TSource Aggregate<TSource>( this ParallelQuery<TSource> source!!, Func<TSource, TSource, TSource> func!!, QueryAggregationOptions options) { if ((~(QueryAggregationOptions.Associative | QueryAggregationOptions.Commutative) & options) != 0) throw new ArgumentOutOfRangeException(nameof(options)); if ((options & QueryAggregationOptions.Associative) != QueryAggregationOptions.Associative) { // Non associative aggregations must be run sequentially. We run the query in parallel // and then perform the reduction over the resulting list. return source.PerformSequentialAggregation(default!, false, func); } else { // If associative, we can run this aggregation in parallel. The logic of the aggregation // operator depends on whether the operator is commutative, so we also pass that information // down to the query planning/execution engine. return source.PerformAggregation<TSource>(func, default!, false, true, options); } } /// <summary> /// Applies in parallel an accumulator function over a sequence. /// The specified seed value is used as the initial accumulator value. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="seed">The initial accumulator value.</param> /// <param name="func">An accumulator function to be invoked on each element.</param> /// <returns>The final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="func"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TAccumulate Aggregate<TSource, TAccumulate>( this ParallelQuery<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func) { return Aggregate<TSource, TAccumulate>(source, seed, func, QueryAggregationOptions.AssociativeCommutative); } internal static TAccumulate Aggregate<TSource, TAccumulate>( this ParallelQuery<TSource> source!!, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func!!, QueryAggregationOptions options) { if ((~(QueryAggregationOptions.Associative | QueryAggregationOptions.Commutative) & options) != 0) throw new ArgumentOutOfRangeException(nameof(options)); return source.PerformSequentialAggregation(seed, true, func); } /// <summary> /// Applies in parallel an accumulator function over a sequence. The specified /// seed value is used as the initial accumulator value, and the specified /// function is used to select the result value. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam> /// <typeparam name="TResult">The type of the resulting value.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="seed">The initial accumulator value.</param> /// <param name="func">An accumulator function to be invoked on each element.</param> /// <param name="resultSelector">A function to transform the final accumulator value /// into the result value.</param> /// <returns>The transformed final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="func"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult Aggregate<TSource, TAccumulate, TResult>( this ParallelQuery<TSource> source!!, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func!!, Func<TAccumulate, TResult> resultSelector!!) { TAccumulate acc = source.PerformSequentialAggregation(seed, true, func); try { return resultSelector(acc); } catch (Exception e) { throw new AggregateException(e); } } /// <summary> /// Applies in parallel an accumulator function over a sequence. This overload is not /// available in the sequential implementation. /// </summary> /// <remarks> /// This overload is specific to processing a parallelized query. A parallelized query may /// partition the data source sequence into several sub-sequences (partitions). /// The <paramref name="updateAccumulatorFunc"/> is invoked on each element within partitions. /// Each partition then yields a single accumulated result. The <paramref name="combineAccumulatorsFunc"/> /// is then invoked on the results of each partition to yield a single element. This element is then /// transformed by the <paramref name="resultSelector"/> function. /// </remarks> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam> /// <typeparam name="TResult">The type of the resulting value.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="seed">The initial accumulator value.</param> /// <param name="updateAccumulatorFunc"> /// An accumulator function to be invoked on each element in a partition. /// </param> /// <param name="combineAccumulatorsFunc"> /// An accumulator function to be invoked on the yielded element from each partition. /// </param> /// <param name="resultSelector"> /// A function to transform the final accumulator value into the result value. /// </param> /// <returns>The transformed final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="updateAccumulatorFunc"/> /// or <paramref name="combineAccumulatorsFunc"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult Aggregate<TSource, TAccumulate, TResult>( this ParallelQuery<TSource> source!!, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> updateAccumulatorFunc!!, Func<TAccumulate, TAccumulate, TAccumulate> combineAccumulatorsFunc!!, Func<TAccumulate, TResult> resultSelector!!) { return new AssociativeAggregationOperator<TSource, TAccumulate, TResult>( source, seed, null, true, updateAccumulatorFunc, combineAccumulatorsFunc, resultSelector, false, QueryAggregationOptions.AssociativeCommutative).Aggregate(); } /// <summary> /// Applies in parallel an accumulator function over a sequence. This overload is not /// available in the sequential implementation. /// </summary> /// <remarks> /// This overload is specific to parallelized queries. A parallelized query may partition the data source sequence /// into several sub-sequences (partitions). The <paramref name="updateAccumulatorFunc"/> is invoked /// on each element within partitions. Each partition then yields a single accumulated result. /// The <paramref name="combineAccumulatorsFunc"/> /// is then invoked on the results of each partition to yield a single element. This element is then /// transformed by the <paramref name="resultSelector"/> function. /// </remarks> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam> /// <typeparam name="TResult">The type of the resulting value.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="seedFactory"> /// A function that returns the initial accumulator value. /// </param> /// <param name="updateAccumulatorFunc"> /// An accumulator function to be invoked on each element in a partition. /// </param> /// <param name="combineAccumulatorsFunc"> /// An accumulator function to be invoked on the yielded element from each partition. /// </param> /// <param name="resultSelector"> /// A function to transform the final accumulator value into the result value. /// </param> /// <returns>The transformed final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="seedFactory"/> or <paramref name="updateAccumulatorFunc"/> /// or <paramref name="combineAccumulatorsFunc"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult Aggregate<TSource, TAccumulate, TResult>( this ParallelQuery<TSource> source!!, Func<TAccumulate> seedFactory!!, Func<TAccumulate, TSource, TAccumulate> updateAccumulatorFunc!!, Func<TAccumulate, TAccumulate, TAccumulate> combineAccumulatorsFunc!!, Func<TAccumulate, TResult> resultSelector!!) { return new AssociativeAggregationOperator<TSource, TAccumulate, TResult>( source, default!, seedFactory, true, updateAccumulatorFunc, combineAccumulatorsFunc, resultSelector, false, QueryAggregationOptions.AssociativeCommutative).Aggregate(); } //----------------------------------------------------------------------------------- // Count and LongCount reductions. // /// <summary> /// Returns the number of elements in a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence that contains elements to be counted.</param> /// <returns>The number of elements in the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The number of elements in source is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Count<TSource>(this ParallelQuery<TSource> source!!) { // If the data source is a collection, we can just return the count right away. if (source is ParallelEnumerableWrapper<TSource> sourceAsWrapper) { if (sourceAsWrapper.WrappedEnumerable is ICollection<TSource> sourceAsCollection) { return sourceAsCollection.Count; } } // Otherwise, enumerate the whole thing and aggregate a count. checked { return new CountAggregationOperator<TSource>(source).Aggregate(); } } /// <summary> /// Returns a number that represents how many elements in the specified /// parallel sequence satisfy a condition. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence that contains elements to be counted.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// A number that represents how many elements in the sequence satisfy the condition /// in the predicate function. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The number of elements in source is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Count<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { // Construct a where operator to filter out non-matching elements, and then aggregate. checked { return new CountAggregationOperator<TSource>(Where<TSource>(source, predicate)).Aggregate(); } } /// <summary> /// Returns an Int64 that represents the total number of elements in a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence that contains elements to be counted.</param> /// <returns>The number of elements in the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The number of elements in source is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long LongCount<TSource>(this ParallelQuery<TSource> source!!) { // If the data source is a collection, we can just return the count right away. if (source is ParallelEnumerableWrapper<TSource> sourceAsWrapper) { if (sourceAsWrapper.WrappedEnumerable is ICollection<TSource> sourceAsCollection) { return sourceAsCollection.Count; } } // Otherwise, enumerate the whole thing and aggregate a count. return new LongCountAggregationOperator<TSource>(source).Aggregate(); } /// <summary> /// Returns an Int64 that represents how many elements in a parallel sequence satisfy a condition. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence that contains elements to be counted.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// A number that represents how many elements in the sequence satisfy the condition /// in the predicate function. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The number of elements in source is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long LongCount<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { // Construct a where operator to filter out non-matching elements, and then aggregate. return new LongCountAggregationOperator<TSource>(Where<TSource>(source, predicate)).Aggregate(); } //----------------------------------------------------------------------------------- // Sum aggregations. // /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Sum(this ParallelQuery<int> source!!) { return new IntSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Sum(this ParallelQuery<int?> source!!) { return new NullableIntSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Sum(this ParallelQuery<long> source!!) { return new LongSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Sum(this ParallelQuery<long?> source!!) { return new NullableLongSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Sum(this ParallelQuery<float> source!!) { return new FloatSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Sum(this ParallelQuery<float?> source!!) { return new NullableFloatSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Sum(this ParallelQuery<double> source!!) { return new DoubleSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Sum(this ParallelQuery<double?> source!!) { return new NullableDoubleSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="decimal.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Sum(this ParallelQuery<decimal> source!!) { return new DecimalSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="decimal.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Sum(this ParallelQuery<decimal?> source!!) { return new NullableDecimalSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, int> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, int?> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, long> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, long?> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, float> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, float?> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, double> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, double?> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="decimal.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="decimal.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal?> selector) { return source.Select(selector).Sum(); } //----------------------------------------------------------------------------------- // Helper methods used for Min/Max aggregations below. This class can create a whole // bunch of type-specific delegates that are passed to the general aggregation // infrastructure. All comparisons are performed using the Comparer<T>.Default // comparator. LINQ doesn't offer a way to override this, so neither do we. // // @PERF: we'll eventually want inlined primitive providers that use IL instructions // for comparison instead of the Comparer<T>.CompareTo method. // //----------------------------------------------------------------------------------- // Min aggregations. // /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Min(this ParallelQuery<int> source!!) { return new IntMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Min(this ParallelQuery<int?> source!!) { return new NullableIntMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Min(this ParallelQuery<long> source!!) { return new LongMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Min(this ParallelQuery<long?> source!!) { return new NullableLongMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Min(this ParallelQuery<float> source!!) { return new FloatMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Min(this ParallelQuery<float?> source!!) { return new NullableFloatMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Min(this ParallelQuery<double> source!!) { return new DoubleMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Min(this ParallelQuery<double?> source!!) { return new NullableDoubleMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Min(this ParallelQuery<decimal> source!!) { return new DecimalMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Min(this ParallelQuery<decimal?> source!!) { return new NullableDecimalMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements and <typeparamref name="TSource"/> is a non-nullable value type. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? Min<TSource>(this ParallelQuery<TSource> source!!) { return AggregationMinMaxHelpers<TSource>.ReduceMin(source); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, int> selector) { return source.Select<TSource, int>(selector).Min<int>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, int?> selector) { return source.Select<TSource, int?>(selector).Min<int?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, long> selector) { return source.Select<TSource, long>(selector).Min<long>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, long?> selector) { return source.Select<TSource, long?>(selector).Min<long?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, float> selector) { return source.Select<TSource, float>(selector).Min<float>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, float?> selector) { return source.Select<TSource, float?>(selector).Min<float?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, double> selector) { return source.Select<TSource, double>(selector).Min<double>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, double?> selector) { return source.Select<TSource, double?>(selector).Min<double?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal> selector) { return source.Select<TSource, decimal>(selector).Min<decimal>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal?> selector) { return source.Select<TSource, decimal?>(selector).Min<decimal?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of the value returned by <paramref name="selector"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements and <typeparamref name="TResult"/> is a non-nullable value type. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult? Min<TSource, TResult>(this ParallelQuery<TSource> source, Func<TSource, TResult> selector) { return source.Select<TSource, TResult>(selector).Min<TResult>(); } //----------------------------------------------------------------------------------- // Max aggregations. // /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Max(this ParallelQuery<int> source!!) { return new IntMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Max(this ParallelQuery<int?> source!!) { return new NullableIntMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Max(this ParallelQuery<long> source!!) { return new LongMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Max(this ParallelQuery<long?> source!!) { return new NullableLongMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Max(this ParallelQuery<float> source!!) { return new FloatMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Max(this ParallelQuery<float?> source!!) { return new NullableFloatMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Max(this ParallelQuery<double> source!!) { return new DoubleMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Max(this ParallelQuery<double?> source!!) { return new NullableDoubleMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Max(this ParallelQuery<decimal> source!!) { return new DecimalMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Max(this ParallelQuery<decimal?> source!!) { return new NullableDecimalMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements and <typeparam name="TSource"/> is a non-nullable value type. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? Max<TSource>(this ParallelQuery<TSource> source!!) { return AggregationMinMaxHelpers<TSource>.ReduceMax(source); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, int> selector) { return source.Select<TSource, int>(selector).Max<int>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, int?> selector) { return source.Select<TSource, int?>(selector).Max<int?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, long> selector) { return source.Select<TSource, long>(selector).Max<long>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, long?> selector) { return source.Select<TSource, long?>(selector).Max<long?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, float> selector) { return source.Select<TSource, float>(selector).Max<float>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, float?> selector) { return source.Select<TSource, float?>(selector).Max<float?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, double> selector) { return source.Select<TSource, double>(selector).Max<double>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, double?> selector) { return source.Select<TSource, double?>(selector).Max<double?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal> selector) { return source.Select<TSource, decimal>(selector).Max<decimal>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal?> selector) { return source.Select<TSource, decimal?>(selector).Max<decimal?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of the value returned by <paramref name="selector"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements and <typeparamref name="TResult"/> is a non-nullable value type. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult? Max<TSource, TResult>(this ParallelQuery<TSource> source, Func<TSource, TResult> selector) { return source.Select<TSource, TResult>(selector).Max<TResult>(); } //----------------------------------------------------------------------------------- // Average aggregations. // /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average(this ParallelQuery<int> source!!) { return new IntAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average(this ParallelQuery<int?> source!!) { return new NullableIntAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average(this ParallelQuery<long> source!!) { return new LongAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average(this ParallelQuery<long?> source!!) { return new NullableLongAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Average(this ParallelQuery<float> source!!) { return new FloatAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Average(this ParallelQuery<float?> source!!) { return new NullableFloatAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average(this ParallelQuery<double> source!!) { return new DoubleAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <exception cref="System.ArgumentNullException"> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average(this ParallelQuery<double?> source!!) { return new NullableDoubleAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Average(this ParallelQuery<decimal> source!!) { return new DecimalAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Average(this ParallelQuery<decimal?> source!!) { return new NullableDecimalAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, int> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, int?> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, long> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, long?> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, float> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, float?> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, double> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, double?> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal?> selector) { return source.Select(selector).Average(); } //----------------------------------------------------------------------------------- // Any returns true if there exists an element for which the predicate returns true. // /// <summary> /// Determines in parallel whether any element of a sequence satisfies a condition. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">An IEnumerable whose elements to apply the predicate to.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// true if any elements in the source sequence pass the test in the specified predicate; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool Any<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new AnyAllSearchOperator<TSource>(source, true, predicate).Aggregate(); } /// <summary> /// Determines whether a parallel sequence contains any elements. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The IEnumerable to check for emptiness.</param> /// <returns>true if the source sequence contains any elements; otherwise, false.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool Any<TSource>(this ParallelQuery<TSource> source!!) { return Any(source, x => true); } //----------------------------------------------------------------------------------- // All returns false if there exists an element for which the predicate returns false. // /// <summary> /// Determines in parallel whether all elements of a sequence satisfy a condition. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence whose elements to apply the predicate to.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// true if all elements in the source sequence pass the test in the specified predicate; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool All<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new AnyAllSearchOperator<TSource>(source, false, predicate).Aggregate(); } //----------------------------------------------------------------------------------- // Contains returns true if the specified value was found in the data source. // /// <summary> /// Determines in parallel whether a sequence contains a specified element /// by using the default equality comparer. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence in which to locate a value.</param> /// <param name="value">The value to locate in the sequence.</param> /// <returns> /// true if the source sequence contains an element that has the specified value; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool Contains<TSource>(this ParallelQuery<TSource> source, TSource value) { return Contains(source, value, null); } /// <summary> /// Determines in parallel whether a sequence contains a specified element by using a /// specified IEqualityComparer{T}. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence in which to locate a value.</param> /// <param name="value">The value to locate in the sequence.</param> /// <param name="comparer">An equality comparer to compare values.</param> /// <returns> /// true if the source sequence contains an element that has the specified value; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool Contains<TSource>(this ParallelQuery<TSource> source!!, TSource value, IEqualityComparer<TSource>? comparer) { // @PERF: there are many simple optimizations we can make for collection types with known sizes. return new ContainsSearchOperator<TSource>(source, value, comparer).Aggregate(); } /*=================================================================================== * TOP (TAKE, SKIP) OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Take will take the first [0..count) contiguous elements from the input. // /// <summary> /// Returns a specified number of contiguous elements from the start of a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="count">The number of elements to return.</param> /// <returns> /// A sequence that contains the specified number of elements from the start of the input sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Take<TSource>(this ParallelQuery<TSource> source!!, int count) { if (count > 0) { return new TakeOrSkipQueryOperator<TSource>(source, count, true); } else { return ParallelEnumerable.Empty<TSource>(); } } //----------------------------------------------------------------------------------- // TakeWhile will take the first [0..N) contiguous elements, where N is the smallest // index of an element for which the predicate yields false. // /// <summary> /// Returns elements from a parallel sequence as long as a specified condition is true. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// A sequence that contains the elements from the input sequence that occur before /// the element at which the test no longer passes. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> TakeWhile<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new TakeOrSkipWhileQueryOperator<TSource>(source, predicate, null, true); } /// <summary> /// Returns elements from a parallel sequence as long as a specified condition is true. /// The element's index is used in the logic of the predicate function. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="predicate"> /// A function to test each source element for a condition; the second parameter of the /// function represents the index of the source element. /// </param> /// <returns> /// A sequence that contains elements from the input sequence that occur before /// the element at which the test no longer passes. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> TakeWhile<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, int, bool> predicate!!) { return new TakeOrSkipWhileQueryOperator<TSource>(source, null, predicate, true); } //----------------------------------------------------------------------------------- // Skip will take the last [count..M) contiguous elements from the input, where M is // the size of the input. // /// <summary> /// Bypasses a specified number of elements in a parallel sequence and then returns the remaining elements. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="count">The number of elements to skip before returning the remaining elements.</param> /// <returns> /// A sequence that contains the elements that occur after the specified index in the input sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Skip<TSource>(this ParallelQuery<TSource> source!!, int count) { // If the count is 0 (or less) we just return the whole stream. if (count <= 0) { return source; } return new TakeOrSkipQueryOperator<TSource>(source, count, false); } //----------------------------------------------------------------------------------- // SkipWhile will take the last [N..M) contiguous elements, where N is the smallest // index of an element for which the predicate yields false, and M is the size of // the input data source. // /// <summary> /// Bypasses elements in a parallel sequence as long as a specified /// condition is true and then returns the remaining elements. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns>A sequence that contains the elements from the input sequence starting at /// the first element in the linear series that does not pass the test specified by /// <B>predicate</B>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> SkipWhile<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new TakeOrSkipWhileQueryOperator<TSource>(source, predicate, null, false); } /// <summary> /// Bypasses elements in a parallel sequence as long as a specified condition is true and /// then returns the remaining elements. The element's index is used in the logic of /// the predicate function. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="predicate"> /// A function to test each source element for a condition; the /// second parameter of the function represents the index of the source element. /// </param> /// <returns> /// A sequence that contains the elements from the input sequence starting at the /// first element in the linear series that does not pass the test specified by /// <B>predicate</B>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> SkipWhile<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, int, bool> predicate!!) { return new TakeOrSkipWhileQueryOperator<TSource>(source, null, predicate, false); } /*=================================================================================== * SET OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Appends the second data source to the first, preserving order in the process. // /// <summary> /// Concatenates two parallel sequences. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">The first sequence to concatenate.</param> /// <param name="second">The sequence to concatenate to the first sequence.</param> /// <returns>A sequence that contains the concatenated elements of the two input sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Concat<TSource>(this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!) { return new ConcatQueryOperator<TSource>(first, second); } /// <summary> /// This Concat overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Concat with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Concat operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Concat<TSource>(this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Compares two input streams pairwise for equality. // /// <summary> /// Determines whether two parallel sequences are equal by comparing the elements by using /// the default equality comparer for their type. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence to compare to <b>second</b>.</param> /// <param name="second">A sequence to compare to the first input sequence.</param> /// <returns> /// true if the two source sequences are of equal length and their corresponding elements /// are equal according to the default equality comparer for their type; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool SequenceEqual<TSource>(this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!) { return SequenceEqual<TSource>(first, second, null); } /// <summary> /// This SequenceEqual overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">Thrown every time this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of SequenceEqual with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the SequenceEqual operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static bool SequenceEqual<TSource>(this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Determines whether two parallel sequences are equal by comparing their elements by /// using a specified IEqualityComparer{T}. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence to compare to <paramref name="second"/>.</param> /// <param name="second">A sequence to compare to the first input sequence.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to use to compare elements.</param> /// <returns> /// true if the two source sequences are of equal length and their corresponding /// elements are equal according to the default equality comparer for their type; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool SequenceEqual<TSource>(this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!, IEqualityComparer<TSource>? comparer) { // If comparer is null, use the default one comparer ??= EqualityComparer<TSource>.Default; QueryOperator<TSource> leftOp = QueryOperator<TSource>.AsQueryOperator(first); QueryOperator<TSource> rightOp = QueryOperator<TSource>.AsQueryOperator(second); // We use a fully-qualified type name for Shared here to prevent the conflict between System.Linq.Parallel.Shared<> // and System.Threading.Shared<> in the 3.5 legacy build. QuerySettings settings = leftOp.SpecifiedQuerySettings.Merge(rightOp.SpecifiedQuerySettings) .WithDefaults() .WithPerExecutionSettings(new CancellationTokenSource(), new System.Linq.Parallel.Shared<bool>(false)); // If first.GetEnumerator throws an exception, we don't want to wrap it with an AggregateException. IEnumerator<TSource> e1 = first.GetEnumerator(); try { // If second.GetEnumerator throws an exception, we don't want to wrap it with an AggregateException. IEnumerator<TSource> e2 = second.GetEnumerator(); try { while (e1.MoveNext()) { if (!(e2.MoveNext() && comparer.Equals(e1.Current, e2.Current))) return false; } if (e2.MoveNext()) return false; } catch (Exception ex) { ExceptionAggregator.ThrowOCEorAggregateException(ex, settings.CancellationState); } finally { DisposeEnumerator<TSource>(e2, settings.CancellationState); } } finally { DisposeEnumerator<TSource>(e1, settings.CancellationState); } return true; } /// <summary> /// A helper method for SequenceEqual to dispose an enumerator. If an exception is thrown by the disposal, /// it gets wrapped into an AggregateException, unless it is an OCE with the query's CancellationToken. /// </summary> private static void DisposeEnumerator<TSource>(IEnumerator<TSource> e, CancellationState cancelState) { try { e.Dispose(); } catch (Exception ex) { ExceptionAggregator.ThrowOCEorAggregateException(ex, cancelState); } } /// <summary> /// This SequenceEqual overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">Thrown every time this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of SequenceEqual with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the SequenceEqual operator would appear to be binding to the parallel implementation, /// but would in reality bind to sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static bool SequenceEqual<TSource>(this ParallelQuery<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Calculates the distinct set of elements in the single input data source. // /// <summary> /// Returns distinct elements from a parallel sequence by using the /// default equality comparer to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to remove duplicate elements from.</param> /// <returns>A sequence that contains distinct elements from the source sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Distinct<TSource>( this ParallelQuery<TSource> source) { return Distinct(source, null); } /// <summary> /// Returns distinct elements from a parallel sequence by using a specified /// IEqualityComparer{T} to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to remove duplicate elements from.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare values.</param> /// <returns>A sequence that contains distinct elements from the source sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Distinct<TSource>( this ParallelQuery<TSource> source!!, IEqualityComparer<TSource>? comparer) { return new DistinctQueryOperator<TSource>(source, comparer); } //----------------------------------------------------------------------------------- // Calculates the union between the first and second data sources. // /// <summary> /// Produces the set union of two parallel sequences by using the default equality comparer. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence whose distinct elements form the first set for the union.</param> /// <param name="second">A sequence whose distinct elements form the second set for the union.</param> /// <returns>A sequence that contains the elements from both input sequences, excluding duplicates.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Union<TSource>( this ParallelQuery<TSource> first, ParallelQuery<TSource> second) { return Union(first, second, null); } /// <summary> /// This Union overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Union with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Union operator would appear to be binding to the parallel implementation, /// but would in reality bind to sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Union<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Produces the set union of two parallel sequences by using a specified IEqualityComparer{T}. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence whose distinct elements form the first set for the union.</param> /// <param name="second">A sequence whose distinct elements form the second set for the union.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare values.</param> /// <returns>A sequence that contains the elements from both input sequences, excluding duplicates.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Union<TSource>( this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!, IEqualityComparer<TSource>? comparer) { return new UnionQueryOperator<TSource>(first, second, comparer); } /// <summary> /// This Union overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Union with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Union operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Union<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Calculates the intersection between the first and second data sources. // /// <summary> /// Produces the set intersection of two parallel sequences by using the /// default equality comparer to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first" /// >A sequence whose distinct elements that also appear in <paramref name="second"/> will be returned. /// </param> /// <param name="second"> /// A sequence whose distinct elements that also appear in the first sequence will be returned. /// </param> /// <returns>A sequence that contains the elements that form the set intersection of two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Intersect<TSource>( this ParallelQuery<TSource> first, ParallelQuery<TSource> second) { return Intersect(first, second, null); } /// <summary> /// This Intersect overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Intersect with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Intersect operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Intersect<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Produces the set intersection of two parallel sequences by using /// the specified IEqualityComparer{T} to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first"> /// A sequence whose distinct elements that also appear in <paramref name="second"/> will be returned. /// </param> /// <param name="second"> /// A sequence whose distinct elements that also appear in the first sequence will be returned. /// </param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare values.</param> /// <returns>A sequence that contains the elements that form the set intersection of two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Intersect<TSource>( this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!, IEqualityComparer<TSource>? comparer) { return new IntersectQueryOperator<TSource>(first, second, comparer); } /// <summary> /// This Intersect overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Intersect with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Intersect operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Intersect<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Calculates the relative complement of the first and second data sources, that is, // the elements in first that are not found in second. // /// <summary> /// Produces the set difference of two parallel sequences by using /// the default equality comparer to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first"> /// A sequence whose elements that are not also in <paramref name="second"/> will be returned. /// </param> /// <param name="second"> /// A sequence whose elements that also occur in the first sequence will cause those /// elements to be removed from the returned sequence. /// </param> /// <returns>A sequence that contains the set difference of the elements of two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Except<TSource>( this ParallelQuery<TSource> first, ParallelQuery<TSource> second) { return Except(first, second, null); } /// <summary> /// This Except overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Except with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Except operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Except<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Produces the set difference of two parallel sequences by using the /// specified IEqualityComparer{T} to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence whose elements that are not also in <paramref name="second"/> will be returned.</param> /// <param name="second"> /// A sequence whose elements that also occur in the first sequence will cause those elements /// to be removed from the returned sequence. /// </param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare values.</param> /// <returns>A sequence that contains the set difference of the elements of two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Except<TSource>( this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!, IEqualityComparer<TSource>? comparer) { return new ExceptQueryOperator<TSource>(first, second, comparer); } /// <summary> /// This Except overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Except with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Except operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Except<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /*=================================================================================== * DATA TYPE CONVERSION OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // For compatibility with LINQ. Changes the static type to be less specific if needed. // /// <summary> /// Converts a <see cref="ParallelQuery{T}"/> into an /// <see cref="System.Collections.Generic.IEnumerable{T}"/> to force sequential /// evaluation of the query. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to type as <see cref="System.Collections.Generic.IEnumerable{T}"/>.</param> /// <returns>The input sequence types as <see cref="System.Collections.Generic.IEnumerable{T}"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static IEnumerable<TSource> AsEnumerable<TSource>(this ParallelQuery<TSource> source) { return AsSequential(source); } //----------------------------------------------------------------------------------- // Simply generates a single-dimensional array containing the elements from the // provided enumerable object. // /// <summary> /// Creates an array from a ParallelQuery{T}. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to create an array from.</param> /// <returns>An array that contains the elements from the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource[] ToArray<TSource>(this ParallelQuery<TSource> source!!) { if (source is QueryOperator<TSource> asOperator) { return asOperator.ExecuteAndGetResultsAsArray(); } return ToList<TSource>(source).ToArray<TSource>(); } //----------------------------------------------------------------------------------- // The ToList method is similar to the ToArray methods above, except that they return // List<TSource> objects. An overload is provided to specify the length, if desired. // /// <summary> /// Creates a List{T} from an ParallelQuery{T}. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to create a List&lt;(Of &lt;(T&gt;)&gt;) from.</param> /// <returns>A List&lt;(Of &lt;(T&gt;)&gt;) that contains elements from the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static List<TSource> ToList<TSource>(this ParallelQuery<TSource> source!!) { // Allocate a growable list (optionally passing the length as the initial size). List<TSource> list = new List<TSource>(); IEnumerator<TSource> input; if (source is QueryOperator<TSource> asOperator) { if (asOperator.OrdinalIndexState == OrdinalIndexState.Indexable && asOperator.OutputOrdered) { // If the query is indexable and the output is ordered, we will use the array-based merge. // That way, we avoid the ordering overhead. Due to limitations of the List<> class, the // most efficient solution seems to be to first dump all results into the array, and then // copy them over into a List<>. // // The issue is that we cannot efficiently construct a List<> with a fixed size. We can // construct a List<> with a fixed *capacity*, but we still need to call Add() N times // in order to be able to index into the List<>. return new List<TSource>(ToArray<TSource>(source)); } // We will enumerate the list w/out pipelining. // @PERF: there are likely some cases, e.g. for very large data sets, // where we want to use pipelining for this operation. It can reduce memory // usage since, as we enumerate w/ pipelining off, we're already accumulating // results into a buffer. As a matter of fact, there's probably a way we can // just directly use that buffer below instead of creating a new list. input = asOperator.GetEnumerator(ParallelMergeOptions.FullyBuffered); } else { input = source.GetEnumerator(); } // Now, accumulate the results into a dynamically sized list, stopping if we reach // the (optionally specified) maximum length. Debug.Assert(input != null); using (input) { while (input.MoveNext()) { list.Add(input.Current); } } return list; } //----------------------------------------------------------------------------------- // ToDictionary constructs a dictionary from an instance of ParallelQuery. // Each element in the enumerable is converted to a (key,value) pair using a pair // of lambda expressions specified by the caller. Different elements must produce // different keys or else ArgumentException is thrown. // /// <summary> /// Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to /// a specified key selector function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence to create a Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <returns>A Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) that contains keys and values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// <paramref name="keySelector"/> produces a key that is a null reference (Nothing in Visual Basic). /// -or- /// <paramref name="keySelector"/> produces duplicate keys for two elements. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector) where TKey : notnull { return ToDictionary(source, keySelector, EqualityComparer<TKey>.Default); } /// <summary> /// Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to a /// specified key selector function and key comparer. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence to create a Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare keys.</param> /// <returns>A Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) that contains keys and values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// <paramref name="keySelector"/> produces a key that is a null reference (Nothing in Visual Basic). /// -or- /// <paramref name="keySelector"/> produces duplicate keys for two elements. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IEqualityComparer<TKey>? comparer) where TKey : notnull { // comparer may be null. In that case, the Dictionary constructor will use the default comparer. Dictionary<TKey, TSource> result = new Dictionary<TKey, TSource>(comparer); QueryOperator<TSource>? op = source as QueryOperator<TSource>; IEnumerator<TSource> input = (op == null) ? source.GetEnumerator() : op.GetEnumerator(ParallelMergeOptions.FullyBuffered, true); using (input) { while (input.MoveNext()) { TKey key; TSource val = input.Current; try { key = keySelector(val); result.Add(key, val); } catch (Exception ex) { throw new AggregateException(ex); } } } return result; } /// <summary> /// Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to specified /// key selector and element selector functions. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector"/>.</typeparam> /// <param name="source">A sequence to create a Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="elementSelector"> /// A transform function to produce a result element value from each element. /// </param> /// <returns> /// A Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) that contains values of type <typeparamref name="TElement"/> /// selected from the input sequence /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// <paramref name="keySelector"/> produces a key that is a null reference (Nothing in Visual Basic). /// -or- /// <paramref name="keySelector"/> produces duplicate keys for two elements. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) where TKey : notnull { return ToDictionary(source, keySelector, elementSelector, EqualityComparer<TKey>.Default); } /// <summary> /// Creates a Dictionary{TKey,TValue from a ParallelQuery{T} according to a /// specified key selector function, a comparer, and an element selector function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector"/>.</typeparam> /// <param name="source">A sequence to create a Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="elementSelector">A transform function to produce a result element /// value from each element.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare keys.</param> /// <returns> /// A Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) that contains values of type <typeparamref name="TElement"/> /// selected from the input sequence /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// <paramref name="keySelector"/> produces a key that is a null reference (Nothing in Visual Basic). /// -or- /// <paramref name="keySelector"/> produces duplicate keys for two elements. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, Func<TSource, TElement> elementSelector!!, IEqualityComparer<TKey>? comparer) where TKey : notnull { // comparer may be null. In that case, the Dictionary constructor will use the default comparer. Dictionary<TKey, TElement> result = new Dictionary<TKey, TElement>(comparer); QueryOperator<TSource>? op = source as QueryOperator<TSource>; IEnumerator<TSource> input = (op == null) ? source.GetEnumerator() : op.GetEnumerator(ParallelMergeOptions.FullyBuffered, true); using (input) { while (input.MoveNext()) { TSource src = input.Current; try { result.Add(keySelector(src), elementSelector(src)); } catch (Exception ex) { throw new AggregateException(ex); } } } return result; } //----------------------------------------------------------------------------------- // ToLookup constructs a lookup from an instance of ParallelQuery. // Each element in the enumerable is converted to a (key,value) pair using a pair // of lambda expressions specified by the caller. Multiple elements are allowed // to produce the same key. // /// <summary> /// Creates an ILookup{TKey,T} from a ParallelQuery{T} according to a specified key selector function. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">The sequence to create a Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <returns>A Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) that contains keys and values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static ILookup<TKey, TSource> ToLookup<TSource, TKey>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector) where TKey: notnull { return ToLookup(source, keySelector, EqualityComparer<TKey>.Default); } /// <summary> /// Creates an ILookup{TKey,T} from a ParallelQuery{T} according to a specified /// key selector function and key comparer. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">The sequence to create a Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare keys.</param> /// <returns>A Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) that contains keys and values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static ILookup<TKey, TSource> ToLookup<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IEqualityComparer<TKey>? comparer) where TKey: notnull { // comparer may be null, in which case we use the default comparer. comparer = comparer ?? EqualityComparer<TKey>.Default; ParallelQuery<IGrouping<TKey, TSource>> groupings = source.GroupBy(keySelector, comparer); Parallel.Lookup<TKey, TSource> lookup = new Parallel.Lookup<TKey, TSource>(comparer); Debug.Assert(groupings is QueryOperator<IGrouping<TKey, TSource>>); QueryOperator<IGrouping<TKey, TSource>>? op = groupings as QueryOperator<IGrouping<TKey, TSource>>; IEnumerator<IGrouping<TKey, TSource>> input = (op == null) ? groupings.GetEnumerator() : op.GetEnumerator(ParallelMergeOptions.FullyBuffered); using (input) { while (input.MoveNext()) { lookup.Add(input.Current); } } return lookup; } /// <summary> /// Creates an ILookup{TKey,TElement} from a ParallelQuery{T} according to specified /// key selector and element selector functions. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector"/>.</typeparam> /// <param name="source">The sequence to create a Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="elementSelector"> /// A transform function to produce a result element value from each element. /// </param> /// <returns> /// A Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) that contains values of type TElement /// selected from the input sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) where TKey : notnull { return ToLookup(source, keySelector, elementSelector, EqualityComparer<TKey>.Default); } /// <summary> /// Creates an ILookup{TKey,TElement} from a ParallelQuery{T} according to /// a specified key selector function, a comparer and an element selector function. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector"/>.</typeparam> /// <param name="source">The sequence to create a Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="elementSelector"> /// A transform function to produce a result element value from each element. /// </param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare keys.</param> /// <returns> /// A Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) that contains values of type TElement selected /// from the input sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, Func<TSource, TElement> elementSelector!!, IEqualityComparer<TKey>? comparer) where TKey : notnull { // comparer may be null, in which case we use the default comparer. comparer = comparer ?? EqualityComparer<TKey>.Default; ParallelQuery<IGrouping<TKey, TElement>> groupings = source.GroupBy(keySelector, elementSelector, comparer); Parallel.Lookup<TKey, TElement> lookup = new Parallel.Lookup<TKey, TElement>(comparer); Debug.Assert(groupings is QueryOperator<IGrouping<TKey, TElement>>); QueryOperator<IGrouping<TKey, TElement>>? op = groupings as QueryOperator<IGrouping<TKey, TElement>>; IEnumerator<IGrouping<TKey, TElement>> input = (op == null) ? groupings.GetEnumerator() : op.GetEnumerator(ParallelMergeOptions.FullyBuffered); using (input) { while (input.MoveNext()) { lookup.Add(input.Current); } } return lookup; } /*=================================================================================== * MISCELLANEOUS OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Reverses the input. // /// <summary> /// Inverts the order of the elements in a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to reverse.</param> /// <returns>A sequence whose elements correspond to those of the input sequence in reverse order.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Reverse<TSource>(this ParallelQuery<TSource> source!!) { return new ReverseQueryOperator<TSource>(source); } //----------------------------------------------------------------------------------- // Both OfType and Cast convert a weakly typed stream to a strongly typed one: // the difference is that OfType filters out elements that aren't of the given type, // while Cast forces the cast, possibly resulting in InvalidCastExceptions. // /// <summary> /// Filters the elements of a ParallelQuery based on a specified type. /// </summary> /// <typeparam name="TResult">The type to filter the elements of the sequence on.</typeparam> /// <param name="source">The sequence whose elements to filter.</param> /// <returns>A sequence that contains elements from the input sequence of type <typeparamref name="TResult"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> OfType<TResult>(this ParallelQuery source!!) { return source.OfType<TResult>(); } /// <summary> /// Converts the elements of a weakly-typed ParallelQuery to the specified stronger type. /// </summary> /// <typeparam name="TResult">The stronger type to convert the elements of <paramref name="source"/> to.</typeparam> /// <param name="source">The sequence that contains the weakly typed elements to be converted.</param> /// <returns> /// A sequence that contains each weakly-type element of the source sequence converted to the specified stronger type. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Cast<TResult>(this ParallelQuery source!!) { return source.Cast<TResult>(); } //----------------------------------------------------------------------------------- // Helper method used by First, FirstOrDefault, Last, LastOrDefault, Single, and // SingleOrDefault below. This takes a query operator, gets the first item (and // either checks or asserts there is at most one item in the source), and returns it. // If there are no elements, the method either throws an exception or, if // defaultIfEmpty is true, returns a default value. // // Arguments: // queryOp - the query operator to enumerate (for the single element) // throwIfTwo - whether to throw an exception (true) or assert (false) that // there is no more than one element in the source // defaultIfEmpty - whether to return a default value (true) or throw an // exception if the output of the query operator is empty // private static TSource? GetOneWithPossibleDefault<TSource>( QueryOperator<TSource> queryOp, bool throwIfTwo, bool defaultIfEmpty) { Debug.Assert(queryOp != null, "expected query operator"); using (IEnumerator<TSource> e = queryOp.GetEnumerator(ParallelMergeOptions.FullyBuffered)) { if (e.MoveNext()) { TSource current = e.Current; // Some operators need to do a runtime, retail check for more than one element. // Others can simply assert that there was only one. if (throwIfTwo) { if (e.MoveNext()) { throw new InvalidOperationException(SR.MoreThanOneMatch); } } else { Debug.Assert(!e.MoveNext(), "expected only a single element"); } return current; } } if (defaultIfEmpty) { return default; } else { throw new InvalidOperationException(SR.NoElements); } } //----------------------------------------------------------------------------------- // First simply returns the first element from the data source; if the predicate // overload is used, the first element satisfying the predicate is returned. // An exception is thrown for empty data sources. Alternatively, the FirstOrDefault // method can be used which returns default(T) if empty (or no elements satisfy the // predicate). // /// <summary> /// Returns the first element of a parallel sequence.</summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the first element of.</param> /// <returns>The first element in the specified sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource First<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for seekable data sources. E.g. if an array, we can // seek directly to the 0th element. FirstQueryOperator<TSource> queryOp = new FirstQueryOperator<TSource>(source, null); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState) .First(); } return GetOneWithPossibleDefault(queryOp, false, false)!; } /// <summary> /// Returns the first element in a parallel sequence that satisfies a specified condition. /// </summary> /// <remarks>There's a temporary difference from LINQ to Objects, this does not throw /// ArgumentNullException when the predicate is null.</remarks> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns>The first element in the sequence that passes the test in the specified predicate function.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// No element in <paramref name="source"/> satisfies the condition in <paramref name="predicate"/>. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource First<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { FirstQueryOperator<TSource> queryOp = new FirstQueryOperator<TSource>(source, predicate); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState) .First(ExceptionAggregator.WrapFunc<TSource, bool>(predicate, settings.CancellationState)); } return GetOneWithPossibleDefault(queryOp, false, false)!; } /// <summary> /// Returns the first element of a parallel sequence, or a default value if the /// sequence contains no elements. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the first element of.</param> /// <returns> /// default(<B>TSource</B>) if <paramref name="source"/> is empty; otherwise, the first element in <paramref name="source"/>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? FirstOrDefault<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for seekable data sources. E.g. if an array, we can // seek directly to the 0th element. FirstQueryOperator<TSource> queryOp = new FirstQueryOperator<TSource>(source, null); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState).FirstOrDefault(); } return GetOneWithPossibleDefault(queryOp, false, true); } /// <summary> /// Returns the first element of the parallel sequence that satisfies a condition or a /// default value if no such element is found. /// </summary> /// <remarks>There's a temporary difference from LINQ to Objects, this does not throw /// ArgumentNullException when the predicate is null.</remarks> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// default(<B>TSource</B>) if <paramref name="source"/> is empty or if no element passes the test /// specified by <B>predicate</B>; otherwise, the first element in <paramref name="source"/> that /// passes the test specified by <B>predicate</B>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? FirstOrDefault<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { FirstQueryOperator<TSource> queryOp = new FirstQueryOperator<TSource>(source, predicate); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable( childWithCancelChecks, settings.CancellationState) .FirstOrDefault(ExceptionAggregator.WrapFunc<TSource, bool>(predicate, settings.CancellationState)); } return GetOneWithPossibleDefault(queryOp, false, true); } //----------------------------------------------------------------------------------- // Last simply returns the last element from the data source; if the predicate // overload is used, the last element satisfying the predicate is returned. // An exception is thrown for empty data sources. Alternatively, the LastOrDefault // method can be used which returns default(T) if empty (or no elements satisfy the // predicate). // /// <summary> /// Returns the last element of a parallel sequence.</summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the last element from.</param> /// <returns>The value at the last position in the source sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Last<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for seekable data sources. E.g. if an array, we can // seek directly to the last element. LastQueryOperator<TSource> queryOp = new LastQueryOperator<TSource>(source, null); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState).Last(); } return GetOneWithPossibleDefault(queryOp, false, false)!; } /// <summary> /// Returns the last element of a parallel sequence that satisfies a specified condition. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// The last element in the sequence that passes the test in the specified predicate function. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// No element in <paramref name="source"/> satisfies the condition in <paramref name="predicate"/>. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Last<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { LastQueryOperator<TSource> queryOp = new LastQueryOperator<TSource>(source, predicate); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable( childWithCancelChecks, settings.CancellationState) .Last(ExceptionAggregator.WrapFunc<TSource, bool>(predicate, settings.CancellationState)); } return GetOneWithPossibleDefault(queryOp, false, false)!; } /// <summary> /// Returns the last element of a parallel sequence, or a default value if the /// sequence contains no elements. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <returns> /// default(<typeparamref name="TSource"/>) if the source sequence is empty; otherwise, the last element in the sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? LastOrDefault<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for seekable data sources. E.g. if an array, we can // seek directly to the last element. LastQueryOperator<TSource> queryOp = new LastQueryOperator<TSource>(source, null); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState).LastOrDefault(); } return GetOneWithPossibleDefault(queryOp, false, true); } /// <summary> /// Returns the last element of a parallel sequence that satisfies a condition, or /// a default value if no such element is found. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// default(<typeparamref name="TSource"/>) if the sequence is empty or if no elements pass the test in the /// predicate function; otherwise, the last element that passes the test in the predicate function. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? LastOrDefault<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { LastQueryOperator<TSource> queryOp = new LastQueryOperator<TSource>(source, predicate); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable( childWithCancelChecks, settings.CancellationState) .LastOrDefault(ExceptionAggregator.WrapFunc<TSource, bool>(predicate, settings.CancellationState)); } return GetOneWithPossibleDefault(queryOp, false, true); } //----------------------------------------------------------------------------------- // Single yields the single element matching the optional predicate, or throws an // exception if there is zero or more than one match. SingleOrDefault is similar // except that it returns the default value in this condition. // /// <summary> /// Returns the only element of a parallel sequence, and throws an exception if there is not /// exactly one element in the sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the single element of.</param> /// <returns>The single element of the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// The input sequence contains more than one element. -or- The input sequence is empty. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Single<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for ICollection-typed data sources, i.e. we can just // check the Count property and avoid costly fork/join/synchronization. return GetOneWithPossibleDefault(new SingleQueryOperator<TSource>(source, null), true, false)!; } /// <summary> /// Returns the only element of a parallel sequence that satisfies a specified condition, /// and throws an exception if more than one such element exists. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the single element of.</param> /// <param name="predicate">A function to test an element for a condition.</param> /// <returns>The single element of the input sequence that satisfies a condition.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// No element satisfies the condition in <paramref name="predicate"/>. -or- More than one element satisfies the condition in <paramref name="predicate"/>. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Single<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return GetOneWithPossibleDefault(new SingleQueryOperator<TSource>(source, predicate), true, false)!; } /// <summary> /// Returns the only element of a parallel sequence, or a default value if the sequence is /// empty; this method throws an exception if there is more than one element in the sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the single element of.</param> /// <returns> /// The single element of the input sequence, or default(<typeparamref name="TSource"/>) if the /// sequence contains no elements. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? SingleOrDefault<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for ICollection-typed data sources, i.e. we can just // check the Count property and avoid costly fork/join/synchronization. return GetOneWithPossibleDefault(new SingleQueryOperator<TSource>(source, null), true, true); } /// <summary> /// Returns the only element of a parallel sequence that satisfies a specified condition /// or a default value if no such element exists; this method throws an exception /// if more than one element satisfies the condition. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the single element of.</param> /// <param name="predicate">A function to test an element for a condition.</param> /// <returns> /// The single element of the input sequence that satisfies the condition, or /// default(<typeparamref name="TSource"/>) if no such element is found. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? SingleOrDefault<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return GetOneWithPossibleDefault(new SingleQueryOperator<TSource>(source, predicate), true, true); } //----------------------------------------------------------------------------------- // DefaultIfEmpty yields the data source, unmodified, if it is non-empty. Otherwise, // it yields a single occurrence of the default value. // /// <summary> /// Returns the elements of the specified parallel sequence or the type parameter's /// default value in a singleton collection if the sequence is empty. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return a default value for if it is empty.</param> /// <returns> /// A sequence that contains default(<B>TSource</B>) if <paramref name="source"/> is empty; otherwise, <paramref name="source"/>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource?> DefaultIfEmpty<TSource>(this ParallelQuery<TSource> source) { return DefaultIfEmpty<TSource>(source, default!)!; } /// <summary> /// Returns the elements of the specified parallel sequence or the specified value /// in a singleton collection if the sequence is empty. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the specified value for if it is empty.</param> /// <param name="defaultValue">The value to return if the sequence is empty.</param> /// <returns> /// A sequence that contains <B>defaultValue</B> if <paramref name="source"/> is empty; otherwise, <paramref name="source"/>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> DefaultIfEmpty<TSource>(this ParallelQuery<TSource> source!!, TSource defaultValue) { return new DefaultIfEmptyQueryOperator<TSource>(source, defaultValue); } //----------------------------------------------------------------------------------- // ElementAt yields an element at a specific index. If the data source doesn't // contain such an element, an exception is thrown. Alternatively, ElementAtOrDefault // will return a default value if the given index is invalid. // /// <summary> /// Returns the element at a specified index in a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to return an element from.</param> /// <param name="index">The zero-based index of the element to retrieve.</param> /// <returns>The element at the specified position in the source sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="index"/> is less than 0 or greater than or equal to the number of elements in <paramref name="source"/>. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource ElementAt<TSource>(this ParallelQuery<TSource> source!!, int index) { if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); // @PERF: there are obvious optimization opportunities for indexable data sources, // since we can just seek to the element requested. ElementAtQueryOperator<TSource> op = new ElementAtQueryOperator<TSource>(source, index); TSource result; if (op.Aggregate(out result!, false)) { return result; } throw new ArgumentOutOfRangeException(nameof(index)); } /// <summary> /// Returns the element at a specified index in a parallel sequence or a default value if the /// index is out of range. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to return an element from.</param> /// <param name="index">The zero-based index of the element to retrieve.</param> /// <returns> /// default(<B>TSource</B>) if the index is outside the bounds of the source sequence; /// otherwise, the element at the specified position in the source sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? ElementAtOrDefault<TSource>(this ParallelQuery<TSource> source!!, int index) { // @PERF: there are obvious optimization opportunities for indexable data sources, // since we can just seek to the element requested. if (index >= 0) { ElementAtQueryOperator<TSource> op = new ElementAtQueryOperator<TSource>(source, index); TSource result; if (op.Aggregate(out result!, true)) { return result; } } return default; } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // ParallelEnumerable.cs // // The standard IEnumerable-based LINQ-to-Objects query provider. This class basically // mirrors the System.Linq.Enumerable class, but (1) takes as input a special "parallel // enumerable" data type and (2) uses an alternative implementation of the operators. // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System; using System.Collections.Generic; using System.Threading; using System.Diagnostics; using System.Linq.Parallel; using System.Collections.Concurrent; using System.Collections; using System.Threading.Tasks; using System.Diagnostics.CodeAnalysis; namespace System.Linq { //----------------------------------------------------------------------------------- // Languages like C# and VB that support query comprehensions translate queries // into calls to a query provider which creates executable representations of the // query. The LINQ-to-Objects provider is implemented as a static class with an // extension method per-query operator; when invoked, these return enumerable // objects that implement the querying behavior. // // We have a new sequence class for two reasons: // // (1) Developers can opt in to parallel query execution piecemeal, by using // a special AsParallel API to wrap the data source. // (2) Parallel LINQ uses a new representation for queries when compared to LINQ, // which we must return from the new sequence operator implementations. // // Comments and documentation will be somewhat light in this file. Please refer // to the "official" Standard Query Operators specification for details on each API: // http://download.microsoft.com/download/5/8/6/5868081c-68aa-40de-9a45-a3803d8134b8/Standard_Query_Operators.doc // // Notes: // The Standard Query Operators herein should be semantically equivalent to // the specification linked to above. In some cases, we offer operators that // aren't available in the sequential LINQ library; in each case, we will note // why this is needed. // /// <summary> /// Provides a set of methods for querying objects that implement /// ParallelQuery{TSource}. This is the parallel equivalent of /// <see cref="System.Linq.Enumerable"/>. /// </summary> public static class ParallelEnumerable { // We pass this string constant to an attribute constructor. Unfortunately, we cannot access resources from // an attribute constructor, so we have to store this string in source code. private const string RIGHT_SOURCE_NOT_PARALLEL_STR = "The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than " + "System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method " + "to convert the right data source to System.Linq.ParallelQuery<T>."; // When running in single partition mode, PLINQ operations will occur on a single partition and will not // be executed in parallel, but will retain PLINQ semantics (exceptions wrapped as aggregates, etc). [System.Runtime.Versioning.SupportedOSPlatformGuard("browser")] internal static bool SinglePartitionMode => OperatingSystem.IsBrowser(); //----------------------------------------------------------------------------------- // Converts any IEnumerable<TSource> into something that can be the target of parallel // query execution. // // Arguments: // source - the enumerable data source // options - query analysis options to override the defaults // degreeOfParallelism - the DOP to use instead of the system default, if any // // Notes: // If the argument is already a parallel enumerable, such as a query operator, // no new objects are allocated. Otherwise, a very simple wrapper is instantiated // that exposes the IEnumerable as a ParallelQuery. // /// <summary> /// Enables parallelization of a query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">An <see cref="System.Collections.Generic.IEnumerable{T}"/> /// to convert to a <see cref="System.Linq.ParallelQuery{T}"/>.</param> /// <returns>The source as a <see cref="System.Linq.ParallelQuery{T}"/> to bind to /// ParallelEnumerable extension methods.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> AsParallel<TSource>(this IEnumerable<TSource> source!!) { return new ParallelEnumerableWrapper<TSource>(source); } /// <summary> /// Enables parallelization of a query, as sourced by a partitioner /// responsible for splitting the input sequence into partitions. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A partitioner over the input sequence.</param> /// <returns>The <paramref name="source"/> as a ParallelQuery to bind to ParallelEnumerable extension methods.</returns> /// <remarks> /// The source partitioner's GetOrderedPartitions method is used when ordering is enabled, /// whereas the partitioner's GetPartitions is used if ordering is not enabled (the default). /// The source partitioner's GetDynamicPartitions and GetDynamicOrderedPartitions are not used. /// </remarks> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> AsParallel<TSource>(this Partitioner<TSource> source!!) { return new PartitionerQueryOperator<TSource>(source); } /// <summary> /// Enables treatment of a data source as if it was ordered, overriding the default of unordered. /// AsOrdered may only be invoked on sequences returned by AsParallel, ParallelEnumerable.Range, /// and ParallelEnumerable.Repeat. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The input sequence.</param> /// <exception cref="System.InvalidOperationException"> /// Thrown if <paramref name="source"/> is not one of AsParallel, ParallelEnumerable.Range, or ParallelEnumerable.Repeat. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <remarks> /// A natural tension exists between performance and preserving order in parallel processing. By default, /// a parallelized query behaves as if the ordering of the results is arbitrary /// unless AsOrdered is applied or there is an explicit OrderBy operator in the query. /// </remarks> /// <returns>The source sequence which will maintain ordering in the query.</returns> public static ParallelQuery<TSource> AsOrdered<TSource>(this ParallelQuery<TSource> source!!) { if (!(source is ParallelEnumerableWrapper<TSource> || source is IParallelPartitionable<TSource>)) { if (source is PartitionerQueryOperator<TSource> partitionerOp) { if (!partitionerOp.Orderable) { throw new InvalidOperationException(SR.ParallelQuery_PartitionerNotOrderable); } } else { throw new InvalidOperationException(SR.ParallelQuery_InvalidAsOrderedCall); } } return new OrderingQueryOperator<TSource>(QueryOperator<TSource>.AsQueryOperator(source), true); } /// <summary> /// Enables treatment of a data source as if it was ordered, overriding the default of unordered. /// AsOrdered may only be invoked on sequences returned by AsParallel, ParallelEnumerable.Range, /// and ParallelEnumerable.Repeat. /// </summary> /// <param name="source">The input sequence.</param> /// <exception cref="InvalidOperationException"> /// Thrown if the <paramref name="source"/> is not one of AsParallel, ParallelEnumerable.Range, or ParallelEnumerable.Repeat. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <remarks> /// A natural tension exists between performance and preserving order in parallel processing. By default, /// a parallelized query behaves as if the ordering of the results is arbitrary unless AsOrdered /// is applied or there is an explicit OrderBy operator in the query. /// </remarks> /// <returns>The source sequence which will maintain ordering in the query.</returns> public static ParallelQuery AsOrdered(this ParallelQuery source!!) { ParallelEnumerableWrapper? wrapper = source as ParallelEnumerableWrapper; if (wrapper == null) { throw new InvalidOperationException(SR.ParallelQuery_InvalidNonGenericAsOrderedCall); } return new OrderingQueryOperator<object?>(QueryOperator<object?>.AsQueryOperator(wrapper), true); } /// <summary> /// Allows an intermediate query to be treated as if no ordering is implied among the elements. /// </summary> /// <remarks> /// AsUnordered may provide /// performance benefits when ordering is not required in a portion of a query. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The input sequence.</param> /// <returns>The source sequence with arbitrary order.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> AsUnordered<TSource>(this ParallelQuery<TSource> source!!) { return new OrderingQueryOperator<TSource>(QueryOperator<TSource>.AsQueryOperator(source), false); } /// <summary> /// Enables parallelization of a query. /// </summary> /// <param name="source">An <see cref="System.Collections.Generic.IEnumerable{T}"/> to convert /// to a <see cref="System.Linq.ParallelQuery{T}"/>.</param> /// <returns> /// The source as a ParallelQuery to bind to /// ParallelEnumerable extension methods. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery AsParallel(this IEnumerable source!!) { return new ParallelEnumerableWrapper(source); } //----------------------------------------------------------------------------------- // Converts a parallel enumerable into something that forces sequential execution. // // Arguments: // source - the parallel enumerable data source // /// <summary> /// Converts a <see cref="ParallelQuery{T}"/> into an /// <see cref="System.Collections.Generic.IEnumerable{T}"/> to force sequential /// evaluation of the query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A <see cref="ParallelQuery{T}"/> to convert to an <see cref="System.Collections.Generic.IEnumerable{T}"/>.</param> /// <returns>The source as an <see cref="System.Collections.Generic.IEnumerable{T}"/> /// to bind to sequential extension methods.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static IEnumerable<TSource> AsSequential<TSource>(this ParallelQuery<TSource> source!!) { // Ditch the wrapper, if there is one. if (source is ParallelEnumerableWrapper<TSource> wrapper) { return wrapper.WrappedEnumerable; } else { return source; } } /// <summary> /// Sets the degree of parallelism to use in a query. Degree of parallelism is the maximum number of concurrently /// executing tasks that will be used to process the query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A ParallelQuery on which to set the limit on the degrees of parallelism.</param> /// <param name="degreeOfParallelism">The degree of parallelism for the query.</param> /// <returns>ParallelQuery representing the same query as source, with the limit on the degrees of parallelism set.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// WithDegreeOfParallelism is used multiple times in the query. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="degreeOfParallelism"/> is less than 1 or greater than 512. /// </exception> public static ParallelQuery<TSource> WithDegreeOfParallelism<TSource>(this ParallelQuery<TSource> source!!, int degreeOfParallelism) { if (degreeOfParallelism < 1 || degreeOfParallelism > Scheduling.MAX_SUPPORTED_DOP) { throw new ArgumentOutOfRangeException(nameof(degreeOfParallelism)); } QuerySettings settings = QuerySettings.Empty; settings.DegreeOfParallelism = degreeOfParallelism; return new QueryExecutionOption<TSource>( QueryOperator<TSource>.AsQueryOperator(source), settings); } /// <summary> /// Sets the <see cref="System.Threading.CancellationToken"/> to associate with the query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A ParallelQuery on which to set the option.</param> /// <param name="cancellationToken">A cancellation token.</param> /// <returns>ParallelQuery representing the same query as source, but with the <seealso cref="System.Threading.CancellationToken"/> /// registered.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// WithCancellation is used multiple times in the query. /// </exception> public static ParallelQuery<TSource> WithCancellation<TSource>(this ParallelQuery<TSource> source!!, CancellationToken cancellationToken) { QuerySettings settings = QuerySettings.Empty; settings.CancellationState = new CancellationState(cancellationToken); return new QueryExecutionOption<TSource>( QueryOperator<TSource>.AsQueryOperator(source), settings); } /// <summary> /// Sets the execution mode of the query. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A ParallelQuery on which to set the option.</param> /// <param name="executionMode">The mode in which to execute the query.</param> /// <returns>ParallelQuery representing the same query as source, but with the /// <seealso cref="System.Linq.ParallelExecutionMode"/> registered.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="executionMode"/> is not a valid <see cref="System.Linq.ParallelExecutionMode"/> value. /// </exception> /// <exception cref="System.InvalidOperationException"> /// WithExecutionMode is used multiple times in the query. /// </exception> public static ParallelQuery<TSource> WithExecutionMode<TSource>(this ParallelQuery<TSource> source!!, ParallelExecutionMode executionMode) { if (executionMode != ParallelExecutionMode.Default && executionMode != ParallelExecutionMode.ForceParallelism) { throw new ArgumentException(SR.ParallelEnumerable_WithQueryExecutionMode_InvalidMode); } QuerySettings settings = QuerySettings.Empty; settings.ExecutionMode = executionMode; return new QueryExecutionOption<TSource>( QueryOperator<TSource>.AsQueryOperator(source), settings); } /// <summary> /// Sets the merge options for this query, which specify how the query will buffer output. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A ParallelQuery on which to set the option.</param> /// <param name="mergeOptions">The merge options to set for this query.</param> /// <returns>ParallelQuery representing the same query as source, but with the /// <seealso cref="ParallelMergeOptions"/> registered.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="mergeOptions"/> is not a valid <see cref="System.Linq.ParallelMergeOptions"/> value. /// </exception> /// <exception cref="System.InvalidOperationException"> /// WithMergeOptions is used multiple times in the query. /// </exception> public static ParallelQuery<TSource> WithMergeOptions<TSource>(this ParallelQuery<TSource> source!!, ParallelMergeOptions mergeOptions) { if (mergeOptions != ParallelMergeOptions.Default && mergeOptions != ParallelMergeOptions.AutoBuffered && mergeOptions != ParallelMergeOptions.NotBuffered && mergeOptions != ParallelMergeOptions.FullyBuffered) { throw new ArgumentException(SR.ParallelEnumerable_WithMergeOptions_InvalidOptions); } QuerySettings settings = QuerySettings.Empty; settings.MergeOptions = mergeOptions; return new QueryExecutionOption<TSource>( QueryOperator<TSource>.AsQueryOperator(source), settings); } //----------------------------------------------------------------------------------- // Range generates a sequence of numbers that can be used as input to a query. // /// <summary> /// Generates a parallel sequence of integral numbers within a specified range. /// </summary> /// <param name="start">The value of the first integer in the sequence.</param> /// <param name="count">The number of sequential integers to generate.</param> /// <returns>An <b>IEnumerable&lt;Int32&gt;</b> in C# or <B>IEnumerable(Of Int32)</B> in /// Visual Basic that contains a range of sequential integral numbers.</returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="count"/> is less than 0 /// -or- /// <paramref name="start"/> + <paramref name="count"/> - 1 is larger than <see cref="int.MaxValue"/>. /// </exception> public static ParallelQuery<int> Range(int start, int count) { if (count < 0 || (count > 0 && int.MaxValue - (count - 1) < start)) throw new ArgumentOutOfRangeException(nameof(count)); return new RangeEnumerable(start, count); } //----------------------------------------------------------------------------------- // Repeat just generates a sequence of size 'count' containing 'element'. // /// <summary> /// Generates a parallel sequence that contains one repeated value. /// </summary> /// <typeparam name="TResult">The type of the value to be repeated in the result sequence.</typeparam> /// <param name="element">The value to be repeated.</param> /// <param name="count">The number of times to repeat the value in the generated sequence.</param> /// <returns>A sequence that contains a repeated value.</returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="count"/> is less than 0. /// </exception> public static ParallelQuery<TResult> Repeat<TResult>(TResult element, int count) { if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); return new RepeatEnumerable<TResult>(element, count); } //----------------------------------------------------------------------------------- // Returns an always-empty sequence. // /// <summary> /// Returns an empty ParallelQuery{TResult} that has the specified type argument. /// </summary> /// <typeparam name="TResult">The type to assign to the type parameter of the returned /// generic sequence.</typeparam> /// <returns>An empty sequence whose type argument is <typeparamref name="TResult"/>.</returns> public static ParallelQuery<TResult> Empty<TResult>() { return System.Linq.Parallel.EmptyEnumerable<TResult>.Instance; } //----------------------------------------------------------------------------------- // A new query operator that allows an arbitrary user-specified "action" to be // tacked on to the query tree. The action will be invoked for every element in the // underlying data source, avoiding a costly final merge in the query's execution, // which can lead to much better scalability. The caveat is that these occur in // parallel, so the user providing an action must take care to eliminate shared state // accesses or to synchronize as appropriate. // // Arguments: // source - the data source over which the actions will be invoked // action - a delegate representing the per-element action to be invoked // // Notes: // Neither source nor action may be null, otherwise this method throws. // /// <summary> /// Invokes in parallel the specified action for each element in the <paramref name="source"/>. /// </summary> /// <remarks> /// This is an efficient way to process the output from a parallelized query because it does /// not require a merge step at the end. However, order of execution is non-deterministic. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The <see cref="ParallelQuery{T}"/> whose elements will be processed by /// <paramref name="action"/>.</param> /// <param name="action">An Action to invoke on each element.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="action"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static void ForAll<TSource>(this ParallelQuery<TSource> source!!, Action<TSource> action!!) { // We just instantiate the forall operator and invoke it synchronously on this thread. // By the time it returns, the entire query has been executed and the actions run.. new ForAllOperator<TSource>(source, action).RunSynchronously(); } /*=================================================================================== * BASIC OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Where is an operator that filters any elements from the data source for which the // user-supplied predicate returns false. // /// <summary> /// Filters in parallel a sequence of values based on a predicate. /// </summary> /// <typeparam name="TSource">The type of the elements of source.</typeparam> /// <param name="source">A sequence to filter.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns>A sequence that contains elements from the input sequence that satisfy /// the condition.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Where<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new WhereQueryOperator<TSource>(source, predicate); } /// <summary> /// Filters in parallel a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function. /// </summary> /// <typeparam name="TSource">The type of the elements of source.</typeparam> /// <param name="source">A sequence to filter.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns>A sequence that contains elements from the input sequence that satisfy the condition.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Where<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, int, bool> predicate!!) { return new IndexedWhereQueryOperator<TSource>(source, predicate); } //----------------------------------------------------------------------------------- // Select merely maps a selector delegate over each element in the data source. // /// <summary> /// Projects in parallel each element of a sequence into a new form. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of elements returned by <b>selector</b>.</typeparam> /// <param name="source">A sequence of values to invoke a transform function on.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>A sequence whose elements are the result of invoking the transform function on each /// element of <paramref name="source"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Select<TSource, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, TResult> selector!!) { return new SelectQueryOperator<TSource, TResult>(source, selector); } /// <summary> /// Projects in parallel each element of a sequence into a new form by incorporating the element's index. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of elements returned by <b>selector</b>.</typeparam> /// <param name="source">A sequence of values to invoke a transform function on.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>A sequence whose elements are the result of invoking the transform function on each /// element of <paramref name="source"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Select<TSource, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, int, TResult> selector!!) { return new IndexedSelectQueryOperator<TSource, TResult>(source, selector); } //----------------------------------------------------------------------------------- // Zip combines an outer and inner data source into a single output data stream. // /// <summary> /// Merges in parallel two sequences by using the specified predicate function. /// </summary> /// <typeparam name="TFirst">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TSecond">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TResult">The type of the return elements.</typeparam> /// <param name="first">The first sequence to zip.</param> /// <param name="second">The second sequence to zip.</param> /// <param name="resultSelector">A function to create a result element from two matching elements.</param> /// <returns> /// A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// resultSelector pairwise on two sequences. If the sequence lengths are unequal, this truncates /// to the length of the shorter sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Zip<TFirst, TSecond, TResult>( this ParallelQuery<TFirst> first!!, ParallelQuery<TSecond> second!!, Func<TFirst, TSecond, TResult> resultSelector!!) { return new ZipQueryOperator<TFirst, TSecond, TResult>(first, second, resultSelector); } /// <summary> /// This Zip overload should never be called. /// This method is marked as obsolete and always throws /// <see cref="System.NotSupportedException"/> when invoked. /// </summary> /// <typeparam name="TFirst">This type parameter is not used.</typeparam> /// <typeparam name="TSecond">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Zip with a left data source of type /// <see cref="System.Linq.ParallelQuery{TFirst}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSecond}"/>. /// Otherwise, the Zip operator would appear to be bind to the parallel implementation, but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> Zip<TFirst, TSecond, TResult>( this ParallelQuery<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Join is an inner join operator, i.e. elements from outer with no inner matches // will yield no results in the output data stream. // /// <summary> /// Correlates in parallel the elements of two sequences based on matching keys. /// The default equality comparer is used to compare keys. /// </summary> /// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam> /// <typeparam name="TResult">The type of the result elements.</typeparam> /// <param name="outer">The first sequence to join.</param> /// <param name="inner">The sequence to join to the first sequence.</param> /// <param name="outerKeySelector">A function to extract the join key from each element of /// the first sequence.</param> /// <param name="innerKeySelector">A function to extract the join key from each element of /// the second sequence.</param> /// <param name="resultSelector">A function to create a result element from two matching elements.</param> /// <returns>A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// an inner join on two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="outer"/> or <paramref name="inner"/> or <paramref name="outerKeySelector"/> or /// <paramref name="innerKeySelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector) { return Join<TOuter, TInner, TKey, TResult>( outer, inner, outerKeySelector, innerKeySelector, resultSelector, null); } /// <summary> /// This Join overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when invoked. /// </summary> /// <typeparam name="TOuter">This type parameter is not used.</typeparam> /// <typeparam name="TInner">This type parameter is not used.</typeparam> /// <typeparam name="TKey">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="outer">This parameter is not used.</param> /// <param name="inner">This parameter is not used.</param> /// <param name="outerKeySelector">This parameter is not used.</param> /// <param name="innerKeySelector">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage Join with a left data source of type /// <see cref="System.Linq.ParallelQuery{TOuter}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TInner}"/>. /// Otherwise, the Join operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Correlates in parallel the elements of two sequences based on matching keys. /// A specified IEqualityComparer{T} is used to compare keys. /// </summary> /// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam> /// <typeparam name="TResult">The type of the result elements.</typeparam> /// <param name="outer">The first sequence to join.</param> /// <param name="inner">The sequence to join to the first sequence.</param> /// <param name="outerKeySelector">A function to extract the join key from each element /// of the first sequence.</param> /// <param name="innerKeySelector">A function to extract the join key from each element /// of the second sequence.</param> /// <param name="resultSelector">A function to create a result element from two matching elements.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to hash and compare keys.</param> /// <returns>A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// an inner join on two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="outer"/> or <paramref name="inner"/> or <paramref name="outerKeySelector"/> or /// <paramref name="innerKeySelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer!!, ParallelQuery<TInner> inner!!, Func<TOuter, TKey> outerKeySelector!!, Func<TInner, TKey> innerKeySelector!!, Func<TOuter, TInner, TResult> resultSelector!!, IEqualityComparer<TKey>? comparer) { return new JoinQueryOperator<TOuter, TInner, TKey, TResult>( outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } /// <summary> /// This Join overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when invoked. /// </summary> /// <typeparam name="TOuter">This type parameter is not used.</typeparam> /// <typeparam name="TInner">This type parameter is not used.</typeparam> /// <typeparam name="TKey">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="outer">This parameter is not used.</param> /// <param name="inner">This parameter is not used.</param> /// <param name="outerKeySelector">This parameter is not used.</param> /// <param name="innerKeySelector">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Join with a left data source of type /// <see cref="System.Linq.ParallelQuery{TOuter}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TInner}"/>. /// Otherwise, the Join operator would appear to be binding to the parallel implementation, but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // GroupJoin is an outer join operator, i.e. elements from outer with no inner matches // will yield results (empty lists) in the output data stream. // /// <summary> /// Correlates in parallel the elements of two sequences based on equality of keys and groups the results. /// The default equality comparer is used to compare keys. /// </summary> /// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam> /// <typeparam name="TResult">The type of the result elements.</typeparam> /// <param name="outer">The first sequence to join.</param> /// <param name="inner">The sequence to join to the first sequence.</param> /// <param name="outerKeySelector">A function to extract the join key from each element /// of the first sequence.</param> /// <param name="innerKeySelector">A function to extract the join key from each element /// of the second sequence.</param> /// <param name="resultSelector">A function to create a result element from an element from /// the first sequence and a collection of matching elements from the second sequence.</param> /// <returns>A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// a grouped join on two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="outer"/> or <paramref name="inner"/> or <paramref name="outerKeySelector"/> or /// <paramref name="innerKeySelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, ParallelQuery<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector) { return GroupJoin<TOuter, TInner, TKey, TResult>( outer, inner, outerKeySelector, innerKeySelector, resultSelector, null); } /// <summary> /// This GroupJoin overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TOuter">This type parameter is not used.</typeparam> /// <typeparam name="TInner">This type parameter is not used.</typeparam> /// <typeparam name="TKey">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="outer">This parameter is not used.</param> /// <param name="inner">This parameter is not used.</param> /// <param name="outerKeySelector">This parameter is not used.</param> /// <param name="innerKeySelector">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of GroupJoin with a left data source of type /// <see cref="System.Linq.ParallelQuery{TOuter}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TInner}"/>. /// Otherwise, the GroupJoin operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. ///</remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Correlates in parallel the elements of two sequences based on key equality and groups the results. /// A specified IEqualityComparer{T} is used to compare keys. /// </summary> /// <typeparam name="TOuter">The type of the elements of the first sequence.</typeparam> /// <typeparam name="TInner">The type of the elements of the second sequence.</typeparam> /// <typeparam name="TKey">The type of the keys returned by the key selector functions.</typeparam> /// <typeparam name="TResult">The type of the result elements.</typeparam> /// <param name="outer">The first sequence to join.</param> /// <param name="inner">The sequence to join to the first sequence.</param> /// <param name="outerKeySelector">A function to extract the join key from each element /// of the first sequence.</param> /// <param name="innerKeySelector">A function to extract the join key from each element /// of the second sequence.</param> /// <param name="resultSelector">A function to create a result element from an element from /// the first sequence and a collection of matching elements from the second sequence.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to hash and compare keys.</param> /// <returns>A sequence that has elements of type <typeparamref name="TResult"/> that are obtained by performing /// a grouped join on two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="outer"/> or <paramref name="inner"/> or <paramref name="outerKeySelector"/> or /// <paramref name="innerKeySelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer!!, ParallelQuery<TInner> inner!!, Func<TOuter, TKey> outerKeySelector!!, Func<TInner, TKey> innerKeySelector!!, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector!!, IEqualityComparer<TKey>? comparer) { return new GroupJoinQueryOperator<TOuter, TInner, TKey, TResult>(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } /// <summary> /// This GroupJoin overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TOuter">This type parameter is not used.</typeparam> /// <typeparam name="TInner">This type parameter is not used.</typeparam> /// <typeparam name="TKey">This type parameter is not used.</typeparam> /// <typeparam name="TResult">This type parameter is not used.</typeparam> /// <param name="outer">This parameter is not used.</param> /// <param name="inner">This parameter is not used.</param> /// <param name="outerKeySelector">This parameter is not used.</param> /// <param name="innerKeySelector">This parameter is not used.</param> /// <param name="resultSelector">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of GroupJoin with a left data source of type /// <see cref="System.Linq.ParallelQuery{TOuter}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TInner}"/>. /// Otherwise, the GroupJoin operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this ParallelQuery<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // SelectMany is a kind of nested loops join. For each element in the outer data // source, we enumerate each element in the inner data source, yielding the result // with some kind of selection routine. A few different flavors are supported. // /// <summary> /// Projects in parallel each element of a sequence to an IEnumerable{T} /// and flattens the resulting sequences into one sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of the elements of the sequence returned by <B>selector</B>.</typeparam> /// <param name="source">A sequence of values to project.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>A sequence whose elements are the result of invoking the one-to-many transform /// function on each element of the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> SelectMany<TSource, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, IEnumerable<TResult>> selector!!) { return new SelectManyQueryOperator<TSource, TResult, TResult>(source, selector, null, null); } /// <summary> /// Projects in parallel each element of a sequence to an IEnumerable{T}, and flattens the resulting /// sequences into one sequence. The index of each source element is used in the projected form of /// that element. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of the elements of the sequence returned by <B>selector</B>.</typeparam> /// <param name="source">A sequence of values to project.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>A sequence whose elements are the result of invoking the one-to-many transform /// function on each element of the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> SelectMany<TSource, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, int, IEnumerable<TResult>> selector!!) { return new SelectManyQueryOperator<TSource, TResult, TResult>(source, null, selector, null); } /// <summary> /// Projects each element of a sequence to an IEnumerable{T}, /// flattens the resulting sequences into one sequence, and invokes a result selector /// function on each element therein. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TCollection">The type of the intermediate elements collected by <paramref name="collectionSelector"/>.</typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="source">A sequence of values to project.</param> /// <param name="collectionSelector">A transform function to apply to each source element; /// the second parameter of the function represents the index of the source element.</param> /// <param name="resultSelector">A function to create a result element from an element from /// the first sequence and a collection of matching elements from the second sequence.</param> /// <returns>A sequence whose elements are the result of invoking the one-to-many transform /// function <paramref name="collectionSelector"/> on each element of <paramref name="source"/> and then mapping /// each of those sequence elements and their corresponding source element to a result element.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="collectionSelector"/> or /// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> SelectMany<TSource, TCollection, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, IEnumerable<TCollection>> collectionSelector!!, Func<TSource, TCollection, TResult> resultSelector!!) { return new SelectManyQueryOperator<TSource, TCollection, TResult>(source, collectionSelector, null, resultSelector); } /// <summary> /// Projects each element of a sequence to an IEnumerable{T}, flattens the resulting /// sequences into one sequence, and invokes a result selector function on each element /// therein. The index of each source element is used in the intermediate projected /// form of that element. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TCollection">The type of the intermediate elements collected by /// <paramref name="collectionSelector"/>.</typeparam> /// <typeparam name="TResult">The type of elements to return.</typeparam> /// <param name="source">A sequence of values to project.</param> /// <param name="collectionSelector">A transform function to apply to each source element; /// the second parameter of the function represents the index of the source element.</param> /// <param name="resultSelector">A function to create a result element from an element from /// the first sequence and a collection of matching elements from the second sequence.</param> /// <returns> /// A sequence whose elements are the result of invoking the one-to-many transform /// function <paramref name="collectionSelector"/> on each element of <paramref name="source"/> and then mapping /// each of those sequence elements and their corresponding source element to a /// result element. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="collectionSelector"/> or /// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> SelectMany<TSource, TCollection, TResult>( this ParallelQuery<TSource> source!!, Func<TSource, int, IEnumerable<TCollection>> collectionSelector!!, Func<TSource, TCollection, TResult> resultSelector!!) { return new SelectManyQueryOperator<TSource, TCollection, TResult>(source, null, collectionSelector, resultSelector); } //----------------------------------------------------------------------------------- // OrderBy and ThenBy establish an ordering among elements, using user-specified key // selection and key comparison routines. There are also descending sort variants. // /// <summary> /// Sorts in parallel the elements of a sequence in ascending order according to a key. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// To achieve a stable sort, change a query of the form: /// <code>var ordered = source.OrderBy((e) => e.k);</code> /// to instead be formed as: /// <code>var ordered = source.Select((e,i) => new { E=e, I=i }).OrderBy((v) => v.i).Select((v) => v.e);</code> /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence of values to order.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> OrderBy<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!) { return new OrderedParallelQuery<TSource>( new SortQueryOperator<TSource, TKey>(source, keySelector, null, false)); } /// <summary> /// Sorts in parallel the elements of a sequence in ascending order by using a specified comparer. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence of values to order.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An IComparer{TKey} to compare keys.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted according /// to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> OrderBy<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IComparer<TKey>? comparer) { return new OrderedParallelQuery<TSource>( new SortQueryOperator<TSource, TKey>(source, keySelector, comparer, false)); } /// <summary> /// Sorts in parallel the elements of a sequence in descending order according to a key. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence of values to order.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// descending according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> OrderByDescending<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!) { return new OrderedParallelQuery<TSource>(new SortQueryOperator<TSource, TKey>(source, keySelector, null, true)); } /// <summary> /// Sorts the elements of a sequence in descending order by using a specified comparer. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence of values to order.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An IComparer{TKey} to compare keys.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted descending /// according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> OrderByDescending<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IComparer<TKey>? comparer) { return new OrderedParallelQuery<TSource>( new SortQueryOperator<TSource, TKey>(source, keySelector, comparer, true)); } /// <summary> /// Performs in parallel a subsequent ordering of the elements in a sequence /// in ascending order according to a key. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">An OrderedParallelQuery{TSource} than /// contains elements to sort.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are /// sorted according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static OrderedParallelQuery<TSource> ThenBy<TSource, TKey>( this OrderedParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!) { return new OrderedParallelQuery<TSource>( (QueryOperator<TSource>)source.OrderedEnumerable.CreateOrderedEnumerable<TKey>(keySelector, null, false)); } /// <summary> /// Performs in parallel a subsequent ordering of the elements in a sequence in /// ascending order by using a specified comparer. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">An OrderedParallelQuery{TSource} that contains /// elements to sort.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An IComparer{TKey} to compare keys.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// public static OrderedParallelQuery<TSource> ThenBy<TSource, TKey>( this OrderedParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IComparer<TKey>? comparer) { return new OrderedParallelQuery<TSource>( (QueryOperator<TSource>)source.OrderedEnumerable.CreateOrderedEnumerable<TKey>(keySelector, comparer, false)); } /// <summary> /// Performs in parallel a subsequent ordering of the elements in a sequence in /// descending order, according to a key. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">An OrderedParallelQuery{TSource} than contains /// elements to sort.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// descending according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// public static OrderedParallelQuery<TSource> ThenByDescending<TSource, TKey>( this OrderedParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!) { return new OrderedParallelQuery<TSource>( (QueryOperator<TSource>)source.OrderedEnumerable.CreateOrderedEnumerable<TKey>(keySelector, null, true)); } /// <summary> /// Performs in parallel a subsequent ordering of the elements in a sequence in descending /// order by using a specified comparer. /// </summary> /// <remarks> /// In contrast to the sequential implementation, this is not a stable sort. /// See the remarks for OrderBy(ParallelQuery{TSource}, Func{TSource,TKey}) for /// an approach to implementing a stable sort. /// </remarks> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">An OrderedParallelQuery{TSource} than contains /// elements to sort.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An IComparer{TKey} to compare keys.</param> /// <returns>An OrderedParallelQuery{TSource} whose elements are sorted /// descending according to a key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// public static OrderedParallelQuery<TSource> ThenByDescending<TSource, TKey>( this OrderedParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IComparer<TKey>? comparer) { return new OrderedParallelQuery<TSource>( (QueryOperator<TSource>)source.OrderedEnumerable.CreateOrderedEnumerable<TKey>(keySelector, comparer, true)); } //----------------------------------------------------------------------------------- // A GroupBy operation groups inputs based on a key-selection routine, yielding a // one-to-many value of key-to-elements to the consumer. // /// <summary> /// Groups in parallel the elements of a sequence according to a specified key selector function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a /// group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> /// is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector) { return GroupBy<TSource, TKey>(source, keySelector, null); } /// <summary> /// Groups in parallel the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="comparer">An equality comparer to compare keys.</param> /// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a /// group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IEqualityComparer<TKey>? comparer) { return new GroupByQueryOperator<TSource, TKey, TSource>(source, keySelector, null, comparer); } /// <summary> /// Groups in parallel the elements of a sequence according to a specified key selector function and /// projects the elements for each group by using a specified function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the elements in each /// IGrouping{TKey, TElement}.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="elementSelector">A function to map each source element to an element in an /// IGrouping{Key, TElement}.</param> /// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a /// group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) { return GroupBy<TSource, TKey, TElement>(source, keySelector, elementSelector, null); } /// <summary> /// Groups in parallel the elements of a sequence according to a key selector function. /// The keys are compared by using a comparer and each group's elements are projected by /// using a specified function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the elements in each /// IGrouping{TKey, TElement}.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="elementSelector">A function to map each source element to an element in an /// IGrouping{Key, TElement}.</param> /// <param name="comparer">An equality comparer to compare keys.</param> /// <returns>A collection of elements of type IGrouping{TKey, TElement}, where each element represents a /// group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, Func<TSource, TElement> elementSelector!!, IEqualityComparer<TKey>? comparer) { return new GroupByQueryOperator<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer); } // // @PERF: We implement the GroupBy overloads that accept a resultSelector using a GroupBy followed by a Select. This // adds some extra overhead, perhaps the most significant of which is an extra delegate invocation per element. // // One possible solution is to create two different versions of the GroupByOperator class, where one has a TResult // generic type and the other does not. Since this results in code duplication, we will avoid doing that for now. // // Another possible solution is to only have the more general GroupByOperator. Unfortunately, implementing the less // general overload (TResult == TElement) using the more general overload would likely result in unnecessary boxing // and unboxing of each processed element in the cases where TResult is a value type, so that solution comes with // a significant cost, too. // /// <summary> /// Groups in parallel the elements of a sequence according to a specified /// key selector function and creates a result value from each group and its key. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="resultSelector">A function to create a result value from each group.</param> /// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a /// projection over a group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupBy<TSource, TKey, TResult>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector!!) { return source.GroupBy<TSource, TKey>(keySelector) .Select<IGrouping<TKey, TSource>, TResult>(delegate (IGrouping<TKey, TSource> grouping) { return resultSelector(grouping.Key, grouping); }); } /// <summary> /// Groups in parallel the elements of a sequence according to a specified key selector function /// and creates a result value from each group and its key. The keys are compared /// by using a specified comparer. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="resultSelector">A function to create a result value from each group.</param> /// <param name="comparer">An equality comparer to compare keys.</param> /// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a /// projection over a group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupBy<TSource, TKey, TResult>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IEnumerable<TSource>, TResult> resultSelector!!, IEqualityComparer<TKey>? comparer) { return source.GroupBy<TSource, TKey>(keySelector, comparer).Select<IGrouping<TKey, TSource>, TResult>( delegate (IGrouping<TKey, TSource> grouping) { return resultSelector(grouping.Key, grouping); }); } /// <summary> /// Groups in parallel the elements of a sequence according to a specified key /// selector function and creates a result value from each group and its key. /// The elements of each group are projected by using a specified function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the elements in each /// IGrouping{TKey, TElement}.</typeparam> /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="elementSelector">A function to map each source element to an element in an /// IGrouping{Key, TElement}.</param> /// <param name="resultSelector">A function to create a result value from each group.</param> /// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a /// projection over a group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="elementSelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupBy<TSource, TKey, TElement, TResult>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector!!) { return source.GroupBy<TSource, TKey, TElement>(keySelector, elementSelector) .Select<IGrouping<TKey, TElement>, TResult>(delegate (IGrouping<TKey, TElement> grouping) { return resultSelector(grouping.Key, grouping); }); } /// <summary> /// Groups the elements of a sequence according to a specified key selector function and /// creates a result value from each group and its key. Key values are compared by using a /// specified comparer, and the elements of each group are projected by using a specified function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the elements in each /// IGrouping{TKey, TElement}.</typeparam> /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam> /// <param name="source">A sequence whose elements to group.</param> /// <param name="keySelector">A function to extract a key from an element.</param> /// <param name="elementSelector">A function to map each source element to an element in an /// IGrouping{Key, TElement}.</param> /// <param name="resultSelector">A function to create a result value from each group.</param> /// <param name="comparer">An equality comparer to compare keys.</param> /// <returns>A collection of elements of type <typeparamref name="TResult"/> where each element represents a /// projection over a group and its key.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or /// <paramref name="elementSelector"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> GroupBy<TSource, TKey, TElement, TResult>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IEnumerable<TElement>, TResult> resultSelector!!, IEqualityComparer<TKey>? comparer) { return source.GroupBy<TSource, TKey, TElement>(keySelector, elementSelector, comparer) .Select<IGrouping<TKey, TElement>, TResult>(delegate (IGrouping<TKey, TElement> grouping) { return resultSelector(grouping.Key, grouping); }); } /*=================================================================================== * AGGREGATION OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Internal helper method that constructs an aggregation query operator and performs // the actual execution/reduction before returning the result. // // Arguments: // source - the data source over which aggregation is performed // reduce - the binary reduction operator // options - whether the operator is associative, commutative, both, or neither // // Return Value: // The result of aggregation. // private static T PerformAggregation<T>(this ParallelQuery<T> source, Func<T, T, T> reduce, T seed, bool seedIsSpecified, bool throwIfEmpty, QueryAggregationOptions options) { Debug.Assert(source != null); Debug.Assert(reduce != null); Debug.Assert(options.IsValidQueryAggregationOption(), "enum is out of range"); AssociativeAggregationOperator<T, T, T> op = new AssociativeAggregationOperator<T, T, T>( source, seed, null, seedIsSpecified, reduce, reduce, delegate (T obj) { return obj; }, throwIfEmpty, options); return op.Aggregate(); } /// <summary> /// Run an aggregation sequentially. If the user-provided reduction function throws an exception, wrap /// it with an AggregateException. /// </summary> /// <param name="source"></param> /// <param name="seed"></param> /// <param name="seedIsSpecified"> /// if true, use the seed provided in the method argument /// if false, use the first element of the sequence as the seed instead /// </param> /// <param name="func"></param> private static TAccumulate PerformSequentialAggregation<TSource, TAccumulate>( this ParallelQuery<TSource> source, TAccumulate seed, bool seedIsSpecified, Func<TAccumulate, TSource, TAccumulate> func) { Debug.Assert(source != null); Debug.Assert(func != null); Debug.Assert(seedIsSpecified || typeof(TSource) == typeof(TAccumulate)); using (IEnumerator<TSource> enumerator = source.GetEnumerator()) { TAccumulate acc; if (seedIsSpecified) { acc = seed; } else { // Take the first element as the seed if (!enumerator.MoveNext()) { throw new InvalidOperationException(SR.NoElements); } acc = (TAccumulate)(object)enumerator.Current!; } while (enumerator.MoveNext()) { TSource elem = enumerator.Current; // If the user delegate throws an exception, wrap it with an AggregateException try { acc = func(acc, elem); } catch (Exception e) { throw new AggregateException(e); } } return acc; } } //----------------------------------------------------------------------------------- // General purpose aggregation operators, allowing pluggable binary prefix operations. // /// <summary> /// Applies in parallel an accumulator function over a sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="func">An accumulator function to be invoked on each element.</param> /// <returns>The final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="func"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Aggregate<TSource>( this ParallelQuery<TSource> source, Func<TSource, TSource, TSource> func) { return Aggregate<TSource>(source, func, QueryAggregationOptions.AssociativeCommutative); } internal static TSource Aggregate<TSource>( this ParallelQuery<TSource> source!!, Func<TSource, TSource, TSource> func!!, QueryAggregationOptions options) { if ((~(QueryAggregationOptions.Associative | QueryAggregationOptions.Commutative) & options) != 0) throw new ArgumentOutOfRangeException(nameof(options)); if ((options & QueryAggregationOptions.Associative) != QueryAggregationOptions.Associative) { // Non associative aggregations must be run sequentially. We run the query in parallel // and then perform the reduction over the resulting list. return source.PerformSequentialAggregation(default!, false, func); } else { // If associative, we can run this aggregation in parallel. The logic of the aggregation // operator depends on whether the operator is commutative, so we also pass that information // down to the query planning/execution engine. return source.PerformAggregation<TSource>(func, default!, false, true, options); } } /// <summary> /// Applies in parallel an accumulator function over a sequence. /// The specified seed value is used as the initial accumulator value. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="seed">The initial accumulator value.</param> /// <param name="func">An accumulator function to be invoked on each element.</param> /// <returns>The final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="func"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TAccumulate Aggregate<TSource, TAccumulate>( this ParallelQuery<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func) { return Aggregate<TSource, TAccumulate>(source, seed, func, QueryAggregationOptions.AssociativeCommutative); } internal static TAccumulate Aggregate<TSource, TAccumulate>( this ParallelQuery<TSource> source!!, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func!!, QueryAggregationOptions options) { if ((~(QueryAggregationOptions.Associative | QueryAggregationOptions.Commutative) & options) != 0) throw new ArgumentOutOfRangeException(nameof(options)); return source.PerformSequentialAggregation(seed, true, func); } /// <summary> /// Applies in parallel an accumulator function over a sequence. The specified /// seed value is used as the initial accumulator value, and the specified /// function is used to select the result value. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam> /// <typeparam name="TResult">The type of the resulting value.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="seed">The initial accumulator value.</param> /// <param name="func">An accumulator function to be invoked on each element.</param> /// <param name="resultSelector">A function to transform the final accumulator value /// into the result value.</param> /// <returns>The transformed final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="func"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult Aggregate<TSource, TAccumulate, TResult>( this ParallelQuery<TSource> source!!, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func!!, Func<TAccumulate, TResult> resultSelector!!) { TAccumulate acc = source.PerformSequentialAggregation(seed, true, func); try { return resultSelector(acc); } catch (Exception e) { throw new AggregateException(e); } } /// <summary> /// Applies in parallel an accumulator function over a sequence. This overload is not /// available in the sequential implementation. /// </summary> /// <remarks> /// This overload is specific to processing a parallelized query. A parallelized query may /// partition the data source sequence into several sub-sequences (partitions). /// The <paramref name="updateAccumulatorFunc"/> is invoked on each element within partitions. /// Each partition then yields a single accumulated result. The <paramref name="combineAccumulatorsFunc"/> /// is then invoked on the results of each partition to yield a single element. This element is then /// transformed by the <paramref name="resultSelector"/> function. /// </remarks> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam> /// <typeparam name="TResult">The type of the resulting value.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="seed">The initial accumulator value.</param> /// <param name="updateAccumulatorFunc"> /// An accumulator function to be invoked on each element in a partition. /// </param> /// <param name="combineAccumulatorsFunc"> /// An accumulator function to be invoked on the yielded element from each partition. /// </param> /// <param name="resultSelector"> /// A function to transform the final accumulator value into the result value. /// </param> /// <returns>The transformed final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="updateAccumulatorFunc"/> /// or <paramref name="combineAccumulatorsFunc"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult Aggregate<TSource, TAccumulate, TResult>( this ParallelQuery<TSource> source!!, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> updateAccumulatorFunc!!, Func<TAccumulate, TAccumulate, TAccumulate> combineAccumulatorsFunc!!, Func<TAccumulate, TResult> resultSelector!!) { return new AssociativeAggregationOperator<TSource, TAccumulate, TResult>( source, seed, null, true, updateAccumulatorFunc, combineAccumulatorsFunc, resultSelector, false, QueryAggregationOptions.AssociativeCommutative).Aggregate(); } /// <summary> /// Applies in parallel an accumulator function over a sequence. This overload is not /// available in the sequential implementation. /// </summary> /// <remarks> /// This overload is specific to parallelized queries. A parallelized query may partition the data source sequence /// into several sub-sequences (partitions). The <paramref name="updateAccumulatorFunc"/> is invoked /// on each element within partitions. Each partition then yields a single accumulated result. /// The <paramref name="combineAccumulatorsFunc"/> /// is then invoked on the results of each partition to yield a single element. This element is then /// transformed by the <paramref name="resultSelector"/> function. /// </remarks> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam> /// <typeparam name="TResult">The type of the resulting value.</typeparam> /// <param name="source">A sequence to aggregate over.</param> /// <param name="seedFactory"> /// A function that returns the initial accumulator value. /// </param> /// <param name="updateAccumulatorFunc"> /// An accumulator function to be invoked on each element in a partition. /// </param> /// <param name="combineAccumulatorsFunc"> /// An accumulator function to be invoked on the yielded element from each partition. /// </param> /// <param name="resultSelector"> /// A function to transform the final accumulator value into the result value. /// </param> /// <returns>The transformed final accumulator value.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="seedFactory"/> or <paramref name="updateAccumulatorFunc"/> /// or <paramref name="combineAccumulatorsFunc"/> or <paramref name="resultSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult Aggregate<TSource, TAccumulate, TResult>( this ParallelQuery<TSource> source!!, Func<TAccumulate> seedFactory!!, Func<TAccumulate, TSource, TAccumulate> updateAccumulatorFunc!!, Func<TAccumulate, TAccumulate, TAccumulate> combineAccumulatorsFunc!!, Func<TAccumulate, TResult> resultSelector!!) { return new AssociativeAggregationOperator<TSource, TAccumulate, TResult>( source, default!, seedFactory, true, updateAccumulatorFunc, combineAccumulatorsFunc, resultSelector, false, QueryAggregationOptions.AssociativeCommutative).Aggregate(); } //----------------------------------------------------------------------------------- // Count and LongCount reductions. // /// <summary> /// Returns the number of elements in a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence that contains elements to be counted.</param> /// <returns>The number of elements in the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The number of elements in source is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Count<TSource>(this ParallelQuery<TSource> source!!) { // If the data source is a collection, we can just return the count right away. if (source is ParallelEnumerableWrapper<TSource> sourceAsWrapper) { if (sourceAsWrapper.WrappedEnumerable is ICollection<TSource> sourceAsCollection) { return sourceAsCollection.Count; } } // Otherwise, enumerate the whole thing and aggregate a count. checked { return new CountAggregationOperator<TSource>(source).Aggregate(); } } /// <summary> /// Returns a number that represents how many elements in the specified /// parallel sequence satisfy a condition. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence that contains elements to be counted.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// A number that represents how many elements in the sequence satisfy the condition /// in the predicate function. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The number of elements in source is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Count<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { // Construct a where operator to filter out non-matching elements, and then aggregate. checked { return new CountAggregationOperator<TSource>(Where<TSource>(source, predicate)).Aggregate(); } } /// <summary> /// Returns an Int64 that represents the total number of elements in a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence that contains elements to be counted.</param> /// <returns>The number of elements in the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The number of elements in source is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long LongCount<TSource>(this ParallelQuery<TSource> source!!) { // If the data source is a collection, we can just return the count right away. if (source is ParallelEnumerableWrapper<TSource> sourceAsWrapper) { if (sourceAsWrapper.WrappedEnumerable is ICollection<TSource> sourceAsCollection) { return sourceAsCollection.Count; } } // Otherwise, enumerate the whole thing and aggregate a count. return new LongCountAggregationOperator<TSource>(source).Aggregate(); } /// <summary> /// Returns an Int64 that represents how many elements in a parallel sequence satisfy a condition. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence that contains elements to be counted.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// A number that represents how many elements in the sequence satisfy the condition /// in the predicate function. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The number of elements in source is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long LongCount<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { // Construct a where operator to filter out non-matching elements, and then aggregate. return new LongCountAggregationOperator<TSource>(Where<TSource>(source, predicate)).Aggregate(); } //----------------------------------------------------------------------------------- // Sum aggregations. // /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Sum(this ParallelQuery<int> source!!) { return new IntSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Sum(this ParallelQuery<int?> source!!) { return new NullableIntSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Sum(this ParallelQuery<long> source!!) { return new LongSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Sum(this ParallelQuery<long?> source!!) { return new NullableLongSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Sum(this ParallelQuery<float> source!!) { return new FloatSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Sum(this ParallelQuery<float?> source!!) { return new NullableFloatSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Sum(this ParallelQuery<double> source!!) { return new DoubleSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Sum(this ParallelQuery<double?> source!!) { return new NullableDoubleSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="decimal.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Sum(this ParallelQuery<decimal> source!!) { return new DecimalSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of a sequence of values. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="decimal.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Sum(this ParallelQuery<decimal?> source!!) { return new NullableDecimalSumAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, int> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, int?> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, long> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, long?> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, float> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, float?> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, double> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, double?> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="decimal.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal> selector) { return source.Select(selector).Sum(); } /// <summary> /// Computes in parallel the sum of the sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to calculate the sum of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The sum of the values in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum is larger than <see cref="decimal.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Sum<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal?> selector) { return source.Select(selector).Sum(); } //----------------------------------------------------------------------------------- // Helper methods used for Min/Max aggregations below. This class can create a whole // bunch of type-specific delegates that are passed to the general aggregation // infrastructure. All comparisons are performed using the Comparer<T>.Default // comparator. LINQ doesn't offer a way to override this, so neither do we. // // @PERF: we'll eventually want inlined primitive providers that use IL instructions // for comparison instead of the Comparer<T>.CompareTo method. // //----------------------------------------------------------------------------------- // Min aggregations. // /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Min(this ParallelQuery<int> source!!) { return new IntMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Min(this ParallelQuery<int?> source!!) { return new NullableIntMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Min(this ParallelQuery<long> source!!) { return new LongMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Min(this ParallelQuery<long?> source!!) { return new NullableLongMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Min(this ParallelQuery<float> source!!) { return new FloatMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Min(this ParallelQuery<float?> source!!) { return new NullableFloatMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Min(this ParallelQuery<double> source!!) { return new DoubleMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Min(this ParallelQuery<double?> source!!) { return new NullableDoubleMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Min(this ParallelQuery<decimal> source!!) { return new DecimalMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Min(this ParallelQuery<decimal?> source!!) { return new NullableDecimalMinMaxAggregationOperator(source, -1).Aggregate(); } /// <summary> /// Returns the minimum value in a parallel sequence of values. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements and <typeparamref name="TSource"/> is a non-nullable value type. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? Min<TSource>(this ParallelQuery<TSource> source!!) { return AggregationMinMaxHelpers<TSource>.ReduceMin(source); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, int> selector) { return source.Select<TSource, int>(selector).Min<int>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, int?> selector) { return source.Select<TSource, int?>(selector).Min<int?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, long> selector) { return source.Select<TSource, long>(selector).Min<long>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, long?> selector) { return source.Select<TSource, long?>(selector).Min<long?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, float> selector) { return source.Select<TSource, float>(selector).Min<float>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, float?> selector) { return source.Select<TSource, float?>(selector).Min<float?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, double> selector) { return source.Select<TSource, double>(selector).Min<double>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, double?> selector) { return source.Select<TSource, double?>(selector).Min<double?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal> selector) { return source.Select<TSource, decimal>(selector).Min<decimal>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Min<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal?> selector) { return source.Select<TSource, decimal?>(selector).Min<decimal?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the minimum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of the value returned by <paramref name="selector"/>.</typeparam> /// <param name="source">A sequence of values to determine the minimum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The minimum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements and <typeparamref name="TResult"/> is a non-nullable value type. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult? Min<TSource, TResult>(this ParallelQuery<TSource> source, Func<TSource, TResult> selector) { return source.Select<TSource, TResult>(selector).Min<TResult>(); } //----------------------------------------------------------------------------------- // Max aggregations. // /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Max(this ParallelQuery<int> source!!) { return new IntMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Max(this ParallelQuery<int?> source!!) { return new NullableIntMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Max(this ParallelQuery<long> source!!) { return new LongMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Max(this ParallelQuery<long?> source!!) { return new NullableLongMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Max(this ParallelQuery<float> source!!) { return new FloatMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Max(this ParallelQuery<float?> source!!) { return new NullableFloatMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Max(this ParallelQuery<double> source!!) { return new DoubleMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Max(this ParallelQuery<double?> source!!) { return new NullableDoubleMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Max(this ParallelQuery<decimal> source!!) { return new DecimalMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Max(this ParallelQuery<decimal?> source!!) { return new NullableDecimalMinMaxAggregationOperator(source, 1).Aggregate(); } /// <summary> /// Returns the maximum value in a parallel sequence of values. /// </summary> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements and <typeparam name="TSource"/> is a non-nullable value type. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? Max<TSource>(this ParallelQuery<TSource> source!!) { return AggregationMinMaxHelpers<TSource>.ReduceMax(source); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, int> selector) { return source.Select<TSource, int>(selector).Max<int>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static int? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, int?> selector) { return source.Select<TSource, int?>(selector).Max<int?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, long> selector) { return source.Select<TSource, long>(selector).Max<long>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static long? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, long?> selector) { return source.Select<TSource, long?>(selector).Max<long?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, float> selector) { return source.Select<TSource, float>(selector).Max<float>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, float?> selector) { return source.Select<TSource, float?>(selector).Max<float?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, double> selector) { return source.Select<TSource, double>(selector).Max<double>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, double?> selector) { return source.Select<TSource, double?>(selector).Max<double?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal> selector) { return source.Select<TSource, decimal>(selector).Max<decimal>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Max<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal?> selector) { return source.Select<TSource, decimal?>(selector).Max<decimal?>(); } /// <summary> /// Invokes in parallel a transform function on each element of a /// sequence and returns the maximum value. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TResult">The type of the value returned by <paramref name="selector"/>.</typeparam> /// <param name="source">A sequence of values to determine the maximum value of.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The maximum value in the sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements and <typeparamref name="TResult"/> is a non-nullable value type. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TResult? Max<TSource, TResult>(this ParallelQuery<TSource> source, Func<TSource, TResult> selector) { return source.Select<TSource, TResult>(selector).Max<TResult>(); } //----------------------------------------------------------------------------------- // Average aggregations. // /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average(this ParallelQuery<int> source!!) { return new IntAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average(this ParallelQuery<int?> source!!) { return new NullableIntAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average(this ParallelQuery<long> source!!) { return new LongAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average(this ParallelQuery<long?> source!!) { return new NullableLongAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Average(this ParallelQuery<float> source!!) { return new FloatAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Average(this ParallelQuery<float?> source!!) { return new NullableFloatAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average(this ParallelQuery<double> source!!) { return new DoubleAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <exception cref="System.ArgumentNullException"> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average(this ParallelQuery<double?> source!!) { return new NullableDoubleAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Average(this ParallelQuery<decimal> source!!) { return new DecimalAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values. /// </summary> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Average(this ParallelQuery<decimal?> source!!) { return new NullableDecimalAverageAggregationOperator(source).Aggregate(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, int> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, int?> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="int.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, long> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// The sum or count of the elements in the sequence is larger than <see cref="long.MaxValue"/>. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, long?> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, float> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static float? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, float?> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, double> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static double? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, double?> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal> selector) { return source.Select(selector).Average(); } /// <summary> /// Computes in parallel the average of a sequence of values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values that are used to calculate an average.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <returns>The average of the sequence of values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="selector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static decimal? Average<TSource>(this ParallelQuery<TSource> source, Func<TSource, decimal?> selector) { return source.Select(selector).Average(); } //----------------------------------------------------------------------------------- // Any returns true if there exists an element for which the predicate returns true. // /// <summary> /// Determines in parallel whether any element of a sequence satisfies a condition. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">An IEnumerable whose elements to apply the predicate to.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// true if any elements in the source sequence pass the test in the specified predicate; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool Any<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new AnyAllSearchOperator<TSource>(source, true, predicate).Aggregate(); } /// <summary> /// Determines whether a parallel sequence contains any elements. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The IEnumerable to check for emptiness.</param> /// <returns>true if the source sequence contains any elements; otherwise, false.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool Any<TSource>(this ParallelQuery<TSource> source!!) { return Any(source, x => true); } //----------------------------------------------------------------------------------- // All returns false if there exists an element for which the predicate returns false. // /// <summary> /// Determines in parallel whether all elements of a sequence satisfy a condition. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence whose elements to apply the predicate to.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// true if all elements in the source sequence pass the test in the specified predicate; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool All<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new AnyAllSearchOperator<TSource>(source, false, predicate).Aggregate(); } //----------------------------------------------------------------------------------- // Contains returns true if the specified value was found in the data source. // /// <summary> /// Determines in parallel whether a sequence contains a specified element /// by using the default equality comparer. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence in which to locate a value.</param> /// <param name="value">The value to locate in the sequence.</param> /// <returns> /// true if the source sequence contains an element that has the specified value; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool Contains<TSource>(this ParallelQuery<TSource> source, TSource value) { return Contains(source, value, null); } /// <summary> /// Determines in parallel whether a sequence contains a specified element by using a /// specified IEqualityComparer{T}. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence in which to locate a value.</param> /// <param name="value">The value to locate in the sequence.</param> /// <param name="comparer">An equality comparer to compare values.</param> /// <returns> /// true if the source sequence contains an element that has the specified value; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool Contains<TSource>(this ParallelQuery<TSource> source!!, TSource value, IEqualityComparer<TSource>? comparer) { // @PERF: there are many simple optimizations we can make for collection types with known sizes. return new ContainsSearchOperator<TSource>(source, value, comparer).Aggregate(); } /*=================================================================================== * TOP (TAKE, SKIP) OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Take will take the first [0..count) contiguous elements from the input. // /// <summary> /// Returns a specified number of contiguous elements from the start of a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="count">The number of elements to return.</param> /// <returns> /// A sequence that contains the specified number of elements from the start of the input sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Take<TSource>(this ParallelQuery<TSource> source!!, int count) { if (count > 0) { return new TakeOrSkipQueryOperator<TSource>(source, count, true); } else { return ParallelEnumerable.Empty<TSource>(); } } //----------------------------------------------------------------------------------- // TakeWhile will take the first [0..N) contiguous elements, where N is the smallest // index of an element for which the predicate yields false. // /// <summary> /// Returns elements from a parallel sequence as long as a specified condition is true. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// A sequence that contains the elements from the input sequence that occur before /// the element at which the test no longer passes. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> TakeWhile<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new TakeOrSkipWhileQueryOperator<TSource>(source, predicate, null, true); } /// <summary> /// Returns elements from a parallel sequence as long as a specified condition is true. /// The element's index is used in the logic of the predicate function. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="predicate"> /// A function to test each source element for a condition; the second parameter of the /// function represents the index of the source element. /// </param> /// <returns> /// A sequence that contains elements from the input sequence that occur before /// the element at which the test no longer passes. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> TakeWhile<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, int, bool> predicate!!) { return new TakeOrSkipWhileQueryOperator<TSource>(source, null, predicate, true); } //----------------------------------------------------------------------------------- // Skip will take the last [count..M) contiguous elements from the input, where M is // the size of the input. // /// <summary> /// Bypasses a specified number of elements in a parallel sequence and then returns the remaining elements. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="count">The number of elements to skip before returning the remaining elements.</param> /// <returns> /// A sequence that contains the elements that occur after the specified index in the input sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Skip<TSource>(this ParallelQuery<TSource> source!!, int count) { // If the count is 0 (or less) we just return the whole stream. if (count <= 0) { return source; } return new TakeOrSkipQueryOperator<TSource>(source, count, false); } //----------------------------------------------------------------------------------- // SkipWhile will take the last [N..M) contiguous elements, where N is the smallest // index of an element for which the predicate yields false, and M is the size of // the input data source. // /// <summary> /// Bypasses elements in a parallel sequence as long as a specified /// condition is true and then returns the remaining elements. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns>A sequence that contains the elements from the input sequence starting at /// the first element in the linear series that does not pass the test specified by /// <B>predicate</B>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> SkipWhile<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return new TakeOrSkipWhileQueryOperator<TSource>(source, predicate, null, false); } /// <summary> /// Bypasses elements in a parallel sequence as long as a specified condition is true and /// then returns the remaining elements. The element's index is used in the logic of /// the predicate function. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return elements from.</param> /// <param name="predicate"> /// A function to test each source element for a condition; the /// second parameter of the function represents the index of the source element. /// </param> /// <returns> /// A sequence that contains the elements from the input sequence starting at the /// first element in the linear series that does not pass the test specified by /// <B>predicate</B>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> SkipWhile<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, int, bool> predicate!!) { return new TakeOrSkipWhileQueryOperator<TSource>(source, null, predicate, false); } /*=================================================================================== * SET OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Appends the second data source to the first, preserving order in the process. // /// <summary> /// Concatenates two parallel sequences. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">The first sequence to concatenate.</param> /// <param name="second">The sequence to concatenate to the first sequence.</param> /// <returns>A sequence that contains the concatenated elements of the two input sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Concat<TSource>(this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!) { return new ConcatQueryOperator<TSource>(first, second); } /// <summary> /// This Concat overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Concat with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Concat operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Concat<TSource>(this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Compares two input streams pairwise for equality. // /// <summary> /// Determines whether two parallel sequences are equal by comparing the elements by using /// the default equality comparer for their type. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence to compare to <b>second</b>.</param> /// <param name="second">A sequence to compare to the first input sequence.</param> /// <returns> /// true if the two source sequences are of equal length and their corresponding elements /// are equal according to the default equality comparer for their type; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool SequenceEqual<TSource>(this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!) { return SequenceEqual<TSource>(first, second, null); } /// <summary> /// This SequenceEqual overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">Thrown every time this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of SequenceEqual with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the SequenceEqual operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static bool SequenceEqual<TSource>(this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Determines whether two parallel sequences are equal by comparing their elements by /// using a specified IEqualityComparer{T}. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence to compare to <paramref name="second"/>.</param> /// <param name="second">A sequence to compare to the first input sequence.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to use to compare elements.</param> /// <returns> /// true if the two source sequences are of equal length and their corresponding /// elements are equal according to the default equality comparer for their type; otherwise, false. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static bool SequenceEqual<TSource>(this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!, IEqualityComparer<TSource>? comparer) { // If comparer is null, use the default one comparer ??= EqualityComparer<TSource>.Default; QueryOperator<TSource> leftOp = QueryOperator<TSource>.AsQueryOperator(first); QueryOperator<TSource> rightOp = QueryOperator<TSource>.AsQueryOperator(second); // We use a fully-qualified type name for Shared here to prevent the conflict between System.Linq.Parallel.Shared<> // and System.Threading.Shared<> in the 3.5 legacy build. QuerySettings settings = leftOp.SpecifiedQuerySettings.Merge(rightOp.SpecifiedQuerySettings) .WithDefaults() .WithPerExecutionSettings(new CancellationTokenSource(), new System.Linq.Parallel.Shared<bool>(false)); // If first.GetEnumerator throws an exception, we don't want to wrap it with an AggregateException. IEnumerator<TSource> e1 = first.GetEnumerator(); try { // If second.GetEnumerator throws an exception, we don't want to wrap it with an AggregateException. IEnumerator<TSource> e2 = second.GetEnumerator(); try { while (e1.MoveNext()) { if (!(e2.MoveNext() && comparer.Equals(e1.Current, e2.Current))) return false; } if (e2.MoveNext()) return false; } catch (Exception ex) { ExceptionAggregator.ThrowOCEorAggregateException(ex, settings.CancellationState); } finally { DisposeEnumerator<TSource>(e2, settings.CancellationState); } } finally { DisposeEnumerator<TSource>(e1, settings.CancellationState); } return true; } /// <summary> /// A helper method for SequenceEqual to dispose an enumerator. If an exception is thrown by the disposal, /// it gets wrapped into an AggregateException, unless it is an OCE with the query's CancellationToken. /// </summary> private static void DisposeEnumerator<TSource>(IEnumerator<TSource> e, CancellationState cancelState) { try { e.Dispose(); } catch (Exception ex) { ExceptionAggregator.ThrowOCEorAggregateException(ex, cancelState); } } /// <summary> /// This SequenceEqual overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">Thrown every time this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of SequenceEqual with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the SequenceEqual operator would appear to be binding to the parallel implementation, /// but would in reality bind to sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static bool SequenceEqual<TSource>(this ParallelQuery<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Calculates the distinct set of elements in the single input data source. // /// <summary> /// Returns distinct elements from a parallel sequence by using the /// default equality comparer to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to remove duplicate elements from.</param> /// <returns>A sequence that contains distinct elements from the source sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Distinct<TSource>( this ParallelQuery<TSource> source) { return Distinct(source, null); } /// <summary> /// Returns distinct elements from a parallel sequence by using a specified /// IEqualityComparer{T} to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to remove duplicate elements from.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare values.</param> /// <returns>A sequence that contains distinct elements from the source sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Distinct<TSource>( this ParallelQuery<TSource> source!!, IEqualityComparer<TSource>? comparer) { return new DistinctQueryOperator<TSource>(source, comparer); } //----------------------------------------------------------------------------------- // Calculates the union between the first and second data sources. // /// <summary> /// Produces the set union of two parallel sequences by using the default equality comparer. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence whose distinct elements form the first set for the union.</param> /// <param name="second">A sequence whose distinct elements form the second set for the union.</param> /// <returns>A sequence that contains the elements from both input sequences, excluding duplicates.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Union<TSource>( this ParallelQuery<TSource> first, ParallelQuery<TSource> second) { return Union(first, second, null); } /// <summary> /// This Union overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Union with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Union operator would appear to be binding to the parallel implementation, /// but would in reality bind to sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Union<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Produces the set union of two parallel sequences by using a specified IEqualityComparer{T}. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence whose distinct elements form the first set for the union.</param> /// <param name="second">A sequence whose distinct elements form the second set for the union.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare values.</param> /// <returns>A sequence that contains the elements from both input sequences, excluding duplicates.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Union<TSource>( this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!, IEqualityComparer<TSource>? comparer) { return new UnionQueryOperator<TSource>(first, second, comparer); } /// <summary> /// This Union overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Union with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Union operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Union<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Calculates the intersection between the first and second data sources. // /// <summary> /// Produces the set intersection of two parallel sequences by using the /// default equality comparer to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first" /// >A sequence whose distinct elements that also appear in <paramref name="second"/> will be returned. /// </param> /// <param name="second"> /// A sequence whose distinct elements that also appear in the first sequence will be returned. /// </param> /// <returns>A sequence that contains the elements that form the set intersection of two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Intersect<TSource>( this ParallelQuery<TSource> first, ParallelQuery<TSource> second) { return Intersect(first, second, null); } /// <summary> /// This Intersect overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Intersect with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Intersect operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Intersect<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Produces the set intersection of two parallel sequences by using /// the specified IEqualityComparer{T} to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first"> /// A sequence whose distinct elements that also appear in <paramref name="second"/> will be returned. /// </param> /// <param name="second"> /// A sequence whose distinct elements that also appear in the first sequence will be returned. /// </param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare values.</param> /// <returns>A sequence that contains the elements that form the set intersection of two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Intersect<TSource>( this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!, IEqualityComparer<TSource>? comparer) { return new IntersectQueryOperator<TSource>(first, second, comparer); } /// <summary> /// This Intersect overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Intersect with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Intersect operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Intersect<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } //----------------------------------------------------------------------------------- // Calculates the relative complement of the first and second data sources, that is, // the elements in first that are not found in second. // /// <summary> /// Produces the set difference of two parallel sequences by using /// the default equality comparer to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first"> /// A sequence whose elements that are not also in <paramref name="second"/> will be returned. /// </param> /// <param name="second"> /// A sequence whose elements that also occur in the first sequence will cause those /// elements to be removed from the returned sequence. /// </param> /// <returns>A sequence that contains the set difference of the elements of two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Except<TSource>( this ParallelQuery<TSource> first, ParallelQuery<TSource> second) { return Except(first, second, null); } /// <summary> /// This Except overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Except with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Except operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Except<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /// <summary> /// Produces the set difference of two parallel sequences by using the /// specified IEqualityComparer{T} to compare values. /// </summary> /// <typeparam name="TSource">The type of the elements of the input sequences.</typeparam> /// <param name="first">A sequence whose elements that are not also in <paramref name="second"/> will be returned.</param> /// <param name="second"> /// A sequence whose elements that also occur in the first sequence will cause those elements /// to be removed from the returned sequence. /// </param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare values.</param> /// <returns>A sequence that contains the set difference of the elements of two sequences.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Except<TSource>( this ParallelQuery<TSource> first!!, ParallelQuery<TSource> second!!, IEqualityComparer<TSource>? comparer) { return new ExceptQueryOperator<TSource>(first, second, comparer); } /// <summary> /// This Except overload should never be called. /// This method is marked as obsolete and always throws <see cref="System.NotSupportedException"/> when called. /// </summary> /// <typeparam name="TSource">This type parameter is not used.</typeparam> /// <param name="first">This parameter is not used.</param> /// <param name="second">This parameter is not used.</param> /// <param name="comparer">This parameter is not used.</param> /// <returns>This overload always throws a <see cref="System.NotSupportedException"/>.</returns> /// <exception cref="System.NotSupportedException">The exception that occurs when this method is called.</exception> /// <remarks> /// This overload exists to disallow usage of Except with a left data source of type /// <see cref="System.Linq.ParallelQuery{TSource}"/> and a right data source of type <see cref="System.Collections.Generic.IEnumerable{TSource}"/>. /// Otherwise, the Except operator would appear to be binding to the parallel implementation, /// but would in reality bind to the sequential implementation. /// </remarks> [Obsolete(RIGHT_SOURCE_NOT_PARALLEL_STR)] public static ParallelQuery<TSource> Except<TSource>( this ParallelQuery<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource>? comparer) { throw new NotSupportedException(SR.ParallelEnumerable_BinaryOpMustUseAsParallel); } /*=================================================================================== * DATA TYPE CONVERSION OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // For compatibility with LINQ. Changes the static type to be less specific if needed. // /// <summary> /// Converts a <see cref="ParallelQuery{T}"/> into an /// <see cref="System.Collections.Generic.IEnumerable{T}"/> to force sequential /// evaluation of the query. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to type as <see cref="System.Collections.Generic.IEnumerable{T}"/>.</param> /// <returns>The input sequence types as <see cref="System.Collections.Generic.IEnumerable{T}"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static IEnumerable<TSource> AsEnumerable<TSource>(this ParallelQuery<TSource> source) { return AsSequential(source); } //----------------------------------------------------------------------------------- // Simply generates a single-dimensional array containing the elements from the // provided enumerable object. // /// <summary> /// Creates an array from a ParallelQuery{T}. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to create an array from.</param> /// <returns>An array that contains the elements from the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource[] ToArray<TSource>(this ParallelQuery<TSource> source!!) { if (source is QueryOperator<TSource> asOperator) { return asOperator.ExecuteAndGetResultsAsArray(); } return ToList<TSource>(source).ToArray<TSource>(); } //----------------------------------------------------------------------------------- // The ToList method is similar to the ToArray methods above, except that they return // List<TSource> objects. An overload is provided to specify the length, if desired. // /// <summary> /// Creates a List{T} from an ParallelQuery{T}. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to create a List&lt;(Of &lt;(T&gt;)&gt;) from.</param> /// <returns>A List&lt;(Of &lt;(T&gt;)&gt;) that contains elements from the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static List<TSource> ToList<TSource>(this ParallelQuery<TSource> source!!) { // Allocate a growable list (optionally passing the length as the initial size). List<TSource> list = new List<TSource>(); IEnumerator<TSource> input; if (source is QueryOperator<TSource> asOperator) { if (asOperator.OrdinalIndexState == OrdinalIndexState.Indexable && asOperator.OutputOrdered) { // If the query is indexable and the output is ordered, we will use the array-based merge. // That way, we avoid the ordering overhead. Due to limitations of the List<> class, the // most efficient solution seems to be to first dump all results into the array, and then // copy them over into a List<>. // // The issue is that we cannot efficiently construct a List<> with a fixed size. We can // construct a List<> with a fixed *capacity*, but we still need to call Add() N times // in order to be able to index into the List<>. return new List<TSource>(ToArray<TSource>(source)); } // We will enumerate the list w/out pipelining. // @PERF: there are likely some cases, e.g. for very large data sets, // where we want to use pipelining for this operation. It can reduce memory // usage since, as we enumerate w/ pipelining off, we're already accumulating // results into a buffer. As a matter of fact, there's probably a way we can // just directly use that buffer below instead of creating a new list. input = asOperator.GetEnumerator(ParallelMergeOptions.FullyBuffered); } else { input = source.GetEnumerator(); } // Now, accumulate the results into a dynamically sized list, stopping if we reach // the (optionally specified) maximum length. Debug.Assert(input != null); using (input) { while (input.MoveNext()) { list.Add(input.Current); } } return list; } //----------------------------------------------------------------------------------- // ToDictionary constructs a dictionary from an instance of ParallelQuery. // Each element in the enumerable is converted to a (key,value) pair using a pair // of lambda expressions specified by the caller. Different elements must produce // different keys or else ArgumentException is thrown. // /// <summary> /// Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to /// a specified key selector function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence to create a Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <returns>A Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) that contains keys and values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// <paramref name="keySelector"/> produces a key that is a null reference (Nothing in Visual Basic). /// -or- /// <paramref name="keySelector"/> produces duplicate keys for two elements. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector) where TKey : notnull { return ToDictionary(source, keySelector, EqualityComparer<TKey>.Default); } /// <summary> /// Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to a /// specified key selector function and key comparer. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">A sequence to create a Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare keys.</param> /// <returns>A Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) that contains keys and values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// <paramref name="keySelector"/> produces a key that is a null reference (Nothing in Visual Basic). /// -or- /// <paramref name="keySelector"/> produces duplicate keys for two elements. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static Dictionary<TKey, TSource> ToDictionary<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IEqualityComparer<TKey>? comparer) where TKey : notnull { // comparer may be null. In that case, the Dictionary constructor will use the default comparer. Dictionary<TKey, TSource> result = new Dictionary<TKey, TSource>(comparer); QueryOperator<TSource>? op = source as QueryOperator<TSource>; IEnumerator<TSource> input = (op == null) ? source.GetEnumerator() : op.GetEnumerator(ParallelMergeOptions.FullyBuffered, true); using (input) { while (input.MoveNext()) { TKey key; TSource val = input.Current; try { key = keySelector(val); result.Add(key, val); } catch (Exception ex) { throw new AggregateException(ex); } } } return result; } /// <summary> /// Creates a Dictionary{TKey,TValue} from a ParallelQuery{T} according to specified /// key selector and element selector functions. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector"/>.</typeparam> /// <param name="source">A sequence to create a Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="elementSelector"> /// A transform function to produce a result element value from each element. /// </param> /// <returns> /// A Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) that contains values of type <typeparamref name="TElement"/> /// selected from the input sequence /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// <paramref name="keySelector"/> produces a key that is a null reference (Nothing in Visual Basic). /// -or- /// <paramref name="keySelector"/> produces duplicate keys for two elements. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) where TKey : notnull { return ToDictionary(source, keySelector, elementSelector, EqualityComparer<TKey>.Default); } /// <summary> /// Creates a Dictionary{TKey,TValue from a ParallelQuery{T} according to a /// specified key selector function, a comparer, and an element selector function. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector"/>.</typeparam> /// <param name="source">A sequence to create a Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="elementSelector">A transform function to produce a result element /// value from each element.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare keys.</param> /// <returns> /// A Dictionary&lt;(Of &lt;(TKey, TValue&gt;)&gt;) that contains values of type <typeparamref name="TElement"/> /// selected from the input sequence /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// <paramref name="keySelector"/> produces a key that is a null reference (Nothing in Visual Basic). /// -or- /// <paramref name="keySelector"/> produces duplicate keys for two elements. /// -or- /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, Func<TSource, TElement> elementSelector!!, IEqualityComparer<TKey>? comparer) where TKey : notnull { // comparer may be null. In that case, the Dictionary constructor will use the default comparer. Dictionary<TKey, TElement> result = new Dictionary<TKey, TElement>(comparer); QueryOperator<TSource>? op = source as QueryOperator<TSource>; IEnumerator<TSource> input = (op == null) ? source.GetEnumerator() : op.GetEnumerator(ParallelMergeOptions.FullyBuffered, true); using (input) { while (input.MoveNext()) { TSource src = input.Current; try { result.Add(keySelector(src), elementSelector(src)); } catch (Exception ex) { throw new AggregateException(ex); } } } return result; } //----------------------------------------------------------------------------------- // ToLookup constructs a lookup from an instance of ParallelQuery. // Each element in the enumerable is converted to a (key,value) pair using a pair // of lambda expressions specified by the caller. Multiple elements are allowed // to produce the same key. // /// <summary> /// Creates an ILookup{TKey,T} from a ParallelQuery{T} according to a specified key selector function. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">The sequence to create a Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <returns>A Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) that contains keys and values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static ILookup<TKey, TSource> ToLookup<TSource, TKey>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector) where TKey: notnull { return ToLookup(source, keySelector, EqualityComparer<TKey>.Default); } /// <summary> /// Creates an ILookup{TKey,T} from a ParallelQuery{T} according to a specified /// key selector function and key comparer. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <param name="source">The sequence to create a Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare keys.</param> /// <returns>A Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) that contains keys and values.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static ILookup<TKey, TSource> ToLookup<TSource, TKey>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, IEqualityComparer<TKey>? comparer) where TKey: notnull { // comparer may be null, in which case we use the default comparer. comparer = comparer ?? EqualityComparer<TKey>.Default; ParallelQuery<IGrouping<TKey, TSource>> groupings = source.GroupBy(keySelector, comparer); Parallel.Lookup<TKey, TSource> lookup = new Parallel.Lookup<TKey, TSource>(comparer); Debug.Assert(groupings is QueryOperator<IGrouping<TKey, TSource>>); QueryOperator<IGrouping<TKey, TSource>>? op = groupings as QueryOperator<IGrouping<TKey, TSource>>; IEnumerator<IGrouping<TKey, TSource>> input = (op == null) ? groupings.GetEnumerator() : op.GetEnumerator(ParallelMergeOptions.FullyBuffered); using (input) { while (input.MoveNext()) { lookup.Add(input.Current); } } return lookup; } /// <summary> /// Creates an ILookup{TKey,TElement} from a ParallelQuery{T} according to specified /// key selector and element selector functions. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector"/>.</typeparam> /// <param name="source">The sequence to create a Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="elementSelector"> /// A transform function to produce a result element value from each element. /// </param> /// <returns> /// A Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) that contains values of type TElement /// selected from the input sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>( this ParallelQuery<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector) where TKey : notnull { return ToLookup(source, keySelector, elementSelector, EqualityComparer<TKey>.Default); } /// <summary> /// Creates an ILookup{TKey,TElement} from a ParallelQuery{T} according to /// a specified key selector function, a comparer and an element selector function. /// </summary> /// <typeparam name="TSource">The type of elements of <paramref name="source"/>.</typeparam> /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam> /// <typeparam name="TElement">The type of the value returned by <paramref name="elementSelector"/>.</typeparam> /// <param name="source">The sequence to create a Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) from.</param> /// <param name="keySelector">A function to extract a key from each element.</param> /// <param name="elementSelector"> /// A transform function to produce a result element value from each element. /// </param> /// <param name="comparer">An IEqualityComparer&lt;(Of &lt;(T&gt;)&gt;) to compare keys.</param> /// <returns> /// A Lookup&lt;(Of &lt;(TKey, TElement&gt;)&gt;) that contains values of type TElement selected /// from the input sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static ILookup<TKey, TElement> ToLookup<TSource, TKey, TElement>( this ParallelQuery<TSource> source!!, Func<TSource, TKey> keySelector!!, Func<TSource, TElement> elementSelector!!, IEqualityComparer<TKey>? comparer) where TKey : notnull { // comparer may be null, in which case we use the default comparer. comparer = comparer ?? EqualityComparer<TKey>.Default; ParallelQuery<IGrouping<TKey, TElement>> groupings = source.GroupBy(keySelector, elementSelector, comparer); Parallel.Lookup<TKey, TElement> lookup = new Parallel.Lookup<TKey, TElement>(comparer); Debug.Assert(groupings is QueryOperator<IGrouping<TKey, TElement>>); QueryOperator<IGrouping<TKey, TElement>>? op = groupings as QueryOperator<IGrouping<TKey, TElement>>; IEnumerator<IGrouping<TKey, TElement>> input = (op == null) ? groupings.GetEnumerator() : op.GetEnumerator(ParallelMergeOptions.FullyBuffered); using (input) { while (input.MoveNext()) { lookup.Add(input.Current); } } return lookup; } /*=================================================================================== * MISCELLANEOUS OPERATORS *===================================================================================*/ //----------------------------------------------------------------------------------- // Reverses the input. // /// <summary> /// Inverts the order of the elements in a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence of values to reverse.</param> /// <returns>A sequence whose elements correspond to those of the input sequence in reverse order.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> Reverse<TSource>(this ParallelQuery<TSource> source!!) { return new ReverseQueryOperator<TSource>(source); } //----------------------------------------------------------------------------------- // Both OfType and Cast convert a weakly typed stream to a strongly typed one: // the difference is that OfType filters out elements that aren't of the given type, // while Cast forces the cast, possibly resulting in InvalidCastExceptions. // /// <summary> /// Filters the elements of a ParallelQuery based on a specified type. /// </summary> /// <typeparam name="TResult">The type to filter the elements of the sequence on.</typeparam> /// <param name="source">The sequence whose elements to filter.</param> /// <returns>A sequence that contains elements from the input sequence of type <typeparamref name="TResult"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> OfType<TResult>(this ParallelQuery source!!) { return source.OfType<TResult>(); } /// <summary> /// Converts the elements of a weakly-typed ParallelQuery to the specified stronger type. /// </summary> /// <typeparam name="TResult">The stronger type to convert the elements of <paramref name="source"/> to.</typeparam> /// <param name="source">The sequence that contains the weakly typed elements to be converted.</param> /// <returns> /// A sequence that contains each weakly-type element of the source sequence converted to the specified stronger type. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TResult> Cast<TResult>(this ParallelQuery source!!) { return source.Cast<TResult>(); } //----------------------------------------------------------------------------------- // Helper method used by First, FirstOrDefault, Last, LastOrDefault, Single, and // SingleOrDefault below. This takes a query operator, gets the first item (and // either checks or asserts there is at most one item in the source), and returns it. // If there are no elements, the method either throws an exception or, if // defaultIfEmpty is true, returns a default value. // // Arguments: // queryOp - the query operator to enumerate (for the single element) // throwIfTwo - whether to throw an exception (true) or assert (false) that // there is no more than one element in the source // defaultIfEmpty - whether to return a default value (true) or throw an // exception if the output of the query operator is empty // private static TSource? GetOneWithPossibleDefault<TSource>( QueryOperator<TSource> queryOp, bool throwIfTwo, bool defaultIfEmpty) { Debug.Assert(queryOp != null, "expected query operator"); using (IEnumerator<TSource> e = queryOp.GetEnumerator(ParallelMergeOptions.FullyBuffered)) { if (e.MoveNext()) { TSource current = e.Current; // Some operators need to do a runtime, retail check for more than one element. // Others can simply assert that there was only one. if (throwIfTwo) { if (e.MoveNext()) { throw new InvalidOperationException(SR.MoreThanOneMatch); } } else { Debug.Assert(!e.MoveNext(), "expected only a single element"); } return current; } } if (defaultIfEmpty) { return default; } else { throw new InvalidOperationException(SR.NoElements); } } //----------------------------------------------------------------------------------- // First simply returns the first element from the data source; if the predicate // overload is used, the first element satisfying the predicate is returned. // An exception is thrown for empty data sources. Alternatively, the FirstOrDefault // method can be used which returns default(T) if empty (or no elements satisfy the // predicate). // /// <summary> /// Returns the first element of a parallel sequence.</summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the first element of.</param> /// <returns>The first element in the specified sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource First<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for seekable data sources. E.g. if an array, we can // seek directly to the 0th element. FirstQueryOperator<TSource> queryOp = new FirstQueryOperator<TSource>(source, null); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState) .First(); } return GetOneWithPossibleDefault(queryOp, false, false)!; } /// <summary> /// Returns the first element in a parallel sequence that satisfies a specified condition. /// </summary> /// <remarks>There's a temporary difference from LINQ to Objects, this does not throw /// ArgumentNullException when the predicate is null.</remarks> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns>The first element in the sequence that passes the test in the specified predicate function.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// No element in <paramref name="source"/> satisfies the condition in <paramref name="predicate"/>. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource First<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { FirstQueryOperator<TSource> queryOp = new FirstQueryOperator<TSource>(source, predicate); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState) .First(ExceptionAggregator.WrapFunc<TSource, bool>(predicate, settings.CancellationState)); } return GetOneWithPossibleDefault(queryOp, false, false)!; } /// <summary> /// Returns the first element of a parallel sequence, or a default value if the /// sequence contains no elements. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the first element of.</param> /// <returns> /// default(<B>TSource</B>) if <paramref name="source"/> is empty; otherwise, the first element in <paramref name="source"/>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? FirstOrDefault<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for seekable data sources. E.g. if an array, we can // seek directly to the 0th element. FirstQueryOperator<TSource> queryOp = new FirstQueryOperator<TSource>(source, null); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState).FirstOrDefault(); } return GetOneWithPossibleDefault(queryOp, false, true); } /// <summary> /// Returns the first element of the parallel sequence that satisfies a condition or a /// default value if no such element is found. /// </summary> /// <remarks>There's a temporary difference from LINQ to Objects, this does not throw /// ArgumentNullException when the predicate is null.</remarks> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// default(<B>TSource</B>) if <paramref name="source"/> is empty or if no element passes the test /// specified by <B>predicate</B>; otherwise, the first element in <paramref name="source"/> that /// passes the test specified by <B>predicate</B>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? FirstOrDefault<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { FirstQueryOperator<TSource> queryOp = new FirstQueryOperator<TSource>(source, predicate); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable( childWithCancelChecks, settings.CancellationState) .FirstOrDefault(ExceptionAggregator.WrapFunc<TSource, bool>(predicate, settings.CancellationState)); } return GetOneWithPossibleDefault(queryOp, false, true); } //----------------------------------------------------------------------------------- // Last simply returns the last element from the data source; if the predicate // overload is used, the last element satisfying the predicate is returned. // An exception is thrown for empty data sources. Alternatively, the LastOrDefault // method can be used which returns default(T) if empty (or no elements satisfy the // predicate). // /// <summary> /// Returns the last element of a parallel sequence.</summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the last element from.</param> /// <returns>The value at the last position in the source sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// <paramref name="source"/> contains no elements. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Last<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for seekable data sources. E.g. if an array, we can // seek directly to the last element. LastQueryOperator<TSource> queryOp = new LastQueryOperator<TSource>(source, null); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState).Last(); } return GetOneWithPossibleDefault(queryOp, false, false)!; } /// <summary> /// Returns the last element of a parallel sequence that satisfies a specified condition. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// The last element in the sequence that passes the test in the specified predicate function. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// No element in <paramref name="source"/> satisfies the condition in <paramref name="predicate"/>. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Last<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { LastQueryOperator<TSource> queryOp = new LastQueryOperator<TSource>(source, predicate); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable( childWithCancelChecks, settings.CancellationState) .Last(ExceptionAggregator.WrapFunc<TSource, bool>(predicate, settings.CancellationState)); } return GetOneWithPossibleDefault(queryOp, false, false)!; } /// <summary> /// Returns the last element of a parallel sequence, or a default value if the /// sequence contains no elements. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <returns> /// default(<typeparamref name="TSource"/>) if the source sequence is empty; otherwise, the last element in the sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? LastOrDefault<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for seekable data sources. E.g. if an array, we can // seek directly to the last element. LastQueryOperator<TSource> queryOp = new LastQueryOperator<TSource>(source, null); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable(childWithCancelChecks, settings.CancellationState).LastOrDefault(); } return GetOneWithPossibleDefault(queryOp, false, true); } /// <summary> /// Returns the last element of a parallel sequence that satisfies a condition, or /// a default value if no such element is found. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return an element from.</param> /// <param name="predicate">A function to test each element for a condition.</param> /// <returns> /// default(<typeparamref name="TSource"/>) if the sequence is empty or if no elements pass the test in the /// predicate function; otherwise, the last element that passes the test in the predicate function. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? LastOrDefault<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { LastQueryOperator<TSource> queryOp = new LastQueryOperator<TSource>(source, predicate); // If in conservative mode and a premature merge would be inserted by the First operator, // run the whole query sequentially. QuerySettings settings = queryOp.SpecifiedQuerySettings.WithDefaults(); if (queryOp.LimitsParallelism && settings.ExecutionMode != ParallelExecutionMode.ForceParallelism) { IEnumerable<TSource> childAsSequential = queryOp.Child.AsSequentialQuery(settings.CancellationState.ExternalCancellationToken); IEnumerable<TSource> childWithCancelChecks = CancellableEnumerable.Wrap(childAsSequential, settings.CancellationState.ExternalCancellationToken); return ExceptionAggregator.WrapEnumerable( childWithCancelChecks, settings.CancellationState) .LastOrDefault(ExceptionAggregator.WrapFunc<TSource, bool>(predicate, settings.CancellationState)); } return GetOneWithPossibleDefault(queryOp, false, true); } //----------------------------------------------------------------------------------- // Single yields the single element matching the optional predicate, or throws an // exception if there is zero or more than one match. SingleOrDefault is similar // except that it returns the default value in this condition. // /// <summary> /// Returns the only element of a parallel sequence, and throws an exception if there is not /// exactly one element in the sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the single element of.</param> /// <returns>The single element of the input sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// The input sequence contains more than one element. -or- The input sequence is empty. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Single<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for ICollection-typed data sources, i.e. we can just // check the Count property and avoid costly fork/join/synchronization. return GetOneWithPossibleDefault(new SingleQueryOperator<TSource>(source, null), true, false)!; } /// <summary> /// Returns the only element of a parallel sequence that satisfies a specified condition, /// and throws an exception if more than one such element exists. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the single element of.</param> /// <param name="predicate">A function to test an element for a condition.</param> /// <returns>The single element of the input sequence that satisfies a condition.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.InvalidOperationException"> /// No element satisfies the condition in <paramref name="predicate"/>. -or- More than one element satisfies the condition in <paramref name="predicate"/>. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource Single<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return GetOneWithPossibleDefault(new SingleQueryOperator<TSource>(source, predicate), true, false)!; } /// <summary> /// Returns the only element of a parallel sequence, or a default value if the sequence is /// empty; this method throws an exception if there is more than one element in the sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the single element of.</param> /// <returns> /// The single element of the input sequence, or default(<typeparamref name="TSource"/>) if the /// sequence contains no elements. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? SingleOrDefault<TSource>(this ParallelQuery<TSource> source!!) { // @PERF: optimize for ICollection-typed data sources, i.e. we can just // check the Count property and avoid costly fork/join/synchronization. return GetOneWithPossibleDefault(new SingleQueryOperator<TSource>(source, null), true, true); } /// <summary> /// Returns the only element of a parallel sequence that satisfies a specified condition /// or a default value if no such element exists; this method throws an exception /// if more than one element satisfies the condition. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the single element of.</param> /// <param name="predicate">A function to test an element for a condition.</param> /// <returns> /// The single element of the input sequence that satisfies the condition, or /// default(<typeparamref name="TSource"/>) if no such element is found. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> or <paramref name="predicate"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? SingleOrDefault<TSource>(this ParallelQuery<TSource> source!!, Func<TSource, bool> predicate!!) { return GetOneWithPossibleDefault(new SingleQueryOperator<TSource>(source, predicate), true, true); } //----------------------------------------------------------------------------------- // DefaultIfEmpty yields the data source, unmodified, if it is non-empty. Otherwise, // it yields a single occurrence of the default value. // /// <summary> /// Returns the elements of the specified parallel sequence or the type parameter's /// default value in a singleton collection if the sequence is empty. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return a default value for if it is empty.</param> /// <returns> /// A sequence that contains default(<B>TSource</B>) if <paramref name="source"/> is empty; otherwise, <paramref name="source"/>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource?> DefaultIfEmpty<TSource>(this ParallelQuery<TSource> source) { return DefaultIfEmpty<TSource>(source, default!)!; } /// <summary> /// Returns the elements of the specified parallel sequence or the specified value /// in a singleton collection if the sequence is empty. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">The sequence to return the specified value for if it is empty.</param> /// <param name="defaultValue">The value to return if the sequence is empty.</param> /// <returns> /// A sequence that contains <B>defaultValue</B> if <paramref name="source"/> is empty; otherwise, <paramref name="source"/>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> public static ParallelQuery<TSource> DefaultIfEmpty<TSource>(this ParallelQuery<TSource> source!!, TSource defaultValue) { return new DefaultIfEmptyQueryOperator<TSource>(source, defaultValue); } //----------------------------------------------------------------------------------- // ElementAt yields an element at a specific index. If the data source doesn't // contain such an element, an exception is thrown. Alternatively, ElementAtOrDefault // will return a default value if the given index is invalid. // /// <summary> /// Returns the element at a specified index in a parallel sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to return an element from.</param> /// <param name="index">The zero-based index of the element to retrieve.</param> /// <returns>The element at the specified position in the source sequence.</returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// <paramref name="index"/> is less than 0 or greater than or equal to the number of elements in <paramref name="source"/>. /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource ElementAt<TSource>(this ParallelQuery<TSource> source!!, int index) { if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); // @PERF: there are obvious optimization opportunities for indexable data sources, // since we can just seek to the element requested. ElementAtQueryOperator<TSource> op = new ElementAtQueryOperator<TSource>(source, index); TSource result; if (op.Aggregate(out result!, false)) { return result; } throw new ArgumentOutOfRangeException(nameof(index)); } /// <summary> /// Returns the element at a specified index in a parallel sequence or a default value if the /// index is out of range. /// </summary> /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">A sequence to return an element from.</param> /// <param name="index">The zero-based index of the element to retrieve.</param> /// <returns> /// default(<B>TSource</B>) if the index is outside the bounds of the source sequence; /// otherwise, the element at the specified position in the source sequence. /// </returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="source"/> is a null reference (Nothing in Visual Basic). /// </exception> /// <exception cref="System.AggregateException"> /// One or more exceptions occurred during the evaluation of the query. /// </exception> /// <exception cref="System.OperationCanceledException"> /// The query was canceled. /// </exception> public static TSource? ElementAtOrDefault<TSource>(this ParallelQuery<TSource> source!!, int index) { // @PERF: there are obvious optimization opportunities for indexable data sources, // since we can just seek to the element requested. if (index >= 0) { ElementAtQueryOperator<TSource> op = new ElementAtQueryOperator<TSource>(source, index); TSource result; if (op.Aggregate(out result!, true)) { return result; } } return default; } } }
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/mono/mono/eglib/test/ptrarray.c
#include <stdio.h> #include <glib.h> #include "test.h" /* Redefine the private structure only to verify proper allocations */ typedef struct _GPtrArrayPriv { gpointer *pdata; guint len; guint size; } GPtrArrayPriv; /* Don't add more than 32 items to this please */ static const char *items [] = { "Apples", "Oranges", "Plumbs", "Goats", "Snorps", "Grapes", "Tickle", "Place", "Coffee", "Cookies", "Cake", "Cheese", "Tseng", "Holiday", "Avenue", "Smashing", "Water", "Toilet", NULL }; static GPtrArray *ptrarray_alloc_and_fill(guint *item_count) { GPtrArray *array = g_ptr_array_new(); gint i; for(i = 0; items[i] != NULL; i++) { g_ptr_array_add(array, (gpointer)items[i]); } if (item_count != NULL) { *item_count = i; } return array; } static guint guess_size(guint length) { guint size = 1; while (size < length) { size <<= 1; } return size; } static RESULT ptrarray_alloc (void) { GPtrArrayPriv *array; guint i; array = (GPtrArrayPriv *)ptrarray_alloc_and_fill(&i); if (array->size != guess_size(array->len)) { return FAILED("Size should be %d, but it is %d", guess_size(array->len), array->size); } if (array->len != i) { return FAILED("Expected %d node(s) in the array", i); } g_ptr_array_free((GPtrArray *)array, TRUE); return OK; } static RESULT ptrarray_for_iterate (void) { GPtrArray *array = ptrarray_alloc_and_fill(NULL); guint i; for (i = 0; i < array->len; i++) { char *item = (char *)g_ptr_array_index(array, i); if (item != items[i]) { return FAILED( "Expected item at %d to be %s, but it was %s", i, items[i], item); } } g_ptr_array_free(array, TRUE); return OK; } static gint foreach_iterate_index = 0; static char *foreach_iterate_error = NULL; static void foreach_callback (gpointer data, gpointer user_data) { char *item = (char *)data; const char *item_cmp = items[foreach_iterate_index++]; if (foreach_iterate_error != NULL) { return; } if (item != item_cmp) { foreach_iterate_error = FAILED( "Expected item at %d to be %s, but it was %s", foreach_iterate_index - 1, item_cmp, item); } } static RESULT ptrarray_foreach_iterate (void) { GPtrArray *array = ptrarray_alloc_and_fill(NULL); foreach_iterate_index = 0; foreach_iterate_error = NULL; g_ptr_array_foreach(array, foreach_callback, array); g_ptr_array_free(array, TRUE); return foreach_iterate_error; } static RESULT ptrarray_set_size (void) { GPtrArray *array = g_ptr_array_new(); guint i, grow_length = 50; g_ptr_array_add(array, (gpointer)items[0]); g_ptr_array_add(array, (gpointer)items[1]); g_ptr_array_set_size(array, grow_length); if (array->len != grow_length) { return FAILED("Array length should be 50, it is %d", array->len); } else if (array->pdata[0] != items[0]) { return FAILED("Item 0 was overwritten, should be %s", items[0]); } else if (array->pdata[1] != items[1]) { return FAILED("Item 1 was overwritten, should be %s", items[1]); } for (i = 2; i < array->len; i++) { if (array->pdata[i] != NULL) { return FAILED("Item %d is not NULL, it is %p", i, array->pdata[i]); } } g_ptr_array_free(array, TRUE); return OK; } static RESULT ptrarray_remove_index (void) { GPtrArray *array; guint i; array = ptrarray_alloc_and_fill(&i); g_ptr_array_remove_index(array, 0); if (array->pdata[0] != items[1]) { return FAILED("First item is not %s, it is %s", items[1], array->pdata[0]); } g_ptr_array_remove_index(array, array->len - 1); if (array->pdata[array->len - 1] != items[array->len]) { return FAILED("Last item is not %s, it is %s", items[array->len - 2], array->pdata[array->len - 1]); } g_ptr_array_free(array, TRUE); return OK; } static RESULT ptrarray_remove_index_fast (void) { GPtrArray *array; guint i; array = ptrarray_alloc_and_fill(&i); g_ptr_array_remove_index_fast(array, 0); if (array->pdata[0] != items[array->len]) { return FAILED("First item is not %s, it is %s", items[array->len], array->pdata[0]); } g_ptr_array_remove_index_fast(array, array->len - 1); if (array->pdata[array->len - 1] != items[array->len - 1]) { return FAILED("Last item is not %s, it is %s", items[array->len - 1], array->pdata[array->len - 1]); } g_ptr_array_free(array, TRUE); return OK; } static RESULT ptrarray_remove (void) { GPtrArray *array; guint i; array = ptrarray_alloc_and_fill(&i); g_ptr_array_remove(array, (gpointer)items[7]); if (!g_ptr_array_remove(array, (gpointer)items[4])) { return FAILED("Item %s not removed", items[4]); } if (g_ptr_array_remove(array, (gpointer)items[4])) { return FAILED("Item %s still in array after removal", items[4]); } if (array->pdata[array->len - 1] != items[array->len + 1]) { return FAILED("Last item in GPtrArray not correct"); } g_ptr_array_free(array, TRUE); return OK; } static gint ptrarray_sort_compare (gconstpointer a, gconstpointer b) { gchar *stra = *(gchar **) a; gchar *strb = *(gchar **) b; return strcmp(stra, strb); } static RESULT ptrarray_sort (void) { GPtrArray *array = g_ptr_array_new(); guint i; static gchar * const letters [] = { (char*)"A", (char*)"B", (char*)"C", (char*)"D", (char*)"E" }; g_ptr_array_add(array, letters[0]); g_ptr_array_add(array, letters[1]); g_ptr_array_add(array, letters[2]); g_ptr_array_add(array, letters[3]); g_ptr_array_add(array, letters[4]); g_ptr_array_sort(array, ptrarray_sort_compare); for (i = 0; i < array->len; i++) { if (array->pdata[i] != letters[i]) { return FAILED("Array out of order, expected %s got %s at position %d", letters [i], (gchar *) array->pdata [i], i); } } g_ptr_array_free(array, TRUE); return OK; } static gint ptrarray_sort_compare_with_data (gconstpointer a, gconstpointer b, gpointer user_data) { gchar *stra = *(gchar **) a; gchar *strb = *(gchar **) b; if (strcmp (user_data, "this is the data for qsort") != 0) fprintf (stderr, "oops at compare with_data\n"); return strcmp(stra, strb); } static RESULT ptrarray_remove_fast (void) { GPtrArray *array = g_ptr_array_new(); static gchar * const letters [] = { (char*)"A", (char*)"B", (char*)"C", (char*)"D", (char*)"E" }; if (g_ptr_array_remove_fast (array, NULL)) return FAILED ("Removing NULL succeeded"); g_ptr_array_add(array, letters[0]); if (!g_ptr_array_remove_fast (array, letters[0]) || array->len != 0) return FAILED ("Removing last element failed"); g_ptr_array_add(array, letters[0]); g_ptr_array_add(array, letters[1]); g_ptr_array_add(array, letters[2]); g_ptr_array_add(array, letters[3]); g_ptr_array_add(array, letters[4]); if (!g_ptr_array_remove_fast (array, letters[0]) || array->len != 4) return FAILED ("Removing first element failed"); if (array->pdata [0] != letters [4]) return FAILED ("First element wasn't replaced with last upon removal"); if (g_ptr_array_remove_fast (array, letters[0])) return FAILED ("Succedeed removing a non-existing element"); if (!g_ptr_array_remove_fast (array, letters[3]) || array->len != 3) return FAILED ("Failed removing \"D\""); if (!g_ptr_array_remove_fast (array, letters[1]) || array->len != 2) return FAILED ("Failed removing \"B\""); if (array->pdata [0] != letters [4] || array->pdata [1] != letters [2]) return FAILED ("Last two elements are wrong"); g_ptr_array_free(array, TRUE); return OK; } static Test ptrarray_tests [] = { {"alloc", ptrarray_alloc}, {"for_iterate", ptrarray_for_iterate}, {"foreach_iterate", ptrarray_foreach_iterate}, {"set_size", ptrarray_set_size}, {"remove_index", ptrarray_remove_index}, {"remove_index_fast", ptrarray_remove_index_fast}, {"remove", ptrarray_remove}, {"sort", ptrarray_sort}, {"remove_fast", ptrarray_remove_fast}, {NULL, NULL} }; DEFINE_TEST_GROUP_INIT(ptrarray_tests_init, ptrarray_tests)
#include <stdio.h> #include <glib.h> #include "test.h" /* Redefine the private structure only to verify proper allocations */ typedef struct _GPtrArrayPriv { gpointer *pdata; guint len; guint size; } GPtrArrayPriv; /* Don't add more than 32 items to this please */ static const char *items [] = { "Apples", "Oranges", "Plumbs", "Goats", "Snorps", "Grapes", "Tickle", "Place", "Coffee", "Cookies", "Cake", "Cheese", "Tseng", "Holiday", "Avenue", "Smashing", "Water", "Toilet", NULL }; static GPtrArray *ptrarray_alloc_and_fill(guint *item_count) { GPtrArray *array = g_ptr_array_new(); gint i; for(i = 0; items[i] != NULL; i++) { g_ptr_array_add(array, (gpointer)items[i]); } if (item_count != NULL) { *item_count = i; } return array; } static guint guess_size(guint length) { guint size = 1; while (size < length) { size <<= 1; } return size; } static RESULT ptrarray_alloc (void) { GPtrArrayPriv *array; guint i; array = (GPtrArrayPriv *)ptrarray_alloc_and_fill(&i); if (array->size != guess_size(array->len)) { return FAILED("Size should be %d, but it is %d", guess_size(array->len), array->size); } if (array->len != i) { return FAILED("Expected %d node(s) in the array", i); } g_ptr_array_free((GPtrArray *)array, TRUE); return OK; } static RESULT ptrarray_for_iterate (void) { GPtrArray *array = ptrarray_alloc_and_fill(NULL); guint i; for (i = 0; i < array->len; i++) { char *item = (char *)g_ptr_array_index(array, i); if (item != items[i]) { return FAILED( "Expected item at %d to be %s, but it was %s", i, items[i], item); } } g_ptr_array_free(array, TRUE); return OK; } static gint foreach_iterate_index = 0; static char *foreach_iterate_error = NULL; static void foreach_callback (gpointer data, gpointer user_data) { char *item = (char *)data; const char *item_cmp = items[foreach_iterate_index++]; if (foreach_iterate_error != NULL) { return; } if (item != item_cmp) { foreach_iterate_error = FAILED( "Expected item at %d to be %s, but it was %s", foreach_iterate_index - 1, item_cmp, item); } } static RESULT ptrarray_foreach_iterate (void) { GPtrArray *array = ptrarray_alloc_and_fill(NULL); foreach_iterate_index = 0; foreach_iterate_error = NULL; g_ptr_array_foreach(array, foreach_callback, array); g_ptr_array_free(array, TRUE); return foreach_iterate_error; } static RESULT ptrarray_set_size (void) { GPtrArray *array = g_ptr_array_new(); guint i, grow_length = 50; g_ptr_array_add(array, (gpointer)items[0]); g_ptr_array_add(array, (gpointer)items[1]); g_ptr_array_set_size(array, grow_length); if (array->len != grow_length) { return FAILED("Array length should be 50, it is %d", array->len); } else if (array->pdata[0] != items[0]) { return FAILED("Item 0 was overwritten, should be %s", items[0]); } else if (array->pdata[1] != items[1]) { return FAILED("Item 1 was overwritten, should be %s", items[1]); } for (i = 2; i < array->len; i++) { if (array->pdata[i] != NULL) { return FAILED("Item %d is not NULL, it is %p", i, array->pdata[i]); } } g_ptr_array_free(array, TRUE); return OK; } static RESULT ptrarray_remove_index (void) { GPtrArray *array; guint i; array = ptrarray_alloc_and_fill(&i); g_ptr_array_remove_index(array, 0); if (array->pdata[0] != items[1]) { return FAILED("First item is not %s, it is %s", items[1], array->pdata[0]); } g_ptr_array_remove_index(array, array->len - 1); if (array->pdata[array->len - 1] != items[array->len]) { return FAILED("Last item is not %s, it is %s", items[array->len - 2], array->pdata[array->len - 1]); } g_ptr_array_free(array, TRUE); return OK; } static RESULT ptrarray_remove_index_fast (void) { GPtrArray *array; guint i; array = ptrarray_alloc_and_fill(&i); g_ptr_array_remove_index_fast(array, 0); if (array->pdata[0] != items[array->len]) { return FAILED("First item is not %s, it is %s", items[array->len], array->pdata[0]); } g_ptr_array_remove_index_fast(array, array->len - 1); if (array->pdata[array->len - 1] != items[array->len - 1]) { return FAILED("Last item is not %s, it is %s", items[array->len - 1], array->pdata[array->len - 1]); } g_ptr_array_free(array, TRUE); return OK; } static RESULT ptrarray_remove (void) { GPtrArray *array; guint i; array = ptrarray_alloc_and_fill(&i); g_ptr_array_remove(array, (gpointer)items[7]); if (!g_ptr_array_remove(array, (gpointer)items[4])) { return FAILED("Item %s not removed", items[4]); } if (g_ptr_array_remove(array, (gpointer)items[4])) { return FAILED("Item %s still in array after removal", items[4]); } if (array->pdata[array->len - 1] != items[array->len + 1]) { return FAILED("Last item in GPtrArray not correct"); } g_ptr_array_free(array, TRUE); return OK; } static gint ptrarray_sort_compare (gconstpointer a, gconstpointer b) { gchar *stra = *(gchar **) a; gchar *strb = *(gchar **) b; return strcmp(stra, strb); } static RESULT ptrarray_sort (void) { GPtrArray *array = g_ptr_array_new(); guint i; static gchar * const letters [] = { (char*)"A", (char*)"B", (char*)"C", (char*)"D", (char*)"E" }; g_ptr_array_add(array, letters[0]); g_ptr_array_add(array, letters[1]); g_ptr_array_add(array, letters[2]); g_ptr_array_add(array, letters[3]); g_ptr_array_add(array, letters[4]); g_ptr_array_sort(array, ptrarray_sort_compare); for (i = 0; i < array->len; i++) { if (array->pdata[i] != letters[i]) { return FAILED("Array out of order, expected %s got %s at position %d", letters [i], (gchar *) array->pdata [i], i); } } g_ptr_array_free(array, TRUE); return OK; } static gint ptrarray_sort_compare_with_data (gconstpointer a, gconstpointer b, gpointer user_data) { gchar *stra = *(gchar **) a; gchar *strb = *(gchar **) b; if (strcmp (user_data, "this is the data for qsort") != 0) fprintf (stderr, "oops at compare with_data\n"); return strcmp(stra, strb); } static RESULT ptrarray_remove_fast (void) { GPtrArray *array = g_ptr_array_new(); static gchar * const letters [] = { (char*)"A", (char*)"B", (char*)"C", (char*)"D", (char*)"E" }; if (g_ptr_array_remove_fast (array, NULL)) return FAILED ("Removing NULL succeeded"); g_ptr_array_add(array, letters[0]); if (!g_ptr_array_remove_fast (array, letters[0]) || array->len != 0) return FAILED ("Removing last element failed"); g_ptr_array_add(array, letters[0]); g_ptr_array_add(array, letters[1]); g_ptr_array_add(array, letters[2]); g_ptr_array_add(array, letters[3]); g_ptr_array_add(array, letters[4]); if (!g_ptr_array_remove_fast (array, letters[0]) || array->len != 4) return FAILED ("Removing first element failed"); if (array->pdata [0] != letters [4]) return FAILED ("First element wasn't replaced with last upon removal"); if (g_ptr_array_remove_fast (array, letters[0])) return FAILED ("Succedeed removing a non-existing element"); if (!g_ptr_array_remove_fast (array, letters[3]) || array->len != 3) return FAILED ("Failed removing \"D\""); if (!g_ptr_array_remove_fast (array, letters[1]) || array->len != 2) return FAILED ("Failed removing \"B\""); if (array->pdata [0] != letters [4] || array->pdata [1] != letters [2]) return FAILED ("Last two elements are wrong"); g_ptr_array_free(array, TRUE); return OK; } static Test ptrarray_tests [] = { {"alloc", ptrarray_alloc}, {"for_iterate", ptrarray_for_iterate}, {"foreach_iterate", ptrarray_foreach_iterate}, {"set_size", ptrarray_set_size}, {"remove_index", ptrarray_remove_index}, {"remove_index_fast", ptrarray_remove_index_fast}, {"remove", ptrarray_remove}, {"sort", ptrarray_sort}, {"remove_fast", ptrarray_remove_fast}, {NULL, NULL} }; DEFINE_TEST_GROUP_INIT(ptrarray_tests_init, ptrarray_tests)
-1
dotnet/runtime
66,026
Adding Count(ReadOnlySpan<char>) Overloads
fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
joperezr
2022-03-01T20:29:46Z
2022-03-08T01:39:21Z
bc822868822f0206a1fa1f01c61f9b2d78bc9ac0
0da5545eb6d3363b503eb04622911f2d5f6d0283
Adding Count(ReadOnlySpan<char>) Overloads. fixes https://github.com/dotnet/runtime/issues/61425 This adds the remaining overloads for Count which work over the passed in span. cc: @stephentoub @danmoseley
./src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonClassDataContract.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.Threading; using System.Xml; using System.Diagnostics; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Diagnostics.CodeAnalysis; namespace System.Runtime.Serialization.Json { internal sealed class JsonClassDataContract : JsonDataContract { private readonly JsonClassDataContractCriticalHelper _helper; [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public JsonClassDataContract(ClassDataContract traditionalDataContract) : base(new JsonClassDataContractCriticalHelper(traditionalDataContract)) { _helper = (base.Helper as JsonClassDataContractCriticalHelper)!; } internal JsonFormatClassReaderDelegate JsonFormatReaderDelegate { [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] get { if (_helper.JsonFormatReaderDelegate == null) { lock (this) { if (_helper.JsonFormatReaderDelegate == null) { JsonFormatClassReaderDelegate tempDelegate; if (DataContractSerializer.Option == SerializationOption.ReflectionOnly) { tempDelegate = new ReflectionJsonClassReader(TraditionalClassDataContract).ReflectionReadClass; } else { tempDelegate = new JsonFormatReaderGenerator().GenerateClassReader(TraditionalClassDataContract); } Interlocked.MemoryBarrier(); _helper.JsonFormatReaderDelegate = tempDelegate; } } } return _helper.JsonFormatReaderDelegate; } } internal JsonFormatClassWriterDelegate JsonFormatWriterDelegate { [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] get { if (_helper.JsonFormatWriterDelegate == null) { lock (this) { if (_helper.JsonFormatWriterDelegate == null) { JsonFormatClassWriterDelegate tempDelegate; if (DataContractSerializer.Option == SerializationOption.ReflectionOnly) { tempDelegate = new ReflectionJsonFormatWriter().ReflectionWriteClass; } else { tempDelegate = new JsonFormatWriterGenerator().GenerateClassWriter(TraditionalClassDataContract); } Interlocked.MemoryBarrier(); _helper.JsonFormatWriterDelegate = tempDelegate; } } } return _helper.JsonFormatWriterDelegate; } } internal XmlDictionaryString[]? MemberNames => _helper.MemberNames; internal override string TypeName => _helper.TypeName; private ClassDataContract TraditionalClassDataContract => _helper.TraditionalClassDataContract; [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public override object? ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson? context) { jsonReader.Read(); object o = JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, MemberNames); jsonReader.ReadEndElement(); return o; } [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson? context, RuntimeTypeHandle declaredTypeHandle) { Debug.Assert(context != null); jsonWriter.WriteAttributeString(null, JsonGlobals.typeString, null, JsonGlobals.objectString); JsonFormatWriterDelegate(jsonWriter, obj, context, TraditionalClassDataContract, MemberNames); } private sealed class JsonClassDataContractCriticalHelper : JsonDataContractCriticalHelper { private JsonFormatClassReaderDelegate? _jsonFormatReaderDelegate; private JsonFormatClassWriterDelegate? _jsonFormatWriterDelegate; private XmlDictionaryString[]? _memberNames; private readonly ClassDataContract _traditionalClassDataContract; private readonly string _typeName; [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public JsonClassDataContractCriticalHelper(ClassDataContract traditionalDataContract) : base(traditionalDataContract) { _typeName = string.IsNullOrEmpty(traditionalDataContract.Namespace.Value) ? traditionalDataContract.Name.Value : string.Concat(traditionalDataContract.Name.Value, JsonGlobals.NameValueSeparatorString, XmlObjectSerializerWriteContextComplexJson.TruncateDefaultDataContractNamespace(traditionalDataContract.Namespace.Value)); _traditionalClassDataContract = traditionalDataContract; CopyMembersAndCheckDuplicateNames(); } internal JsonFormatClassReaderDelegate? JsonFormatReaderDelegate { get { return _jsonFormatReaderDelegate; } set { _jsonFormatReaderDelegate = value; } } internal JsonFormatClassWriterDelegate? JsonFormatWriterDelegate { get { return _jsonFormatWriterDelegate; } set { _jsonFormatWriterDelegate = value; } } internal XmlDictionaryString[]? MemberNames { get { return _memberNames; } } internal ClassDataContract TraditionalClassDataContract { get { return _traditionalClassDataContract; } } private void CopyMembersAndCheckDuplicateNames() { if (_traditionalClassDataContract.MemberNames != null) { int memberCount = _traditionalClassDataContract.MemberNames.Length; Dictionary<string, object?> memberTable = new Dictionary<string, object?>(memberCount); XmlDictionaryString[] decodedMemberNames = new XmlDictionaryString[memberCount]; for (int i = 0; i < memberCount; i++) { if (memberTable.ContainsKey(_traditionalClassDataContract.MemberNames[i].Value)) { throw new SerializationException(SR.Format(SR.JsonDuplicateMemberNames, DataContract.GetClrTypeFullName(_traditionalClassDataContract.UnderlyingType), _traditionalClassDataContract.MemberNames[i].Value)); } else { memberTable.Add(_traditionalClassDataContract.MemberNames[i].Value, null); decodedMemberNames[i] = DataContractJsonSerializer.ConvertXmlNameToJsonName(_traditionalClassDataContract.MemberNames[i]); } } _memberNames = decodedMemberNames; } } } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Threading; using System.Xml; using System.Diagnostics; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Diagnostics.CodeAnalysis; namespace System.Runtime.Serialization.Json { internal sealed class JsonClassDataContract : JsonDataContract { private readonly JsonClassDataContractCriticalHelper _helper; [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public JsonClassDataContract(ClassDataContract traditionalDataContract) : base(new JsonClassDataContractCriticalHelper(traditionalDataContract)) { _helper = (base.Helper as JsonClassDataContractCriticalHelper)!; } internal JsonFormatClassReaderDelegate JsonFormatReaderDelegate { [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] get { if (_helper.JsonFormatReaderDelegate == null) { lock (this) { if (_helper.JsonFormatReaderDelegate == null) { JsonFormatClassReaderDelegate tempDelegate; if (DataContractSerializer.Option == SerializationOption.ReflectionOnly) { tempDelegate = new ReflectionJsonClassReader(TraditionalClassDataContract).ReflectionReadClass; } else { tempDelegate = new JsonFormatReaderGenerator().GenerateClassReader(TraditionalClassDataContract); } Interlocked.MemoryBarrier(); _helper.JsonFormatReaderDelegate = tempDelegate; } } } return _helper.JsonFormatReaderDelegate; } } internal JsonFormatClassWriterDelegate JsonFormatWriterDelegate { [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] get { if (_helper.JsonFormatWriterDelegate == null) { lock (this) { if (_helper.JsonFormatWriterDelegate == null) { JsonFormatClassWriterDelegate tempDelegate; if (DataContractSerializer.Option == SerializationOption.ReflectionOnly) { tempDelegate = new ReflectionJsonFormatWriter().ReflectionWriteClass; } else { tempDelegate = new JsonFormatWriterGenerator().GenerateClassWriter(TraditionalClassDataContract); } Interlocked.MemoryBarrier(); _helper.JsonFormatWriterDelegate = tempDelegate; } } } return _helper.JsonFormatWriterDelegate; } } internal XmlDictionaryString[]? MemberNames => _helper.MemberNames; internal override string TypeName => _helper.TypeName; private ClassDataContract TraditionalClassDataContract => _helper.TraditionalClassDataContract; [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public override object? ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson? context) { jsonReader.Read(); object o = JsonFormatReaderDelegate(jsonReader, context, XmlDictionaryString.Empty, MemberNames); jsonReader.ReadEndElement(); return o; } [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson? context, RuntimeTypeHandle declaredTypeHandle) { Debug.Assert(context != null); jsonWriter.WriteAttributeString(null, JsonGlobals.typeString, null, JsonGlobals.objectString); JsonFormatWriterDelegate(jsonWriter, obj, context, TraditionalClassDataContract, MemberNames); } private sealed class JsonClassDataContractCriticalHelper : JsonDataContractCriticalHelper { private JsonFormatClassReaderDelegate? _jsonFormatReaderDelegate; private JsonFormatClassWriterDelegate? _jsonFormatWriterDelegate; private XmlDictionaryString[]? _memberNames; private readonly ClassDataContract _traditionalClassDataContract; private readonly string _typeName; [RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)] public JsonClassDataContractCriticalHelper(ClassDataContract traditionalDataContract) : base(traditionalDataContract) { _typeName = string.IsNullOrEmpty(traditionalDataContract.Namespace.Value) ? traditionalDataContract.Name.Value : string.Concat(traditionalDataContract.Name.Value, JsonGlobals.NameValueSeparatorString, XmlObjectSerializerWriteContextComplexJson.TruncateDefaultDataContractNamespace(traditionalDataContract.Namespace.Value)); _traditionalClassDataContract = traditionalDataContract; CopyMembersAndCheckDuplicateNames(); } internal JsonFormatClassReaderDelegate? JsonFormatReaderDelegate { get { return _jsonFormatReaderDelegate; } set { _jsonFormatReaderDelegate = value; } } internal JsonFormatClassWriterDelegate? JsonFormatWriterDelegate { get { return _jsonFormatWriterDelegate; } set { _jsonFormatWriterDelegate = value; } } internal XmlDictionaryString[]? MemberNames { get { return _memberNames; } } internal ClassDataContract TraditionalClassDataContract { get { return _traditionalClassDataContract; } } private void CopyMembersAndCheckDuplicateNames() { if (_traditionalClassDataContract.MemberNames != null) { int memberCount = _traditionalClassDataContract.MemberNames.Length; Dictionary<string, object?> memberTable = new Dictionary<string, object?>(memberCount); XmlDictionaryString[] decodedMemberNames = new XmlDictionaryString[memberCount]; for (int i = 0; i < memberCount; i++) { if (memberTable.ContainsKey(_traditionalClassDataContract.MemberNames[i].Value)) { throw new SerializationException(SR.Format(SR.JsonDuplicateMemberNames, DataContract.GetClrTypeFullName(_traditionalClassDataContract.UnderlyingType), _traditionalClassDataContract.MemberNames[i].Value)); } else { memberTable.Add(_traditionalClassDataContract.MemberNames[i].Value, null); decodedMemberNames[i] = DataContractJsonSerializer.ConvertXmlNameToJsonName(_traditionalClassDataContract.MemberNames[i]); } } _memberNames = decodedMemberNames; } } } } }
-1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.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; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { // Note that we make a T[] (single-dimensional w/ zero as the lower bound) implement both // IList<U> and IReadOnlyList<U>, where T : U dynamically. See the SZArrayHelper class for details. public abstract partial class Array : ICloneable, IList, IStructuralComparable, IStructuralEquatable { // Create instance will create an array [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, int length) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); return InternalCreate((void*)t.TypeHandle.Value, 1, &length, null); } public static unsafe Array CreateInstance(Type elementType, int length1, int length2) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length1 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length2 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); int* pLengths = stackalloc int[2]; pLengths[0] = length1; pLengths[1] = length2; return InternalCreate((void*)t.TypeHandle.Value, 2, pLengths, null); } public static unsafe Array CreateInstance(Type elementType, int length1, int length2, int length3) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length1 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length2 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length3 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length3, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); int* pLengths = stackalloc int[3]; pLengths[0] = length1; pLengths[1] = length2; pLengths[2] = length3; return InternalCreate((void*)t.TypeHandle.Value, 3, pLengths, null); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, params int[] lengths) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (lengths == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths); if (lengths.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); // Check to make sure the lengths are all positive. Note that we check this here to give // a good exception message if they are not; however we check this again inside the execution // engine's low level allocation function after having made a copy of the array to prevent a // malicious caller from mutating the array after this check. for (int i = 0; i < lengths.Length; i++) if (lengths[i] < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); fixed (int* pLengths = &lengths[0]) return InternalCreate((void*)t.TypeHandle.Value, lengths.Length, pLengths, null); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, int[] lengths, int[] lowerBounds) { if (elementType == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (lengths == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths); if (lowerBounds == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lowerBounds); if (lengths.Length != lowerBounds!.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RanksAndBounds); if (lengths.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); // Check to make sure the lenghts are all positive. Note that we check this here to give // a good exception message if they are not; however we check this again inside the execution // engine's low level allocation function after having made a copy of the array to prevent a // malicious caller from mutating the array after this check. for (int i = 0; i < lengths.Length; i++) if (lengths[i] < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); fixed (int* pLengths = &lengths[0]) fixed (int* pLowerBounds = &lowerBounds[0]) return InternalCreate((void*)t.TypeHandle.Value, lengths.Length, pLengths, pLowerBounds); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern unsafe Array InternalCreate(void* elementType, int rank, int* pLengths, int* pLowerBounds); // Copies length elements from sourceArray, starting at index 0, to // destinationArray, starting at index 0. // public static unsafe void Copy(Array sourceArray, Array destinationArray, int length) { if (sourceArray == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray); if (destinationArray == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray); MethodTable* pMT = RuntimeHelpers.GetMethodTable(sourceArray); if (pMT == RuntimeHelpers.GetMethodTable(destinationArray) && !pMT->IsMultiDimensionalArray && (uint)length <= sourceArray.NativeLength && (uint)length <= destinationArray.NativeLength) { nuint byteCount = (uint)length * (nuint)pMT->ComponentSize; ref byte src = ref Unsafe.As<RawArrayData>(sourceArray).Data; ref byte dst = ref Unsafe.As<RawArrayData>(destinationArray).Data; if (pMT->ContainsGCPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } // Less common Copy(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length, reliable: false); } // Copies length elements from sourceArray, starting at sourceIndex, to // destinationArray, starting at destinationIndex. // public static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { if (sourceArray != null && destinationArray != null) { MethodTable* pMT = RuntimeHelpers.GetMethodTable(sourceArray); if (pMT == RuntimeHelpers.GetMethodTable(destinationArray) && !pMT->IsMultiDimensionalArray && length >= 0 && sourceIndex >= 0 && destinationIndex >= 0 && (uint)(sourceIndex + length) <= sourceArray.NativeLength && (uint)(destinationIndex + length) <= destinationArray.NativeLength) { nuint elementSize = (nuint)pMT->ComponentSize; nuint byteCount = (uint)length * elementSize; ref byte src = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(sourceArray).Data, (uint)sourceIndex * elementSize); ref byte dst = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(destinationArray).Data, (uint)destinationIndex * elementSize); if (pMT->ContainsGCPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } } // Less common Copy(sourceArray!, sourceIndex, destinationArray!, destinationIndex, length, reliable: false); } private static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { if (sourceArray == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray); if (destinationArray == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray); if (sourceArray.GetType() != destinationArray.GetType() && sourceArray.Rank != destinationArray.Rank) throw new RankException(SR.Rank_MustMatch); if (length < 0) throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum); int srcLB = sourceArray.GetLowerBound(0); if (sourceIndex < srcLB || sourceIndex - srcLB < 0) throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_ArrayLB); sourceIndex -= srcLB; int dstLB = destinationArray.GetLowerBound(0); if (destinationIndex < dstLB || destinationIndex - dstLB < 0) throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_ArrayLB); destinationIndex -= dstLB; if ((uint)(sourceIndex + length) > sourceArray.NativeLength) throw new ArgumentException(SR.Arg_LongerThanSrcArray, nameof(sourceArray)); if ((uint)(destinationIndex + length) > destinationArray.NativeLength) throw new ArgumentException(SR.Arg_LongerThanDestArray, nameof(destinationArray)); if (sourceArray.GetType() == destinationArray.GetType() || IsSimpleCopy(sourceArray, destinationArray)) { MethodTable* pMT = RuntimeHelpers.GetMethodTable(sourceArray); nuint elementSize = (nuint)pMT->ComponentSize; nuint byteCount = (uint)length * elementSize; ref byte src = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(sourceArray), (uint)sourceIndex * elementSize); ref byte dst = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(destinationArray), (uint)destinationIndex * elementSize); if (pMT->ContainsGCPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } // If we were called from Array.ConstrainedCopy, ensure that the array copy // is guaranteed to succeed. if (reliable) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_ConstrainedCopy); // Rare CopySlow(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool IsSimpleCopy(Array sourceArray, Array destinationArray); // Reliability-wise, this method will either possibly corrupt your // instance & might fail when called from within a CER, or if the // reliable flag is true, it will either always succeed or always // throw an exception with no side effects. [MethodImpl(MethodImplOptions.InternalCall)] private static extern void CopySlow(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length); // Provides a strong exception guarantee - either it succeeds, or // it throws an exception with no side effects. The arrays must be // compatible array types based on the array element type - this // method does not support casting, boxing, or primitive widening. // It will up-cast, assuming the array types are correct. public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable: true); } /// <summary> /// Clears the contents of an array. /// </summary> /// <param name="array">The array to clear.</param> /// <exception cref="ArgumentNullException"><paramref name="array"/> is null.</exception> public static unsafe void Clear(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); MethodTable* pMT = RuntimeHelpers.GetMethodTable(array); nuint totalByteLength = pMT->ComponentSize * array.NativeLength; ref byte pStart = ref MemoryMarshal.GetArrayDataReference(array); if (!pMT->ContainsGCPointers) { SpanHelpers.ClearWithoutReferences(ref pStart, totalByteLength); } else { Debug.Assert(totalByteLength % (nuint)sizeof(IntPtr) == 0); SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref pStart), totalByteLength / (nuint)sizeof(IntPtr)); } // GC.KeepAlive(array) not required. pMT kept alive via `pStart` } // Sets length elements in array to 0 (or null for Object arrays), starting // at index. // public static unsafe void Clear(Array array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); ref byte p = ref Unsafe.As<RawArrayData>(array).Data; int lowerBound = 0; MethodTable* pMT = RuntimeHelpers.GetMethodTable(array); if (pMT->IsMultiDimensionalArray) { int rank = pMT->MultiDimensionalArrayRank; lowerBound = Unsafe.Add(ref Unsafe.As<byte, int>(ref p), rank); p = ref Unsafe.Add(ref p, 2 * sizeof(int) * rank); // skip the bounds } int offset = index - lowerBound; if (index < lowerBound || offset < 0 || length < 0 || (uint)(offset + length) > array.NativeLength) ThrowHelper.ThrowIndexOutOfRangeException(); nuint elementSize = pMT->ComponentSize; ref byte ptr = ref Unsafe.AddByteOffset(ref p, (uint)offset * elementSize); nuint byteLength = (uint)length * elementSize; if (pMT->ContainsGCPointers) SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); else SpanHelpers.ClearWithoutReferences(ref ptr, byteLength); // GC.KeepAlive(array) not required. pMT kept alive via `ptr` } private unsafe nint GetFlattenedIndex(ReadOnlySpan<int> indices) { // Checked by the caller Debug.Assert(indices.Length == Rank); if (RuntimeHelpers.GetMethodTable(this)->IsMultiDimensionalArray) { ref int bounds = ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this); nint flattenedIndex = 0; for (int i = 0; i < indices.Length; i++) { int index = indices[i] - Unsafe.Add(ref bounds, indices.Length + i); int length = Unsafe.Add(ref bounds, i); if ((uint)index >= (uint)length) ThrowHelper.ThrowIndexOutOfRangeException(); flattenedIndex = (length * flattenedIndex) + index; } Debug.Assert((nuint)flattenedIndex < (nuint)LongLength); return flattenedIndex; } else { int index = indices[0]; if ((uint)index >= (uint)LongLength) ThrowHelper.ThrowIndexOutOfRangeException(); return index; } } [MethodImpl(MethodImplOptions.InternalCall)] internal extern unsafe object? InternalGetValue(nint flattenedIndex); [MethodImpl(MethodImplOptions.InternalCall)] private extern void InternalSetValue(object? value, nint flattenedIndex); public int Length => checked((int)Unsafe.As<RawArrayData>(this).Length); // This could return a length greater than int.MaxValue internal nuint NativeLength => Unsafe.As<RawArrayData>(this).Length; public long LongLength => (long)NativeLength; public unsafe int Rank { get { int rank = RuntimeHelpers.GetMultiDimensionalArrayRank(this); return (rank != 0) ? rank : 1; } } [Intrinsic] public unsafe int GetLength(int dimension) { int rank = RuntimeHelpers.GetMultiDimensionalArrayRank(this); if (rank == 0 && dimension == 0) return Length; if ((uint)dimension >= (uint)rank) throw new IndexOutOfRangeException(SR.IndexOutOfRange_ArrayRankIndex); return Unsafe.Add(ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this), dimension); } [Intrinsic] public unsafe int GetUpperBound(int dimension) { int rank = RuntimeHelpers.GetMultiDimensionalArrayRank(this); if (rank == 0 && dimension == 0) return Length - 1; if ((uint)dimension >= (uint)rank) throw new IndexOutOfRangeException(SR.IndexOutOfRange_ArrayRankIndex); ref int bounds = ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this); return Unsafe.Add(ref bounds, dimension) + Unsafe.Add(ref bounds, rank + dimension) - 1; } [Intrinsic] public unsafe int GetLowerBound(int dimension) { int rank = RuntimeHelpers.GetMultiDimensionalArrayRank(this); if (rank == 0 && dimension == 0) return 0; if ((uint)dimension >= (uint)rank) throw new IndexOutOfRangeException(SR.IndexOutOfRange_ArrayRankIndex); return Unsafe.Add(ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this), rank + dimension); } [MethodImpl(MethodImplOptions.InternalCall)] internal extern CorElementType GetCorElementTypeOfElementType(); private unsafe bool IsValueOfElementType(object value) { MethodTable* thisMT = RuntimeHelpers.GetMethodTable(this); return (IntPtr)thisMT->ElementType == (IntPtr)RuntimeHelpers.GetMethodTable(value); } // if this is an array of value classes and that value class has a default constructor // then this calls this default constructor on every element in the value class array. // otherwise this is a no-op. Generally this method is called automatically by the compiler [MethodImpl(MethodImplOptions.InternalCall)] public extern void Initialize(); } #pragma warning disable CA1822 // Mark members as static //---------------------------------------------------------------------------------------- // ! READ THIS BEFORE YOU WORK ON THIS CLASS. // // The methods on this class must be written VERY carefully to avoid introducing security holes. // That's because they are invoked with special "this"! The "this" object // for all of these methods are not SZArrayHelper objects. Rather, they are of type U[] // where U[] is castable to T[]. No actual SZArrayHelper object is ever instantiated. Thus, you will // see a lot of expressions that cast "this" "T[]". // // This class is needed to allow an SZ array of type T[] to expose IList<T>, // IList<T.BaseType>, etc., etc. all the way up to IList<Object>. When the following call is // made: // // ((IList<T>) (new U[n])).SomeIListMethod() // // the interface stub dispatcher treats this as a special case, loads up SZArrayHelper, // finds the corresponding generic method (matched simply by method name), instantiates // it for type <T> and executes it. // // The "T" will reflect the interface used to invoke the method. The actual runtime "this" will be // array that is castable to "T[]" (i.e. for primitivs and valuetypes, it will be exactly // "T[]" - for orefs, it may be a "U[]" where U derives from T.) //---------------------------------------------------------------------------------------- internal sealed class SZArrayHelper { // It is never legal to instantiate this class. private SZArrayHelper() { Debug.Fail("Hey! How'd I get here?"); } internal IEnumerator<T> GetEnumerator<T>() { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); return _this.Length == 0 ? SZGenericArrayEnumerator<T>.Empty : new SZGenericArrayEnumerator<T>(_this); } private void CopyTo<T>(T[] array, int index) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); Array.Copy(_this, 0, array, index, _this.Length); } internal int get_Count<T>() { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); return _this.Length; } internal T get_Item<T>(int index) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); if ((uint)index >= (uint)_this.Length) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } return _this[index]; } internal void set_Item<T>(int index, T value) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); if ((uint)index >= (uint)_this.Length) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } _this[index] = value; } private void Add<T>(T _) { // Not meaningful for arrays. ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } private bool Contains<T>(T value) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); return Array.IndexOf(_this, value, 0, _this.Length) >= 0; } private bool get_IsReadOnly<T>() { return true; } private void Clear<T>() { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } private int IndexOf<T>(T value) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); return Array.IndexOf(_this, value, 0, _this.Length); } private void Insert<T>(int _, T _1) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } private bool Remove<T>(T _) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; } private void RemoveAt<T>(int _) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } } #pragma warning restore CA1822 }
// 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; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { // Note that we make a T[] (single-dimensional w/ zero as the lower bound) implement both // IList<U> and IReadOnlyList<U>, where T : U dynamically. See the SZArrayHelper class for details. public abstract partial class Array : ICloneable, IList, IStructuralComparable, IStructuralEquatable { [MethodImpl(MethodImplOptions.InternalCall)] private static extern unsafe Array InternalCreate(RuntimeType elementType, int rank, int* pLengths, int* pLowerBounds); // Copies length elements from sourceArray, starting at index 0, to // destinationArray, starting at index 0. // public static unsafe void Copy(Array sourceArray, Array destinationArray, int length) { if (sourceArray == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray); if (destinationArray == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray); MethodTable* pMT = RuntimeHelpers.GetMethodTable(sourceArray); if (pMT == RuntimeHelpers.GetMethodTable(destinationArray) && !pMT->IsMultiDimensionalArray && (uint)length <= sourceArray.NativeLength && (uint)length <= destinationArray.NativeLength) { nuint byteCount = (uint)length * (nuint)pMT->ComponentSize; ref byte src = ref Unsafe.As<RawArrayData>(sourceArray).Data; ref byte dst = ref Unsafe.As<RawArrayData>(destinationArray).Data; if (pMT->ContainsGCPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } // Less common Copy(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length, reliable: false); } // Copies length elements from sourceArray, starting at sourceIndex, to // destinationArray, starting at destinationIndex. // public static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { if (sourceArray != null && destinationArray != null) { MethodTable* pMT = RuntimeHelpers.GetMethodTable(sourceArray); if (pMT == RuntimeHelpers.GetMethodTable(destinationArray) && !pMT->IsMultiDimensionalArray && length >= 0 && sourceIndex >= 0 && destinationIndex >= 0 && (uint)(sourceIndex + length) <= sourceArray.NativeLength && (uint)(destinationIndex + length) <= destinationArray.NativeLength) { nuint elementSize = (nuint)pMT->ComponentSize; nuint byteCount = (uint)length * elementSize; ref byte src = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(sourceArray).Data, (uint)sourceIndex * elementSize); ref byte dst = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(destinationArray).Data, (uint)destinationIndex * elementSize); if (pMT->ContainsGCPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } } // Less common Copy(sourceArray!, sourceIndex, destinationArray!, destinationIndex, length, reliable: false); } private static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { if (sourceArray == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray); if (destinationArray == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray); if (sourceArray.GetType() != destinationArray.GetType() && sourceArray.Rank != destinationArray.Rank) throw new RankException(SR.Rank_MustMatch); if (length < 0) throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum); int srcLB = sourceArray.GetLowerBound(0); if (sourceIndex < srcLB || sourceIndex - srcLB < 0) throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_ArrayLB); sourceIndex -= srcLB; int dstLB = destinationArray.GetLowerBound(0); if (destinationIndex < dstLB || destinationIndex - dstLB < 0) throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_ArrayLB); destinationIndex -= dstLB; if ((uint)(sourceIndex + length) > sourceArray.NativeLength) throw new ArgumentException(SR.Arg_LongerThanSrcArray, nameof(sourceArray)); if ((uint)(destinationIndex + length) > destinationArray.NativeLength) throw new ArgumentException(SR.Arg_LongerThanDestArray, nameof(destinationArray)); if (sourceArray.GetType() == destinationArray.GetType() || IsSimpleCopy(sourceArray, destinationArray)) { MethodTable* pMT = RuntimeHelpers.GetMethodTable(sourceArray); nuint elementSize = (nuint)pMT->ComponentSize; nuint byteCount = (uint)length * elementSize; ref byte src = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(sourceArray), (uint)sourceIndex * elementSize); ref byte dst = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(destinationArray), (uint)destinationIndex * elementSize); if (pMT->ContainsGCPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } // If we were called from Array.ConstrainedCopy, ensure that the array copy // is guaranteed to succeed. if (reliable) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_ConstrainedCopy); // Rare CopySlow(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool IsSimpleCopy(Array sourceArray, Array destinationArray); // Reliability-wise, this method will either possibly corrupt your // instance & might fail when called from within a CER, or if the // reliable flag is true, it will either always succeed or always // throw an exception with no side effects. [MethodImpl(MethodImplOptions.InternalCall)] private static extern void CopySlow(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length); // Provides a strong exception guarantee - either it succeeds, or // it throws an exception with no side effects. The arrays must be // compatible array types based on the array element type - this // method does not support casting, boxing, or primitive widening. // It will up-cast, assuming the array types are correct. public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable: true); } /// <summary> /// Clears the contents of an array. /// </summary> /// <param name="array">The array to clear.</param> /// <exception cref="ArgumentNullException"><paramref name="array"/> is null.</exception> public static unsafe void Clear(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); MethodTable* pMT = RuntimeHelpers.GetMethodTable(array); nuint totalByteLength = pMT->ComponentSize * array.NativeLength; ref byte pStart = ref MemoryMarshal.GetArrayDataReference(array); if (!pMT->ContainsGCPointers) { SpanHelpers.ClearWithoutReferences(ref pStart, totalByteLength); } else { Debug.Assert(totalByteLength % (nuint)sizeof(IntPtr) == 0); SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref pStart), totalByteLength / (nuint)sizeof(IntPtr)); } // GC.KeepAlive(array) not required. pMT kept alive via `pStart` } // Sets length elements in array to 0 (or null for Object arrays), starting // at index. // public static unsafe void Clear(Array array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); ref byte p = ref Unsafe.As<RawArrayData>(array).Data; int lowerBound = 0; MethodTable* pMT = RuntimeHelpers.GetMethodTable(array); if (pMT->IsMultiDimensionalArray) { int rank = pMT->MultiDimensionalArrayRank; lowerBound = Unsafe.Add(ref Unsafe.As<byte, int>(ref p), rank); p = ref Unsafe.Add(ref p, 2 * sizeof(int) * rank); // skip the bounds } int offset = index - lowerBound; if (index < lowerBound || offset < 0 || length < 0 || (uint)(offset + length) > array.NativeLength) ThrowHelper.ThrowIndexOutOfRangeException(); nuint elementSize = pMT->ComponentSize; ref byte ptr = ref Unsafe.AddByteOffset(ref p, (uint)offset * elementSize); nuint byteLength = (uint)length * elementSize; if (pMT->ContainsGCPointers) SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); else SpanHelpers.ClearWithoutReferences(ref ptr, byteLength); // GC.KeepAlive(array) not required. pMT kept alive via `ptr` } private unsafe nint GetFlattenedIndex(ReadOnlySpan<int> indices) { // Checked by the caller Debug.Assert(indices.Length == Rank); if (RuntimeHelpers.GetMethodTable(this)->IsMultiDimensionalArray) { ref int bounds = ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this); nint flattenedIndex = 0; for (int i = 0; i < indices.Length; i++) { int index = indices[i] - Unsafe.Add(ref bounds, indices.Length + i); int length = Unsafe.Add(ref bounds, i); if ((uint)index >= (uint)length) ThrowHelper.ThrowIndexOutOfRangeException(); flattenedIndex = (length * flattenedIndex) + index; } Debug.Assert((nuint)flattenedIndex < (nuint)LongLength); return flattenedIndex; } else { int index = indices[0]; if ((uint)index >= (uint)LongLength) ThrowHelper.ThrowIndexOutOfRangeException(); return index; } } [MethodImpl(MethodImplOptions.InternalCall)] internal extern unsafe object? InternalGetValue(nint flattenedIndex); [MethodImpl(MethodImplOptions.InternalCall)] private extern void InternalSetValue(object? value, nint flattenedIndex); public int Length => checked((int)Unsafe.As<RawArrayData>(this).Length); // This could return a length greater than int.MaxValue internal nuint NativeLength => Unsafe.As<RawArrayData>(this).Length; public long LongLength => (long)NativeLength; public unsafe int Rank { get { int rank = RuntimeHelpers.GetMultiDimensionalArrayRank(this); return (rank != 0) ? rank : 1; } } [Intrinsic] public unsafe int GetLength(int dimension) { int rank = RuntimeHelpers.GetMultiDimensionalArrayRank(this); if (rank == 0 && dimension == 0) return Length; if ((uint)dimension >= (uint)rank) throw new IndexOutOfRangeException(SR.IndexOutOfRange_ArrayRankIndex); return Unsafe.Add(ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this), dimension); } [Intrinsic] public unsafe int GetUpperBound(int dimension) { int rank = RuntimeHelpers.GetMultiDimensionalArrayRank(this); if (rank == 0 && dimension == 0) return Length - 1; if ((uint)dimension >= (uint)rank) throw new IndexOutOfRangeException(SR.IndexOutOfRange_ArrayRankIndex); ref int bounds = ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this); return Unsafe.Add(ref bounds, dimension) + Unsafe.Add(ref bounds, rank + dimension) - 1; } [Intrinsic] public unsafe int GetLowerBound(int dimension) { int rank = RuntimeHelpers.GetMultiDimensionalArrayRank(this); if (rank == 0 && dimension == 0) return 0; if ((uint)dimension >= (uint)rank) throw new IndexOutOfRangeException(SR.IndexOutOfRange_ArrayRankIndex); return Unsafe.Add(ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this), rank + dimension); } [MethodImpl(MethodImplOptions.InternalCall)] internal extern CorElementType GetCorElementTypeOfElementType(); private unsafe bool IsValueOfElementType(object value) { MethodTable* thisMT = RuntimeHelpers.GetMethodTable(this); return (IntPtr)thisMT->ElementType == (IntPtr)RuntimeHelpers.GetMethodTable(value); } // if this is an array of value classes and that value class has a default constructor // then this calls this default constructor on every element in the value class array. // otherwise this is a no-op. Generally this method is called automatically by the compiler [MethodImpl(MethodImplOptions.InternalCall)] public extern void Initialize(); } #pragma warning disable CA1822 // Mark members as static //---------------------------------------------------------------------------------------- // ! READ THIS BEFORE YOU WORK ON THIS CLASS. // // The methods on this class must be written VERY carefully to avoid introducing security holes. // That's because they are invoked with special "this"! The "this" object // for all of these methods are not SZArrayHelper objects. Rather, they are of type U[] // where U[] is castable to T[]. No actual SZArrayHelper object is ever instantiated. Thus, you will // see a lot of expressions that cast "this" "T[]". // // This class is needed to allow an SZ array of type T[] to expose IList<T>, // IList<T.BaseType>, etc., etc. all the way up to IList<Object>. When the following call is // made: // // ((IList<T>) (new U[n])).SomeIListMethod() // // the interface stub dispatcher treats this as a special case, loads up SZArrayHelper, // finds the corresponding generic method (matched simply by method name), instantiates // it for type <T> and executes it. // // The "T" will reflect the interface used to invoke the method. The actual runtime "this" will be // array that is castable to "T[]" (i.e. for primitivs and valuetypes, it will be exactly // "T[]" - for orefs, it may be a "U[]" where U derives from T.) //---------------------------------------------------------------------------------------- internal sealed class SZArrayHelper { // It is never legal to instantiate this class. private SZArrayHelper() { Debug.Fail("Hey! How'd I get here?"); } internal IEnumerator<T> GetEnumerator<T>() { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); return _this.Length == 0 ? SZGenericArrayEnumerator<T>.Empty : new SZGenericArrayEnumerator<T>(_this); } private void CopyTo<T>(T[] array, int index) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); Array.Copy(_this, 0, array, index, _this.Length); } internal int get_Count<T>() { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); return _this.Length; } internal T get_Item<T>(int index) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); if ((uint)index >= (uint)_this.Length) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } return _this[index]; } internal void set_Item<T>(int index, T value) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); if ((uint)index >= (uint)_this.Length) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } _this[index] = value; } private void Add<T>(T _) { // Not meaningful for arrays. ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } private bool Contains<T>(T value) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); return Array.IndexOf(_this, value, 0, _this.Length) >= 0; } private bool get_IsReadOnly<T>() { return true; } private void Clear<T>() { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } private int IndexOf<T>(T value) { // ! Warning: "this" is an array, not an SZArrayHelper. See comments above // ! or you may introduce a security hole! T[] _this = Unsafe.As<T[]>(this); return Array.IndexOf(_this, value, 0, _this.Length); } private void Insert<T>(int _, T _1) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } private bool Remove<T>(T _) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; } private void RemoveAt<T>(int _) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } } #pragma warning restore CA1822 }
1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/coreclr/classlibnative/bcltype/arraynative.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // File: ArrayNative.cpp // // // This file contains the native methods that support the Array class // #include "common.h" #include "arraynative.h" #include "excep.h" #include "field.h" #include "invokeutil.h" #include "arraynative.inl" // Returns a bool to indicate if the array is of primitive types or not. FCIMPL1(INT32, ArrayNative::GetCorElementTypeOfElementType, ArrayBase* arrayUNSAFE) { FCALL_CONTRACT; _ASSERTE(arrayUNSAFE != NULL); return arrayUNSAFE->GetArrayElementTypeHandle().GetVerifierCorElementType(); } FCIMPLEND // array is GC protected by caller void ArrayInitializeWorker(ARRAYBASEREF * arrayRef, MethodTable* pArrayMT, MethodTable* pElemMT) { STATIC_CONTRACT_MODE_COOPERATIVE; // Ensure that the array element type is fully loaded before executing its code pElemMT->EnsureInstanceActive(); //can not use contract here because of SEH _ASSERTE(IsProtectedByGCFrame (arrayRef)); SIZE_T offset = ArrayBase::GetDataPtrOffset(pArrayMT); SIZE_T size = pArrayMT->GetComponentSize(); SIZE_T cElements = (*arrayRef)->GetNumComponents(); MethodTable * pCanonMT = pElemMT->GetCanonicalMethodTable(); WORD slot = pCanonMT->GetDefaultConstructorSlot(); PCODE ctorFtn = pCanonMT->GetSlot(slot); #if defined(TARGET_X86) && !defined(TARGET_UNIX) BEGIN_CALL_TO_MANAGED(); for (SIZE_T i = 0; i < cElements; i++) { // Since GetSlot() is not idempotent and may have returned // a non-optimal entry-point the first time round. if (i == 1) { ctorFtn = pCanonMT->GetSlot(slot); } BYTE* thisPtr = (((BYTE*) OBJECTREFToObject (*arrayRef)) + offset); #ifdef _DEBUG __asm { mov ECX, thisPtr mov EDX, pElemMT // Instantiation argument if the type is generic call [ctorFtn] nop // Mark the fact that we can call managed code } #else // _DEBUG typedef void (__fastcall * CtorFtnType)(BYTE*, BYTE*); (*(CtorFtnType)ctorFtn)(thisPtr, (BYTE*)pElemMT); #endif // _DEBUG offset += size; } END_CALL_TO_MANAGED(); #else // TARGET_X86 && !TARGET_UNIX // // This is quite a bit slower, but it is portable. // for (SIZE_T i =0; i < cElements; i++) { // Since GetSlot() is not idempotent and may have returned // a non-optimal entry-point the first time round. if (i == 1) { ctorFtn = pCanonMT->GetSlot(slot); } BYTE* thisPtr = (((BYTE*) OBJECTREFToObject (*arrayRef)) + offset); PREPARE_NONVIRTUAL_CALLSITE_USING_CODE(ctorFtn); DECLARE_ARGHOLDER_ARRAY(args, 2); args[ARGNUM_0] = PTR_TO_ARGHOLDER(thisPtr); args[ARGNUM_1] = PTR_TO_ARGHOLDER(pElemMT); // Instantiation argument if the type is generic CALL_MANAGED_METHOD_NORET(args); offset += size; } #endif // !TARGET_X86 || TARGET_UNIX } FCIMPL1(void, ArrayNative::Initialize, ArrayBase* array) { FCALL_CONTRACT; if (array == NULL) { FCThrowVoid(kNullReferenceException); } MethodTable* pArrayMT = array->GetMethodTable(); TypeHandle thElem = pArrayMT->GetArrayElementTypeHandle(); if (thElem.IsTypeDesc()) return; MethodTable * pElemMT = thElem.AsMethodTable(); if (!pElemMT->HasDefaultConstructor() || !pElemMT->IsValueType()) return; ARRAYBASEREF arrayRef (array); HELPER_METHOD_FRAME_BEGIN_1(arrayRef); ArrayInitializeWorker(&arrayRef, pArrayMT, pElemMT); HELPER_METHOD_FRAME_END(); } FCIMPLEND // Returns whether you can directly copy an array of srcType into destType. FCIMPL2(FC_BOOL_RET, ArrayNative::IsSimpleCopy, ArrayBase* pSrc, ArrayBase* pDst) { FCALL_CONTRACT; _ASSERTE(pSrc != NULL); _ASSERTE(pDst != NULL); // This case is expected to be handled by the fast path _ASSERTE(pSrc->GetMethodTable() != pDst->GetMethodTable()); TypeHandle srcTH = pSrc->GetMethodTable()->GetArrayElementTypeHandle(); TypeHandle destTH = pDst->GetMethodTable()->GetArrayElementTypeHandle(); if (srcTH == destTH) // This check kicks for different array kind or dimensions FC_RETURN_BOOL(true); if (srcTH.IsValueType()) { // Value class boxing if (!destTH.IsValueType()) FC_RETURN_BOOL(false); const CorElementType srcElType = srcTH.GetVerifierCorElementType(); const CorElementType destElType = destTH.GetVerifierCorElementType(); _ASSERTE(srcElType < ELEMENT_TYPE_MAX); _ASSERTE(destElType < ELEMENT_TYPE_MAX); // Copying primitives from one type to another if (CorTypeInfo::IsPrimitiveType_NoThrow(srcElType) && CorTypeInfo::IsPrimitiveType_NoThrow(destElType)) { if (GetNormalizedIntegralArrayElementType(srcElType) == GetNormalizedIntegralArrayElementType(destElType)) FC_RETURN_BOOL(true); } } else { // Value class unboxing if (destTH.IsValueType()) FC_RETURN_BOOL(false); } TypeHandle::CastResult r = srcTH.CanCastToCached(destTH); if (r != TypeHandle::MaybeCast) { FC_RETURN_BOOL(r); } struct { OBJECTREF src; OBJECTREF dst; } gc; gc.src = ObjectToOBJECTREF(pSrc); gc.dst = ObjectToOBJECTREF(pDst); BOOL iRetVal = FALSE; HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc); iRetVal = srcTH.CanCastTo(destTH); HELPER_METHOD_FRAME_END(); FC_RETURN_BOOL(iRetVal); } FCIMPLEND // Returns an enum saying whether you can copy an array of srcType into destType. ArrayNative::AssignArrayEnum ArrayNative::CanAssignArrayType(const BASEARRAYREF pSrc, const BASEARRAYREF pDest) { CONTRACTL { THROWS; GC_TRIGGERS; MODE_COOPERATIVE; PRECONDITION(pSrc != NULL); PRECONDITION(pDest != NULL); } CONTRACTL_END; // This first bit is a minor optimization: e.g. when copying byte[] to byte[] // we do not need to call GetArrayElementTypeHandle(). MethodTable *pSrcMT = pSrc->GetMethodTable(); MethodTable *pDestMT = pDest->GetMethodTable(); _ASSERTE(pSrcMT != pDestMT); // Handled by fast path TypeHandle srcTH = pSrcMT->GetArrayElementTypeHandle(); TypeHandle destTH = pDestMT->GetArrayElementTypeHandle(); _ASSERTE(srcTH != destTH); // Handled by fast path // Value class boxing if (srcTH.IsValueType() && !destTH.IsValueType()) { if (srcTH.CanCastTo(destTH)) return AssignBoxValueClassOrPrimitive; else return AssignWrongType; } // Value class unboxing. if (!srcTH.IsValueType() && destTH.IsValueType()) { if (srcTH.CanCastTo(destTH)) return AssignUnboxValueClass; else if (destTH.CanCastTo(srcTH)) // V extends IV. Copying from IV to V, or Object to V. return AssignUnboxValueClass; else return AssignWrongType; } const CorElementType srcElType = srcTH.GetVerifierCorElementType(); const CorElementType destElType = destTH.GetVerifierCorElementType(); _ASSERTE(srcElType < ELEMENT_TYPE_MAX); _ASSERTE(destElType < ELEMENT_TYPE_MAX); // Copying primitives from one type to another if (CorTypeInfo::IsPrimitiveType_NoThrow(srcElType) && CorTypeInfo::IsPrimitiveType_NoThrow(destElType)) { _ASSERTE(srcElType != destElType); // Handled by fast path if (InvokeUtil::CanPrimitiveWiden(destElType, srcElType)) return AssignPrimitiveWiden; else return AssignWrongType; } // dest Object extends src _ASSERTE(!srcTH.CanCastTo(destTH)); // Handled by fast path // src Object extends dest if (destTH.CanCastTo(srcTH)) return AssignMustCast; // class X extends/implements src and implements dest. if (destTH.IsInterface() && srcElType != ELEMENT_TYPE_VALUETYPE) return AssignMustCast; // class X implements src and extends/implements dest if (srcTH.IsInterface() && destElType != ELEMENT_TYPE_VALUETYPE) return AssignMustCast; return AssignWrongType; } // Casts and assigns each element of src array to the dest array type. void ArrayNative::CastCheckEachElement(const BASEARRAYREF pSrcUnsafe, const unsigned int srcIndex, BASEARRAYREF pDestUnsafe, unsigned int destIndex, const unsigned int len) { CONTRACTL { THROWS; GC_TRIGGERS; MODE_COOPERATIVE; PRECONDITION(pSrcUnsafe != NULL); PRECONDITION(srcIndex >= 0); PRECONDITION(pDestUnsafe != NULL); PRECONDITION(len > 0); } CONTRACTL_END; // pSrc is either a PTRARRAYREF or a multidimensional array. TypeHandle destTH = pDestUnsafe->GetArrayElementTypeHandle(); struct _gc { OBJECTREF obj; BASEARRAYREF pDest; BASEARRAYREF pSrc; } gc; gc.obj = NULL; gc.pDest = pDestUnsafe; gc.pSrc = pSrcUnsafe; GCPROTECT_BEGIN(gc); for(unsigned int i=srcIndex; i<srcIndex + len; ++i) { gc.obj = ObjectToOBJECTREF(*((Object**) gc.pSrc->GetDataPtr() + i)); // Now that we have grabbed obj, we are no longer subject to races from another // mutator thread. if (gc.obj != NULL && !ObjIsInstanceOf(OBJECTREFToObject(gc.obj), destTH)) COMPlusThrow(kInvalidCastException, W("InvalidCast_DownCastArrayElement")); OBJECTREF * destData = (OBJECTREF*)(gc.pDest->GetDataPtr()) + i - srcIndex + destIndex; SetObjectReference(destData, gc.obj); } GCPROTECT_END(); return; } // Will box each element in an array of value classes or primitives into an array of Objects. void ArrayNative::BoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length) { CONTRACTL { THROWS; GC_TRIGGERS; MODE_COOPERATIVE; PRECONDITION(pSrc != NULL); PRECONDITION(srcIndex >= 0); PRECONDITION(pDest != NULL); PRECONDITION(length > 0); } CONTRACTL_END; // pDest is either a PTRARRAYREF or a multidimensional array. _ASSERTE(pSrc!=NULL && srcIndex>=0 && pDest!=NULL && destIndex>=0 && length>=0); TypeHandle srcTH = pSrc->GetArrayElementTypeHandle(); #ifdef _DEBUG TypeHandle destTH = pDest->GetArrayElementTypeHandle(); #endif _ASSERTE(srcTH.GetSignatureCorElementType() == ELEMENT_TYPE_CLASS || srcTH.GetSignatureCorElementType() == ELEMENT_TYPE_VALUETYPE || CorTypeInfo::IsPrimitiveType(pSrc->GetArrayElementType())); _ASSERTE(!destTH.GetMethodTable()->IsValueType()); // Get method table of type we're copying from - we need to allocate objects of that type. MethodTable * pSrcMT = srcTH.AsMethodTable(); PREFIX_ASSUME(pSrcMT != NULL); if (!pSrcMT->IsClassInited()) { BASEARRAYREF pSrcTmp = pSrc; BASEARRAYREF pDestTmp = pDest; GCPROTECT_BEGIN (pSrcTmp); GCPROTECT_BEGIN (pDestTmp); pSrcMT->CheckRunClassInitThrowing(); pSrc = pSrcTmp; pDest = pDestTmp; GCPROTECT_END (); GCPROTECT_END (); } const unsigned int srcSize = pSrcMT->GetNumInstanceFieldBytes(); unsigned int srcArrayOffset = srcIndex * srcSize; struct _gc { BASEARRAYREF src; BASEARRAYREF dest; OBJECTREF obj; } gc; gc.src = pSrc; gc.dest = pDest; gc.obj = NULL; void* srcPtr = 0; GCPROTECT_BEGIN(gc); GCPROTECT_BEGININTERIOR(srcPtr); for (unsigned int i=destIndex; i < destIndex+length; i++, srcArrayOffset += srcSize) { srcPtr = (BYTE*)gc.src->GetDataPtr() + srcArrayOffset; gc.obj = pSrcMT->FastBox(&srcPtr); OBJECTREF * destData = (OBJECTREF*)((gc.dest)->GetDataPtr()) + i; SetObjectReference(destData, gc.obj); } GCPROTECT_END(); GCPROTECT_END(); } // Unboxes from an Object[] into a value class or primitive array. void ArrayNative::UnBoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length) { CONTRACTL { THROWS; GC_TRIGGERS; MODE_COOPERATIVE; PRECONDITION(pSrc != NULL); PRECONDITION(srcIndex >= 0); PRECONDITION(pDest != NULL); PRECONDITION(destIndex >= 0); PRECONDITION(length > 0); } CONTRACTL_END; #ifdef _DEBUG TypeHandle srcTH = pSrc->GetArrayElementTypeHandle(); #endif TypeHandle destTH = pDest->GetArrayElementTypeHandle(); _ASSERTE(destTH.GetSignatureCorElementType() == ELEMENT_TYPE_CLASS || destTH.GetSignatureCorElementType() == ELEMENT_TYPE_VALUETYPE || CorTypeInfo::IsPrimitiveType(pDest->GetArrayElementType())); _ASSERTE(!srcTH.GetMethodTable()->IsValueType()); MethodTable * pDestMT = destTH.AsMethodTable(); PREFIX_ASSUME(pDestMT != NULL); SIZE_T destSize = pDest->GetComponentSize(); BYTE* srcData = (BYTE*) pSrc->GetDataPtr() + srcIndex * sizeof(OBJECTREF); BYTE* data = (BYTE*) pDest->GetDataPtr() + destIndex * destSize; for(; length>0; length--, srcData += sizeof(OBJECTREF), data += destSize) { OBJECTREF obj = ObjectToOBJECTREF(*(Object**)srcData); // Now that we have retrieved the element, we are no longer subject to race // conditions from another array mutator. if (!pDestMT->UnBoxInto(data, obj)) goto fail; } return; fail: COMPlusThrow(kInvalidCastException, W("InvalidCast_DownCastArrayElement")); } // Widen primitive types to another primitive type. void ArrayNative::PrimitiveWiden(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length) { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_COOPERATIVE; PRECONDITION(pSrc != NULL); PRECONDITION(srcIndex >= 0); PRECONDITION(pDest != NULL); PRECONDITION(destIndex >= 0); PRECONDITION(length > 0); } CONTRACTL_END; // Get appropriate sizes, which requires method tables. TypeHandle srcTH = pSrc->GetArrayElementTypeHandle(); TypeHandle destTH = pDest->GetArrayElementTypeHandle(); const CorElementType srcElType = srcTH.GetVerifierCorElementType(); const CorElementType destElType = destTH.GetVerifierCorElementType(); const unsigned int srcSize = GetSizeForCorElementType(srcElType); const unsigned int destSize = GetSizeForCorElementType(destElType); BYTE* srcData = (BYTE*) pSrc->GetDataPtr() + srcIndex * srcSize; BYTE* data = (BYTE*) pDest->GetDataPtr() + destIndex * destSize; _ASSERTE(srcElType != destElType); // We shouldn't be here if these are the same type. _ASSERTE(CorTypeInfo::IsPrimitiveType_NoThrow(srcElType) && CorTypeInfo::IsPrimitiveType_NoThrow(destElType)); for(; length>0; length--, srcData += srcSize, data += destSize) { // We pretty much have to do some fancy datatype mangling every time here, for // converting w/ sign extension and floating point conversions. switch (srcElType) { case ELEMENT_TYPE_U1: switch (destElType) { case ELEMENT_TYPE_R4: *(float*)data = *(UINT8*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(UINT8*)srcData; break; #ifndef BIGENDIAN default: *(UINT8*)data = *(UINT8*)srcData; memset(data+1, 0, destSize - 1); break; #else // BIGENDIAN case ELEMENT_TYPE_CHAR: case ELEMENT_TYPE_I2: case ELEMENT_TYPE_U2: *(INT16*)data = *(UINT8*)srcData; break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: *(INT32*)data = *(UINT8*)srcData; break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: *(INT64*)data = *(UINT8*)srcData; break; default: _ASSERTE(!"Array.Copy from U1 to another type hit unsupported widening conversion"); #endif // BIGENDIAN } break; case ELEMENT_TYPE_I1: switch (destElType) { case ELEMENT_TYPE_I2: *(INT16*)data = *(INT8*)srcData; break; case ELEMENT_TYPE_I4: *(INT32*)data = *(INT8*)srcData; break; case ELEMENT_TYPE_I8: *(INT64*)data = *(INT8*)srcData; break; case ELEMENT_TYPE_R4: *(float*)data = *(INT8*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(INT8*)srcData; break; default: _ASSERTE(!"Array.Copy from I1 to another type hit unsupported widening conversion"); } break; case ELEMENT_TYPE_U2: case ELEMENT_TYPE_CHAR: switch (destElType) { case ELEMENT_TYPE_R4: *(float*)data = *(UINT16*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(UINT16*)srcData; break; #ifndef BIGENDIAN default: *(UINT16*)data = *(UINT16*)srcData; memset(data+2, 0, destSize - 2); break; #else // BIGENDIAN case ELEMENT_TYPE_U2: case ELEMENT_TYPE_CHAR: *(UINT16*)data = *(UINT16*)srcData; break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: *(UINT32*)data = *(UINT16*)srcData; break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: *(UINT64*)data = *(UINT16*)srcData; break; default: _ASSERTE(!"Array.Copy from U1 to another type hit unsupported widening conversion"); #endif // BIGENDIAN } break; case ELEMENT_TYPE_I2: switch (destElType) { case ELEMENT_TYPE_I4: *(INT32*)data = *(INT16*)srcData; break; case ELEMENT_TYPE_I8: *(INT64*)data = *(INT16*)srcData; break; case ELEMENT_TYPE_R4: *(float*)data = *(INT16*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(INT16*)srcData; break; default: _ASSERTE(!"Array.Copy from I2 to another type hit unsupported widening conversion"); } break; case ELEMENT_TYPE_I4: switch (destElType) { case ELEMENT_TYPE_I8: *(INT64*)data = *(INT32*)srcData; break; case ELEMENT_TYPE_R4: *(float*)data = (float)*(INT32*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(INT32*)srcData; break; default: _ASSERTE(!"Array.Copy from I4 to another type hit unsupported widening conversion"); } break; case ELEMENT_TYPE_U4: switch (destElType) { case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: *(INT64*)data = *(UINT32*)srcData; break; case ELEMENT_TYPE_R4: *(float*)data = (float)*(UINT32*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(UINT32*)srcData; break; default: _ASSERTE(!"Array.Copy from U4 to another type hit unsupported widening conversion"); } break; case ELEMENT_TYPE_I8: if (destElType == ELEMENT_TYPE_R4) { *(float*) data = (float) *(INT64*)srcData; } else { _ASSERTE(destElType==ELEMENT_TYPE_R8); *(double*) data = (double) *(INT64*)srcData; } break; case ELEMENT_TYPE_U8: if (destElType == ELEMENT_TYPE_R4) { //*(float*) data = (float) *(UINT64*)srcData; INT64 srcVal = *(INT64*)srcData; float f = (float) srcVal; if (srcVal < 0) f += 4294967296.0f * 4294967296.0f; // This is 2^64 *(float*) data = f; } else { _ASSERTE(destElType==ELEMENT_TYPE_R8); //*(double*) data = (double) *(UINT64*)srcData; INT64 srcVal = *(INT64*)srcData; double d = (double) srcVal; if (srcVal < 0) d += 4294967296.0 * 4294967296.0; // This is 2^64 *(double*) data = d; } break; case ELEMENT_TYPE_R4: *(double*) data = *(float*)srcData; break; default: _ASSERTE(!"Fell through outer switch in PrimitiveWiden! Unknown primitive type for source array!"); } } } // // This is a GC safe variant of the memmove intrinsic. It sets the cards, and guarantees that the object references in the GC heap are // updated atomically. // // The CRT version of memmove does not always guarantee that updates of aligned fields stay atomic (e.g. it is using "rep movsb" in some cases). // Type safety guarantees and background GC scanning requires object references in GC heap to be updated atomically. // void memmoveGCRefs(void *dest, const void *src, size_t len) { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_COOPERATIVE; } CONTRACTL_END; _ASSERTE(dest != nullptr); _ASSERTE(src != nullptr); // Make sure everything is pointer aligned _ASSERTE(IS_ALIGNED(dest, sizeof(SIZE_T))); _ASSERTE(IS_ALIGNED(src, sizeof(SIZE_T))); _ASSERTE(IS_ALIGNED(len, sizeof(SIZE_T))); _ASSERTE(CheckPointer(dest)); _ASSERTE(CheckPointer(src)); if (len != 0 && dest != src) { InlinedMemmoveGCRefsHelper(dest, src, len); } } FCIMPL5(void, ArrayNative::CopySlow, ArrayBase* pSrc, INT32 iSrcIndex, ArrayBase* pDst, INT32 iDstIndex, INT32 iLength) { FCALL_CONTRACT; struct _gc { BASEARRAYREF pSrc; BASEARRAYREF pDst; } gc; gc.pSrc = (BASEARRAYREF)pSrc; gc.pDst = (BASEARRAYREF)pDst; // cannot pass null for source or destination _ASSERTE(gc.pSrc != NULL && gc.pDst != NULL); // source and destination must be arrays _ASSERTE(gc.pSrc->GetMethodTable()->IsArray()); _ASSERTE(gc.pDst->GetMethodTable()->IsArray()); _ASSERTE(gc.pSrc->GetRank() == gc.pDst->GetRank()); // array bounds checking _ASSERTE(iLength >= 0); _ASSERTE(iSrcIndex >= 0); _ASSERTE(iDstIndex >= 0); _ASSERTE((DWORD)(iSrcIndex + iLength) <= gc.pSrc->GetNumComponents()); _ASSERTE((DWORD)(iDstIndex + iLength) <= gc.pDst->GetNumComponents()); HELPER_METHOD_FRAME_BEGIN_PROTECT(gc); int r = CanAssignArrayType(gc.pSrc, gc.pDst); if (r == AssignWrongType) COMPlusThrow(kArrayTypeMismatchException, W("ArrayTypeMismatch_CantAssignType")); if (iLength > 0) { switch (r) { case AssignUnboxValueClass: UnBoxEachElement(gc.pSrc, iSrcIndex, gc.pDst, iDstIndex, iLength); break; case AssignBoxValueClassOrPrimitive: BoxEachElement(gc.pSrc, iSrcIndex, gc.pDst, iDstIndex, iLength); break; case AssignMustCast: CastCheckEachElement(gc.pSrc, iSrcIndex, gc.pDst, iDstIndex, iLength); break; case AssignPrimitiveWiden: PrimitiveWiden(gc.pSrc, iSrcIndex, gc.pDst, iDstIndex, iLength); break; default: _ASSERTE(!"Fell through switch in Array.Copy!"); } } HELPER_METHOD_FRAME_END(); } FCIMPLEND // Check we're allowed to create an array with the given element type. void ArrayNative::CheckElementType(TypeHandle elementType) { // Checks apply recursively for arrays of arrays etc. if (elementType.IsArray()) { CheckElementType(elementType.GetArrayElementTypeHandle()); return; } // Check for simple types first. if (!elementType.IsTypeDesc()) { MethodTable *pMT = elementType.AsMethodTable(); // Check for byref-like types. if (pMT->IsByRefLike()) COMPlusThrow(kNotSupportedException, W("NotSupported_ByRefLikeArray")); // Check for open generic types. if (pMT->IsGenericTypeDefinition() || pMT->ContainsGenericVariables()) COMPlusThrow(kNotSupportedException, W("NotSupported_OpenType")); // Check for Void. if (elementType.GetSignatureCorElementType() == ELEMENT_TYPE_VOID) COMPlusThrow(kNotSupportedException, W("NotSupported_VoidArray")); // That's all the dangerous simple types we know, it must be OK. return; } // ByRefs and generic type variables are never allowed. if (elementType.IsByRef() || elementType.IsGenericVariable()) COMPlusThrow(kNotSupportedException, W("NotSupported_Type")); // We can create pointers and function pointers, but it requires skip verification permission. CorElementType etType = elementType.GetSignatureCorElementType(); if (etType == ELEMENT_TYPE_PTR || etType == ELEMENT_TYPE_FNPTR) { return; } // We shouldn't get here (it means we've encountered a new type of typehandle if we do). _ASSERTE(!"Shouldn't get here, unknown type handle type"); COMPlusThrow(kNotSupportedException); } FCIMPL4(Object*, ArrayNative::CreateInstance, void* elementTypeHandle, INT32 rank, INT32* pLengths, INT32* pLowerBounds) { CONTRACTL { FCALL_CHECK; PRECONDITION(rank > 0); PRECONDITION(CheckPointer(pLengths)); PRECONDITION(CheckPointer(pLowerBounds, NULL_OK)); } CONTRACTL_END; OBJECTREF pRet = NULL; TypeHandle elementType = TypeHandle::FromPtr(elementTypeHandle); _ASSERTE(!elementType.IsNull()); // pLengths and pLowerBounds are pinned buffers. No need to protect them. HELPER_METHOD_FRAME_BEGIN_RET_0(); CheckElementType(elementType); CorElementType CorType = elementType.GetSignatureCorElementType(); CorElementType kind = ELEMENT_TYPE_ARRAY; // Is it ELEMENT_TYPE_SZARRAY array? if (rank == 1 && (pLowerBounds == NULL || pLowerBounds[0] == 0) #ifdef FEATURE_64BIT_ALIGNMENT // On platforms where 64-bit types require 64-bit alignment and don't obtain it naturally force us // through the slow path where this will be handled. && (CorType != ELEMENT_TYPE_I8) && (CorType != ELEMENT_TYPE_U8) && (CorType != ELEMENT_TYPE_R8) #endif ) { // Shortcut for common cases if (CorTypeInfo::IsPrimitiveType(CorType)) { pRet = AllocatePrimitiveArray(CorType,pLengths[0]); goto Done; } else if (CorTypeInfo::IsObjRef(CorType)) { pRet = AllocateObjectArray(pLengths[0],elementType); goto Done; } kind = ELEMENT_TYPE_SZARRAY; pLowerBounds = NULL; } { // Find the Array class... TypeHandle typeHnd = ClassLoader::LoadArrayTypeThrowing(elementType, kind, rank); DWORD boundsSize = 0; INT32* bounds; if (pLowerBounds != NULL) { if (!ClrSafeInt<DWORD>::multiply(rank, 2, boundsSize)) COMPlusThrowOM(); DWORD dwAllocaSize = 0; if (!ClrSafeInt<DWORD>::multiply(boundsSize, sizeof(INT32), dwAllocaSize)) COMPlusThrowOM(); bounds = (INT32*) _alloca(dwAllocaSize); for (int i=0;i<rank;i++) { bounds[2*i] = pLowerBounds[i]; bounds[2*i+1] = pLengths[i]; } } else { boundsSize = rank; DWORD dwAllocaSize = 0; if (!ClrSafeInt<DWORD>::multiply(boundsSize, sizeof(INT32), dwAllocaSize)) COMPlusThrowOM(); bounds = (INT32*) _alloca(dwAllocaSize); // We need to create a private copy of pLengths to avoid holes caused // by caller mutating the array for (int i=0;i<rank;i++) bounds[i] = pLengths[i]; } pRet = AllocateArrayEx(typeHnd, bounds, boundsSize); } Done: ; HELPER_METHOD_FRAME_END(); return OBJECTREFToObject(pRet); } FCIMPLEND FCIMPL2(Object*, ArrayNative::GetValue, ArrayBase* refThisUNSAFE, INT_PTR flattenedIndex) { CONTRACTL { FCALL_CHECK; } CONTRACTL_END; BASEARRAYREF refThis(refThisUNSAFE); TypeHandle arrayElementType = refThis->GetArrayElementTypeHandle(); // Legacy behavior if (arrayElementType.IsTypeDesc()) { CorElementType elemtype = arrayElementType.AsTypeDesc()->GetInternalCorElementType(); if (elemtype == ELEMENT_TYPE_PTR || elemtype == ELEMENT_TYPE_FNPTR) FCThrowRes(kNotSupportedException, W("NotSupported_Type")); } _ASSERTE((SIZE_T)flattenedIndex < refThis->GetNumComponents()); void* pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); OBJECTREF Obj; MethodTable* pElementTypeMT = arrayElementType.GetMethodTable(); if (pElementTypeMT->IsValueType()) { HELPER_METHOD_FRAME_BEGIN_RET_0(); Obj = pElementTypeMT->Box(pData); HELPER_METHOD_FRAME_END(); } else { Obj = ObjectToOBJECTREF(*((Object**)pData)); } return OBJECTREFToObject(Obj); } FCIMPLEND FCIMPL3(void, ArrayNative::SetValue, ArrayBase* refThisUNSAFE, Object* objUNSAFE, INT_PTR flattenedIndex) { FCALL_CONTRACT; BASEARRAYREF refThis(refThisUNSAFE); OBJECTREF obj(objUNSAFE); TypeHandle arrayElementType = refThis->GetArrayElementTypeHandle(); // Legacy behavior if (arrayElementType.IsTypeDesc()) { CorElementType elemtype = arrayElementType.AsTypeDesc()->GetInternalCorElementType(); if (elemtype == ELEMENT_TYPE_PTR || elemtype == ELEMENT_TYPE_FNPTR) FCThrowResVoid(kNotSupportedException, W("NotSupported_Type")); } _ASSERTE((SIZE_T)flattenedIndex < refThis->GetNumComponents()); MethodTable* pElementTypeMT = arrayElementType.GetMethodTable(); PREFIX_ASSUME(NULL != pElementTypeMT); void* pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); if (obj == NULL) { // Null is the universal zero... if (pElementTypeMT->IsValueType()) InitValueClass(pData,pElementTypeMT); else ClearObjectReference((OBJECTREF*)pData); } else if (arrayElementType == TypeHandle(g_pObjectClass)) { // Everything is compatible with Object SetObjectReference((OBJECTREF*)pData,(OBJECTREF)obj); } else if (!pElementTypeMT->IsValueType()) { if (ObjIsInstanceOfCached(OBJECTREFToObject(obj), arrayElementType) != TypeHandle::CanCast) { HELPER_METHOD_FRAME_BEGIN_2(refThis, obj); if (!ObjIsInstanceOf(OBJECTREFToObject(obj), arrayElementType)) COMPlusThrow(kInvalidCastException,W("InvalidCast_StoreArrayElement")); HELPER_METHOD_FRAME_END(); // Refresh pData in case GC moved objects around pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); } SetObjectReference((OBJECTREF*)pData,obj); } else { // value class or primitive type if (!pElementTypeMT->UnBoxInto(pData, obj)) { HELPER_METHOD_FRAME_BEGIN_2(refThis, obj); ARG_SLOT value = 0; // Allow enum -> primitive conversion, disallow primitive -> enum conversion TypeHandle thSrc = obj->GetTypeHandle(); CorElementType srcType = thSrc.GetVerifierCorElementType(); CorElementType targetType = arrayElementType.GetSignatureCorElementType(); if (!InvokeUtil::IsPrimitiveType(srcType) || !InvokeUtil::IsPrimitiveType(targetType)) COMPlusThrow(kInvalidCastException, W("InvalidCast_StoreArrayElement")); // Get a properly widened type InvokeUtil::CreatePrimitiveValue(targetType,srcType,obj,&value); // Refresh pData in case GC moved objects around pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); UINT cbSize = CorTypeInfo::Size(targetType); memcpyNoGCRefs(pData, ArgSlotEndianessFixup(&value, cbSize), cbSize); HELPER_METHOD_FRAME_END(); } } } FCIMPLEND // This method will initialize an array from a TypeHandle to a field. FCIMPL2_IV(void, ArrayNative::InitializeArray, ArrayBase* pArrayRef, FCALLRuntimeFieldHandle structField) { FCALL_CONTRACT; BASEARRAYREF arr = BASEARRAYREF(pArrayRef); REFLECTFIELDREF refField = (REFLECTFIELDREF)ObjectToOBJECTREF(FCALL_RFH_TO_REFLECTFIELD(structField)); HELPER_METHOD_FRAME_BEGIN_2(arr, refField); if ((arr == 0) || (refField == NULL)) COMPlusThrow(kArgumentNullException); FieldDesc* pField = (FieldDesc*) refField->GetField(); if (!pField->IsRVA()) COMPlusThrow(kArgumentException); // Report the RVA field to the logger. g_IBCLogger.LogRVADataAccess(pField); // Note that we do not check that the field is actually in the PE file that is initializing // the array. Basically the data being published is can be accessed by anyone with the proper // permissions (C# marks these as assembly visibility, and thus are protected from outside // snooping) if (!CorTypeInfo::IsPrimitiveType(arr->GetArrayElementType()) && !arr->GetArrayElementTypeHandle().IsEnum()) COMPlusThrow(kArgumentException); SIZE_T dwCompSize = arr->GetComponentSize(); SIZE_T dwElemCnt = arr->GetNumComponents(); SIZE_T dwTotalSize = dwCompSize * dwElemCnt; DWORD size = pField->LoadSize(); // make certain you don't go off the end of the rva static if (dwTotalSize > size) COMPlusThrow(kArgumentException); void *src = pField->GetStaticAddressHandle(NULL); void *dest = arr->GetDataPtr(); #if BIGENDIAN DWORD i; switch (dwCompSize) { case 1: memcpyNoGCRefs(dest, src, dwElemCnt); break; case 2: for (i = 0; i < dwElemCnt; i++) *((UINT16*)dest + i) = GET_UNALIGNED_VAL16((UINT16*)src + i); break; case 4: for (i = 0; i < dwElemCnt; i++) *((UINT32*)dest + i) = GET_UNALIGNED_VAL32((UINT32*)src + i); break; case 8: for (i = 0; i < dwElemCnt; i++) *((UINT64*)dest + i) = GET_UNALIGNED_VAL64((UINT64*)src + i); break; default: // should not reach here. UNREACHABLE_MSG("Incorrect primitive type size!"); break; } #else memcpyNoGCRefs(dest, src, dwTotalSize); #endif HELPER_METHOD_FRAME_END(); } FCIMPLEND FCIMPL3_VVI(void*, ArrayNative::GetSpanDataFrom, FCALLRuntimeFieldHandle structField, FCALLRuntimeTypeHandle targetTypeUnsafe, INT32* count) { FCALL_CONTRACT; struct { REFLECTFIELDREF refField; REFLECTCLASSBASEREF refClass; } gc; gc.refField = (REFLECTFIELDREF)ObjectToOBJECTREF(FCALL_RFH_TO_REFLECTFIELD(structField)); gc.refClass = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(FCALL_RTH_TO_REFLECTCLASS(targetTypeUnsafe)); void* data; HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc); FieldDesc* pField = (FieldDesc*)gc.refField->GetField(); if (!pField->IsRVA()) COMPlusThrow(kArgumentException); TypeHandle targetTypeHandle = gc.refClass->GetType(); if (!CorTypeInfo::IsPrimitiveType(targetTypeHandle.GetSignatureCorElementType()) && !targetTypeHandle.IsEnum()) COMPlusThrow(kArgumentException); DWORD totalSize = pField->LoadSize(); DWORD targetTypeSize = targetTypeHandle.GetSize(); // Report the RVA field to the logger. g_IBCLogger.LogRVADataAccess(pField); data = pField->GetStaticAddressHandle(NULL); _ASSERTE(data != NULL); _ASSERTE(count != NULL); if (AlignUp((UINT_PTR)data, targetTypeSize) != (UINT_PTR)data) COMPlusThrow(kArgumentException); *count = (INT32)totalSize / targetTypeSize; #if BIGENDIAN COMPlusThrow(kPlatformNotSupportedException); #endif HELPER_METHOD_FRAME_END(); return data; } FCIMPLEND
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // File: ArrayNative.cpp // // // This file contains the native methods that support the Array class // #include "common.h" #include "arraynative.h" #include "excep.h" #include "field.h" #include "invokeutil.h" #include "arraynative.inl" // Returns a bool to indicate if the array is of primitive types or not. FCIMPL1(INT32, ArrayNative::GetCorElementTypeOfElementType, ArrayBase* arrayUNSAFE) { FCALL_CONTRACT; _ASSERTE(arrayUNSAFE != NULL); return arrayUNSAFE->GetArrayElementTypeHandle().GetVerifierCorElementType(); } FCIMPLEND // array is GC protected by caller void ArrayInitializeWorker(ARRAYBASEREF * arrayRef, MethodTable* pArrayMT, MethodTable* pElemMT) { STATIC_CONTRACT_MODE_COOPERATIVE; // Ensure that the array element type is fully loaded before executing its code pElemMT->EnsureInstanceActive(); //can not use contract here because of SEH _ASSERTE(IsProtectedByGCFrame (arrayRef)); SIZE_T offset = ArrayBase::GetDataPtrOffset(pArrayMT); SIZE_T size = pArrayMT->GetComponentSize(); SIZE_T cElements = (*arrayRef)->GetNumComponents(); MethodTable * pCanonMT = pElemMT->GetCanonicalMethodTable(); WORD slot = pCanonMT->GetDefaultConstructorSlot(); PCODE ctorFtn = pCanonMT->GetSlot(slot); #if defined(TARGET_X86) && !defined(TARGET_UNIX) BEGIN_CALL_TO_MANAGED(); for (SIZE_T i = 0; i < cElements; i++) { // Since GetSlot() is not idempotent and may have returned // a non-optimal entry-point the first time round. if (i == 1) { ctorFtn = pCanonMT->GetSlot(slot); } BYTE* thisPtr = (((BYTE*) OBJECTREFToObject (*arrayRef)) + offset); #ifdef _DEBUG __asm { mov ECX, thisPtr mov EDX, pElemMT // Instantiation argument if the type is generic call [ctorFtn] nop // Mark the fact that we can call managed code } #else // _DEBUG typedef void (__fastcall * CtorFtnType)(BYTE*, BYTE*); (*(CtorFtnType)ctorFtn)(thisPtr, (BYTE*)pElemMT); #endif // _DEBUG offset += size; } END_CALL_TO_MANAGED(); #else // TARGET_X86 && !TARGET_UNIX // // This is quite a bit slower, but it is portable. // for (SIZE_T i =0; i < cElements; i++) { // Since GetSlot() is not idempotent and may have returned // a non-optimal entry-point the first time round. if (i == 1) { ctorFtn = pCanonMT->GetSlot(slot); } BYTE* thisPtr = (((BYTE*) OBJECTREFToObject (*arrayRef)) + offset); PREPARE_NONVIRTUAL_CALLSITE_USING_CODE(ctorFtn); DECLARE_ARGHOLDER_ARRAY(args, 2); args[ARGNUM_0] = PTR_TO_ARGHOLDER(thisPtr); args[ARGNUM_1] = PTR_TO_ARGHOLDER(pElemMT); // Instantiation argument if the type is generic CALL_MANAGED_METHOD_NORET(args); offset += size; } #endif // !TARGET_X86 || TARGET_UNIX } FCIMPL1(void, ArrayNative::Initialize, ArrayBase* array) { FCALL_CONTRACT; if (array == NULL) { FCThrowVoid(kNullReferenceException); } MethodTable* pArrayMT = array->GetMethodTable(); TypeHandle thElem = pArrayMT->GetArrayElementTypeHandle(); if (thElem.IsTypeDesc()) return; MethodTable * pElemMT = thElem.AsMethodTable(); if (!pElemMT->HasDefaultConstructor() || !pElemMT->IsValueType()) return; ARRAYBASEREF arrayRef (array); HELPER_METHOD_FRAME_BEGIN_1(arrayRef); ArrayInitializeWorker(&arrayRef, pArrayMT, pElemMT); HELPER_METHOD_FRAME_END(); } FCIMPLEND // Returns whether you can directly copy an array of srcType into destType. FCIMPL2(FC_BOOL_RET, ArrayNative::IsSimpleCopy, ArrayBase* pSrc, ArrayBase* pDst) { FCALL_CONTRACT; _ASSERTE(pSrc != NULL); _ASSERTE(pDst != NULL); // This case is expected to be handled by the fast path _ASSERTE(pSrc->GetMethodTable() != pDst->GetMethodTable()); TypeHandle srcTH = pSrc->GetMethodTable()->GetArrayElementTypeHandle(); TypeHandle destTH = pDst->GetMethodTable()->GetArrayElementTypeHandle(); if (srcTH == destTH) // This check kicks for different array kind or dimensions FC_RETURN_BOOL(true); if (srcTH.IsValueType()) { // Value class boxing if (!destTH.IsValueType()) FC_RETURN_BOOL(false); const CorElementType srcElType = srcTH.GetVerifierCorElementType(); const CorElementType destElType = destTH.GetVerifierCorElementType(); _ASSERTE(srcElType < ELEMENT_TYPE_MAX); _ASSERTE(destElType < ELEMENT_TYPE_MAX); // Copying primitives from one type to another if (CorTypeInfo::IsPrimitiveType_NoThrow(srcElType) && CorTypeInfo::IsPrimitiveType_NoThrow(destElType)) { if (GetNormalizedIntegralArrayElementType(srcElType) == GetNormalizedIntegralArrayElementType(destElType)) FC_RETURN_BOOL(true); } } else { // Value class unboxing if (destTH.IsValueType()) FC_RETURN_BOOL(false); } TypeHandle::CastResult r = srcTH.CanCastToCached(destTH); if (r != TypeHandle::MaybeCast) { FC_RETURN_BOOL(r); } struct { OBJECTREF src; OBJECTREF dst; } gc; gc.src = ObjectToOBJECTREF(pSrc); gc.dst = ObjectToOBJECTREF(pDst); BOOL iRetVal = FALSE; HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc); iRetVal = srcTH.CanCastTo(destTH); HELPER_METHOD_FRAME_END(); FC_RETURN_BOOL(iRetVal); } FCIMPLEND // Returns an enum saying whether you can copy an array of srcType into destType. ArrayNative::AssignArrayEnum ArrayNative::CanAssignArrayType(const BASEARRAYREF pSrc, const BASEARRAYREF pDest) { CONTRACTL { THROWS; GC_TRIGGERS; MODE_COOPERATIVE; PRECONDITION(pSrc != NULL); PRECONDITION(pDest != NULL); } CONTRACTL_END; // This first bit is a minor optimization: e.g. when copying byte[] to byte[] // we do not need to call GetArrayElementTypeHandle(). MethodTable *pSrcMT = pSrc->GetMethodTable(); MethodTable *pDestMT = pDest->GetMethodTable(); _ASSERTE(pSrcMT != pDestMT); // Handled by fast path TypeHandle srcTH = pSrcMT->GetArrayElementTypeHandle(); TypeHandle destTH = pDestMT->GetArrayElementTypeHandle(); _ASSERTE(srcTH != destTH); // Handled by fast path // Value class boxing if (srcTH.IsValueType() && !destTH.IsValueType()) { if (srcTH.CanCastTo(destTH)) return AssignBoxValueClassOrPrimitive; else return AssignWrongType; } // Value class unboxing. if (!srcTH.IsValueType() && destTH.IsValueType()) { if (srcTH.CanCastTo(destTH)) return AssignUnboxValueClass; else if (destTH.CanCastTo(srcTH)) // V extends IV. Copying from IV to V, or Object to V. return AssignUnboxValueClass; else return AssignWrongType; } const CorElementType srcElType = srcTH.GetVerifierCorElementType(); const CorElementType destElType = destTH.GetVerifierCorElementType(); _ASSERTE(srcElType < ELEMENT_TYPE_MAX); _ASSERTE(destElType < ELEMENT_TYPE_MAX); // Copying primitives from one type to another if (CorTypeInfo::IsPrimitiveType_NoThrow(srcElType) && CorTypeInfo::IsPrimitiveType_NoThrow(destElType)) { _ASSERTE(srcElType != destElType); // Handled by fast path if (InvokeUtil::CanPrimitiveWiden(destElType, srcElType)) return AssignPrimitiveWiden; else return AssignWrongType; } // dest Object extends src _ASSERTE(!srcTH.CanCastTo(destTH)); // Handled by fast path // src Object extends dest if (destTH.CanCastTo(srcTH)) return AssignMustCast; // class X extends/implements src and implements dest. if (destTH.IsInterface() && srcElType != ELEMENT_TYPE_VALUETYPE) return AssignMustCast; // class X implements src and extends/implements dest if (srcTH.IsInterface() && destElType != ELEMENT_TYPE_VALUETYPE) return AssignMustCast; return AssignWrongType; } // Casts and assigns each element of src array to the dest array type. void ArrayNative::CastCheckEachElement(const BASEARRAYREF pSrcUnsafe, const unsigned int srcIndex, BASEARRAYREF pDestUnsafe, unsigned int destIndex, const unsigned int len) { CONTRACTL { THROWS; GC_TRIGGERS; MODE_COOPERATIVE; PRECONDITION(pSrcUnsafe != NULL); PRECONDITION(srcIndex >= 0); PRECONDITION(pDestUnsafe != NULL); PRECONDITION(len > 0); } CONTRACTL_END; // pSrc is either a PTRARRAYREF or a multidimensional array. TypeHandle destTH = pDestUnsafe->GetArrayElementTypeHandle(); struct _gc { OBJECTREF obj; BASEARRAYREF pDest; BASEARRAYREF pSrc; } gc; gc.obj = NULL; gc.pDest = pDestUnsafe; gc.pSrc = pSrcUnsafe; GCPROTECT_BEGIN(gc); for(unsigned int i=srcIndex; i<srcIndex + len; ++i) { gc.obj = ObjectToOBJECTREF(*((Object**) gc.pSrc->GetDataPtr() + i)); // Now that we have grabbed obj, we are no longer subject to races from another // mutator thread. if (gc.obj != NULL && !ObjIsInstanceOf(OBJECTREFToObject(gc.obj), destTH)) COMPlusThrow(kInvalidCastException, W("InvalidCast_DownCastArrayElement")); OBJECTREF * destData = (OBJECTREF*)(gc.pDest->GetDataPtr()) + i - srcIndex + destIndex; SetObjectReference(destData, gc.obj); } GCPROTECT_END(); return; } // Will box each element in an array of value classes or primitives into an array of Objects. void ArrayNative::BoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length) { CONTRACTL { THROWS; GC_TRIGGERS; MODE_COOPERATIVE; PRECONDITION(pSrc != NULL); PRECONDITION(srcIndex >= 0); PRECONDITION(pDest != NULL); PRECONDITION(length > 0); } CONTRACTL_END; // pDest is either a PTRARRAYREF or a multidimensional array. _ASSERTE(pSrc!=NULL && srcIndex>=0 && pDest!=NULL && destIndex>=0 && length>=0); TypeHandle srcTH = pSrc->GetArrayElementTypeHandle(); #ifdef _DEBUG TypeHandle destTH = pDest->GetArrayElementTypeHandle(); #endif _ASSERTE(srcTH.GetSignatureCorElementType() == ELEMENT_TYPE_CLASS || srcTH.GetSignatureCorElementType() == ELEMENT_TYPE_VALUETYPE || CorTypeInfo::IsPrimitiveType(pSrc->GetArrayElementType())); _ASSERTE(!destTH.GetMethodTable()->IsValueType()); // Get method table of type we're copying from - we need to allocate objects of that type. MethodTable * pSrcMT = srcTH.AsMethodTable(); PREFIX_ASSUME(pSrcMT != NULL); if (!pSrcMT->IsClassInited()) { BASEARRAYREF pSrcTmp = pSrc; BASEARRAYREF pDestTmp = pDest; GCPROTECT_BEGIN (pSrcTmp); GCPROTECT_BEGIN (pDestTmp); pSrcMT->CheckRunClassInitThrowing(); pSrc = pSrcTmp; pDest = pDestTmp; GCPROTECT_END (); GCPROTECT_END (); } const unsigned int srcSize = pSrcMT->GetNumInstanceFieldBytes(); unsigned int srcArrayOffset = srcIndex * srcSize; struct _gc { BASEARRAYREF src; BASEARRAYREF dest; OBJECTREF obj; } gc; gc.src = pSrc; gc.dest = pDest; gc.obj = NULL; void* srcPtr = 0; GCPROTECT_BEGIN(gc); GCPROTECT_BEGININTERIOR(srcPtr); for (unsigned int i=destIndex; i < destIndex+length; i++, srcArrayOffset += srcSize) { srcPtr = (BYTE*)gc.src->GetDataPtr() + srcArrayOffset; gc.obj = pSrcMT->FastBox(&srcPtr); OBJECTREF * destData = (OBJECTREF*)((gc.dest)->GetDataPtr()) + i; SetObjectReference(destData, gc.obj); } GCPROTECT_END(); GCPROTECT_END(); } // Unboxes from an Object[] into a value class or primitive array. void ArrayNative::UnBoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length) { CONTRACTL { THROWS; GC_TRIGGERS; MODE_COOPERATIVE; PRECONDITION(pSrc != NULL); PRECONDITION(srcIndex >= 0); PRECONDITION(pDest != NULL); PRECONDITION(destIndex >= 0); PRECONDITION(length > 0); } CONTRACTL_END; #ifdef _DEBUG TypeHandle srcTH = pSrc->GetArrayElementTypeHandle(); #endif TypeHandle destTH = pDest->GetArrayElementTypeHandle(); _ASSERTE(destTH.GetSignatureCorElementType() == ELEMENT_TYPE_CLASS || destTH.GetSignatureCorElementType() == ELEMENT_TYPE_VALUETYPE || CorTypeInfo::IsPrimitiveType(pDest->GetArrayElementType())); _ASSERTE(!srcTH.GetMethodTable()->IsValueType()); MethodTable * pDestMT = destTH.AsMethodTable(); PREFIX_ASSUME(pDestMT != NULL); SIZE_T destSize = pDest->GetComponentSize(); BYTE* srcData = (BYTE*) pSrc->GetDataPtr() + srcIndex * sizeof(OBJECTREF); BYTE* data = (BYTE*) pDest->GetDataPtr() + destIndex * destSize; for(; length>0; length--, srcData += sizeof(OBJECTREF), data += destSize) { OBJECTREF obj = ObjectToOBJECTREF(*(Object**)srcData); // Now that we have retrieved the element, we are no longer subject to race // conditions from another array mutator. if (!pDestMT->UnBoxInto(data, obj)) goto fail; } return; fail: COMPlusThrow(kInvalidCastException, W("InvalidCast_DownCastArrayElement")); } // Widen primitive types to another primitive type. void ArrayNative::PrimitiveWiden(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length) { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_COOPERATIVE; PRECONDITION(pSrc != NULL); PRECONDITION(srcIndex >= 0); PRECONDITION(pDest != NULL); PRECONDITION(destIndex >= 0); PRECONDITION(length > 0); } CONTRACTL_END; // Get appropriate sizes, which requires method tables. TypeHandle srcTH = pSrc->GetArrayElementTypeHandle(); TypeHandle destTH = pDest->GetArrayElementTypeHandle(); const CorElementType srcElType = srcTH.GetVerifierCorElementType(); const CorElementType destElType = destTH.GetVerifierCorElementType(); const unsigned int srcSize = GetSizeForCorElementType(srcElType); const unsigned int destSize = GetSizeForCorElementType(destElType); BYTE* srcData = (BYTE*) pSrc->GetDataPtr() + srcIndex * srcSize; BYTE* data = (BYTE*) pDest->GetDataPtr() + destIndex * destSize; _ASSERTE(srcElType != destElType); // We shouldn't be here if these are the same type. _ASSERTE(CorTypeInfo::IsPrimitiveType_NoThrow(srcElType) && CorTypeInfo::IsPrimitiveType_NoThrow(destElType)); for(; length>0; length--, srcData += srcSize, data += destSize) { // We pretty much have to do some fancy datatype mangling every time here, for // converting w/ sign extension and floating point conversions. switch (srcElType) { case ELEMENT_TYPE_U1: switch (destElType) { case ELEMENT_TYPE_R4: *(float*)data = *(UINT8*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(UINT8*)srcData; break; #ifndef BIGENDIAN default: *(UINT8*)data = *(UINT8*)srcData; memset(data+1, 0, destSize - 1); break; #else // BIGENDIAN case ELEMENT_TYPE_CHAR: case ELEMENT_TYPE_I2: case ELEMENT_TYPE_U2: *(INT16*)data = *(UINT8*)srcData; break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: *(INT32*)data = *(UINT8*)srcData; break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: *(INT64*)data = *(UINT8*)srcData; break; default: _ASSERTE(!"Array.Copy from U1 to another type hit unsupported widening conversion"); #endif // BIGENDIAN } break; case ELEMENT_TYPE_I1: switch (destElType) { case ELEMENT_TYPE_I2: *(INT16*)data = *(INT8*)srcData; break; case ELEMENT_TYPE_I4: *(INT32*)data = *(INT8*)srcData; break; case ELEMENT_TYPE_I8: *(INT64*)data = *(INT8*)srcData; break; case ELEMENT_TYPE_R4: *(float*)data = *(INT8*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(INT8*)srcData; break; default: _ASSERTE(!"Array.Copy from I1 to another type hit unsupported widening conversion"); } break; case ELEMENT_TYPE_U2: case ELEMENT_TYPE_CHAR: switch (destElType) { case ELEMENT_TYPE_R4: *(float*)data = *(UINT16*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(UINT16*)srcData; break; #ifndef BIGENDIAN default: *(UINT16*)data = *(UINT16*)srcData; memset(data+2, 0, destSize - 2); break; #else // BIGENDIAN case ELEMENT_TYPE_U2: case ELEMENT_TYPE_CHAR: *(UINT16*)data = *(UINT16*)srcData; break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: *(UINT32*)data = *(UINT16*)srcData; break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: *(UINT64*)data = *(UINT16*)srcData; break; default: _ASSERTE(!"Array.Copy from U1 to another type hit unsupported widening conversion"); #endif // BIGENDIAN } break; case ELEMENT_TYPE_I2: switch (destElType) { case ELEMENT_TYPE_I4: *(INT32*)data = *(INT16*)srcData; break; case ELEMENT_TYPE_I8: *(INT64*)data = *(INT16*)srcData; break; case ELEMENT_TYPE_R4: *(float*)data = *(INT16*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(INT16*)srcData; break; default: _ASSERTE(!"Array.Copy from I2 to another type hit unsupported widening conversion"); } break; case ELEMENT_TYPE_I4: switch (destElType) { case ELEMENT_TYPE_I8: *(INT64*)data = *(INT32*)srcData; break; case ELEMENT_TYPE_R4: *(float*)data = (float)*(INT32*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(INT32*)srcData; break; default: _ASSERTE(!"Array.Copy from I4 to another type hit unsupported widening conversion"); } break; case ELEMENT_TYPE_U4: switch (destElType) { case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: *(INT64*)data = *(UINT32*)srcData; break; case ELEMENT_TYPE_R4: *(float*)data = (float)*(UINT32*)srcData; break; case ELEMENT_TYPE_R8: *(double*)data = *(UINT32*)srcData; break; default: _ASSERTE(!"Array.Copy from U4 to another type hit unsupported widening conversion"); } break; case ELEMENT_TYPE_I8: if (destElType == ELEMENT_TYPE_R4) { *(float*) data = (float) *(INT64*)srcData; } else { _ASSERTE(destElType==ELEMENT_TYPE_R8); *(double*) data = (double) *(INT64*)srcData; } break; case ELEMENT_TYPE_U8: if (destElType == ELEMENT_TYPE_R4) { //*(float*) data = (float) *(UINT64*)srcData; INT64 srcVal = *(INT64*)srcData; float f = (float) srcVal; if (srcVal < 0) f += 4294967296.0f * 4294967296.0f; // This is 2^64 *(float*) data = f; } else { _ASSERTE(destElType==ELEMENT_TYPE_R8); //*(double*) data = (double) *(UINT64*)srcData; INT64 srcVal = *(INT64*)srcData; double d = (double) srcVal; if (srcVal < 0) d += 4294967296.0 * 4294967296.0; // This is 2^64 *(double*) data = d; } break; case ELEMENT_TYPE_R4: *(double*) data = *(float*)srcData; break; default: _ASSERTE(!"Fell through outer switch in PrimitiveWiden! Unknown primitive type for source array!"); } } } // // This is a GC safe variant of the memmove intrinsic. It sets the cards, and guarantees that the object references in the GC heap are // updated atomically. // // The CRT version of memmove does not always guarantee that updates of aligned fields stay atomic (e.g. it is using "rep movsb" in some cases). // Type safety guarantees and background GC scanning requires object references in GC heap to be updated atomically. // void memmoveGCRefs(void *dest, const void *src, size_t len) { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_COOPERATIVE; } CONTRACTL_END; _ASSERTE(dest != nullptr); _ASSERTE(src != nullptr); // Make sure everything is pointer aligned _ASSERTE(IS_ALIGNED(dest, sizeof(SIZE_T))); _ASSERTE(IS_ALIGNED(src, sizeof(SIZE_T))); _ASSERTE(IS_ALIGNED(len, sizeof(SIZE_T))); _ASSERTE(CheckPointer(dest)); _ASSERTE(CheckPointer(src)); if (len != 0 && dest != src) { InlinedMemmoveGCRefsHelper(dest, src, len); } } FCIMPL5(void, ArrayNative::CopySlow, ArrayBase* pSrc, INT32 iSrcIndex, ArrayBase* pDst, INT32 iDstIndex, INT32 iLength) { FCALL_CONTRACT; struct _gc { BASEARRAYREF pSrc; BASEARRAYREF pDst; } gc; gc.pSrc = (BASEARRAYREF)pSrc; gc.pDst = (BASEARRAYREF)pDst; // cannot pass null for source or destination _ASSERTE(gc.pSrc != NULL && gc.pDst != NULL); // source and destination must be arrays _ASSERTE(gc.pSrc->GetMethodTable()->IsArray()); _ASSERTE(gc.pDst->GetMethodTable()->IsArray()); _ASSERTE(gc.pSrc->GetRank() == gc.pDst->GetRank()); // array bounds checking _ASSERTE(iLength >= 0); _ASSERTE(iSrcIndex >= 0); _ASSERTE(iDstIndex >= 0); _ASSERTE((DWORD)(iSrcIndex + iLength) <= gc.pSrc->GetNumComponents()); _ASSERTE((DWORD)(iDstIndex + iLength) <= gc.pDst->GetNumComponents()); HELPER_METHOD_FRAME_BEGIN_PROTECT(gc); int r = CanAssignArrayType(gc.pSrc, gc.pDst); if (r == AssignWrongType) COMPlusThrow(kArrayTypeMismatchException, W("ArrayTypeMismatch_CantAssignType")); if (iLength > 0) { switch (r) { case AssignUnboxValueClass: UnBoxEachElement(gc.pSrc, iSrcIndex, gc.pDst, iDstIndex, iLength); break; case AssignBoxValueClassOrPrimitive: BoxEachElement(gc.pSrc, iSrcIndex, gc.pDst, iDstIndex, iLength); break; case AssignMustCast: CastCheckEachElement(gc.pSrc, iSrcIndex, gc.pDst, iDstIndex, iLength); break; case AssignPrimitiveWiden: PrimitiveWiden(gc.pSrc, iSrcIndex, gc.pDst, iDstIndex, iLength); break; default: _ASSERTE(!"Fell through switch in Array.Copy!"); } } HELPER_METHOD_FRAME_END(); } FCIMPLEND // Check we're allowed to create an array with the given element type. void ArrayNative::CheckElementType(TypeHandle elementType) { // Checks apply recursively for arrays of arrays etc. while (elementType.IsArray()) { elementType = elementType.GetArrayElementTypeHandle(); } // Check for simple types first. if (!elementType.IsTypeDesc()) { MethodTable *pMT = elementType.AsMethodTable(); // Check for byref-like types. if (pMT->IsByRefLike()) COMPlusThrow(kNotSupportedException, W("NotSupported_ByRefLikeArray")); // Check for open generic types. if (pMT->IsGenericTypeDefinition() || pMT->ContainsGenericVariables()) COMPlusThrow(kNotSupportedException, W("NotSupported_OpenType")); // Check for Void. if (elementType.GetSignatureCorElementType() == ELEMENT_TYPE_VOID) COMPlusThrow(kNotSupportedException, W("NotSupported_VoidArray")); } else { // ByRefs and generic type variables are never allowed. if (elementType.IsByRef() || elementType.IsGenericVariable()) COMPlusThrow(kNotSupportedException, W("NotSupported_Type")); } } FCIMPL4(Object*, ArrayNative::CreateInstance, ReflectClassBaseObject* pElementTypeUNSAFE, INT32 rank, INT32* pLengths, INT32* pLowerBounds) { CONTRACTL { FCALL_CHECK; PRECONDITION(rank > 0); PRECONDITION(CheckPointer(pLengths)); PRECONDITION(CheckPointer(pLowerBounds, NULL_OK)); } CONTRACTL_END; OBJECTREF pRet = NULL; REFLECTCLASSBASEREF pElementType = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(pElementTypeUNSAFE); // pLengths and pLowerBounds are pinned buffers. No need to protect them. HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(pElementType); TypeHandle elementType(pElementType->GetType()); CheckElementType(elementType); CorElementType CorType = elementType.GetSignatureCorElementType(); CorElementType kind = ELEMENT_TYPE_ARRAY; // Is it ELEMENT_TYPE_SZARRAY array? if (rank == 1 && (pLowerBounds == NULL || pLowerBounds[0] == 0) #ifdef FEATURE_64BIT_ALIGNMENT // On platforms where 64-bit types require 64-bit alignment and don't obtain it naturally force us // through the slow path where this will be handled. && (CorType != ELEMENT_TYPE_I8) && (CorType != ELEMENT_TYPE_U8) && (CorType != ELEMENT_TYPE_R8) #endif ) { // Shortcut for common cases if (CorTypeInfo::IsPrimitiveType(CorType)) { pRet = AllocatePrimitiveArray(CorType,pLengths[0]); goto Done; } else if (CorTypeInfo::IsObjRef(CorType)) { pRet = AllocateObjectArray(pLengths[0],elementType); goto Done; } kind = ELEMENT_TYPE_SZARRAY; pLowerBounds = NULL; } { // Find the Array class... TypeHandle typeHnd = ClassLoader::LoadArrayTypeThrowing(elementType, kind, rank); _ASSERTE(rank < MAX_RANK); // Ensures that the stack buffer size allocations below won't overlow DWORD boundsSize = 0; INT32* bounds; if (pLowerBounds != NULL) { boundsSize = 2 * rank; bounds = (INT32*) _alloca(boundsSize * sizeof(INT32)); for (int i=0;i<rank;i++) { bounds[2*i] = pLowerBounds[i]; bounds[2*i+1] = pLengths[i]; } } else { boundsSize = rank; bounds = (INT32*) _alloca(boundsSize * sizeof(INT32)); // We need to create a private copy of pLengths to avoid holes caused // by caller mutating the array for (int i=0; i < rank; i++) bounds[i] = pLengths[i]; } pRet = AllocateArrayEx(typeHnd, bounds, boundsSize); } Done: ; HELPER_METHOD_FRAME_END(); return OBJECTREFToObject(pRet); } FCIMPLEND FCIMPL2(Object*, ArrayNative::GetValue, ArrayBase* refThisUNSAFE, INT_PTR flattenedIndex) { CONTRACTL { FCALL_CHECK; } CONTRACTL_END; BASEARRAYREF refThis(refThisUNSAFE); TypeHandle arrayElementType = refThis->GetArrayElementTypeHandle(); // Legacy behavior if (arrayElementType.IsTypeDesc()) { CorElementType elemtype = arrayElementType.AsTypeDesc()->GetInternalCorElementType(); if (elemtype == ELEMENT_TYPE_PTR || elemtype == ELEMENT_TYPE_FNPTR) FCThrowRes(kNotSupportedException, W("NotSupported_Type")); } _ASSERTE((SIZE_T)flattenedIndex < refThis->GetNumComponents()); void* pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); OBJECTREF Obj; MethodTable* pElementTypeMT = arrayElementType.GetMethodTable(); if (pElementTypeMT->IsValueType()) { HELPER_METHOD_FRAME_BEGIN_RET_0(); Obj = pElementTypeMT->Box(pData); HELPER_METHOD_FRAME_END(); } else { Obj = ObjectToOBJECTREF(*((Object**)pData)); } return OBJECTREFToObject(Obj); } FCIMPLEND FCIMPL3(void, ArrayNative::SetValue, ArrayBase* refThisUNSAFE, Object* objUNSAFE, INT_PTR flattenedIndex) { FCALL_CONTRACT; BASEARRAYREF refThis(refThisUNSAFE); OBJECTREF obj(objUNSAFE); TypeHandle arrayElementType = refThis->GetArrayElementTypeHandle(); // Legacy behavior if (arrayElementType.IsTypeDesc()) { CorElementType elemtype = arrayElementType.AsTypeDesc()->GetInternalCorElementType(); if (elemtype == ELEMENT_TYPE_PTR || elemtype == ELEMENT_TYPE_FNPTR) FCThrowResVoid(kNotSupportedException, W("NotSupported_Type")); } _ASSERTE((SIZE_T)flattenedIndex < refThis->GetNumComponents()); MethodTable* pElementTypeMT = arrayElementType.GetMethodTable(); PREFIX_ASSUME(NULL != pElementTypeMT); void* pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); if (obj == NULL) { // Null is the universal zero... if (pElementTypeMT->IsValueType()) InitValueClass(pData,pElementTypeMT); else ClearObjectReference((OBJECTREF*)pData); } else if (arrayElementType == TypeHandle(g_pObjectClass)) { // Everything is compatible with Object SetObjectReference((OBJECTREF*)pData,(OBJECTREF)obj); } else if (!pElementTypeMT->IsValueType()) { if (ObjIsInstanceOfCached(OBJECTREFToObject(obj), arrayElementType) != TypeHandle::CanCast) { HELPER_METHOD_FRAME_BEGIN_2(refThis, obj); if (!ObjIsInstanceOf(OBJECTREFToObject(obj), arrayElementType)) COMPlusThrow(kInvalidCastException,W("InvalidCast_StoreArrayElement")); HELPER_METHOD_FRAME_END(); // Refresh pData in case GC moved objects around pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); } SetObjectReference((OBJECTREF*)pData,obj); } else { // value class or primitive type if (!pElementTypeMT->UnBoxInto(pData, obj)) { HELPER_METHOD_FRAME_BEGIN_2(refThis, obj); ARG_SLOT value = 0; // Allow enum -> primitive conversion, disallow primitive -> enum conversion TypeHandle thSrc = obj->GetTypeHandle(); CorElementType srcType = thSrc.GetVerifierCorElementType(); CorElementType targetType = arrayElementType.GetSignatureCorElementType(); if (!InvokeUtil::IsPrimitiveType(srcType) || !InvokeUtil::IsPrimitiveType(targetType)) COMPlusThrow(kInvalidCastException, W("InvalidCast_StoreArrayElement")); // Get a properly widened type InvokeUtil::CreatePrimitiveValue(targetType,srcType,obj,&value); // Refresh pData in case GC moved objects around pData = refThis->GetDataPtr() + flattenedIndex * refThis->GetComponentSize(); UINT cbSize = CorTypeInfo::Size(targetType); memcpyNoGCRefs(pData, ArgSlotEndianessFixup(&value, cbSize), cbSize); HELPER_METHOD_FRAME_END(); } } } FCIMPLEND // This method will initialize an array from a TypeHandle to a field. FCIMPL2_IV(void, ArrayNative::InitializeArray, ArrayBase* pArrayRef, FCALLRuntimeFieldHandle structField) { FCALL_CONTRACT; BASEARRAYREF arr = BASEARRAYREF(pArrayRef); REFLECTFIELDREF refField = (REFLECTFIELDREF)ObjectToOBJECTREF(FCALL_RFH_TO_REFLECTFIELD(structField)); HELPER_METHOD_FRAME_BEGIN_2(arr, refField); if ((arr == 0) || (refField == NULL)) COMPlusThrow(kArgumentNullException); FieldDesc* pField = (FieldDesc*) refField->GetField(); if (!pField->IsRVA()) COMPlusThrow(kArgumentException); // Report the RVA field to the logger. g_IBCLogger.LogRVADataAccess(pField); // Note that we do not check that the field is actually in the PE file that is initializing // the array. Basically the data being published is can be accessed by anyone with the proper // permissions (C# marks these as assembly visibility, and thus are protected from outside // snooping) if (!CorTypeInfo::IsPrimitiveType(arr->GetArrayElementType()) && !arr->GetArrayElementTypeHandle().IsEnum()) COMPlusThrow(kArgumentException); SIZE_T dwCompSize = arr->GetComponentSize(); SIZE_T dwElemCnt = arr->GetNumComponents(); SIZE_T dwTotalSize = dwCompSize * dwElemCnt; DWORD size = pField->LoadSize(); // make certain you don't go off the end of the rva static if (dwTotalSize > size) COMPlusThrow(kArgumentException); void *src = pField->GetStaticAddressHandle(NULL); void *dest = arr->GetDataPtr(); #if BIGENDIAN DWORD i; switch (dwCompSize) { case 1: memcpyNoGCRefs(dest, src, dwElemCnt); break; case 2: for (i = 0; i < dwElemCnt; i++) *((UINT16*)dest + i) = GET_UNALIGNED_VAL16((UINT16*)src + i); break; case 4: for (i = 0; i < dwElemCnt; i++) *((UINT32*)dest + i) = GET_UNALIGNED_VAL32((UINT32*)src + i); break; case 8: for (i = 0; i < dwElemCnt; i++) *((UINT64*)dest + i) = GET_UNALIGNED_VAL64((UINT64*)src + i); break; default: // should not reach here. UNREACHABLE_MSG("Incorrect primitive type size!"); break; } #else memcpyNoGCRefs(dest, src, dwTotalSize); #endif HELPER_METHOD_FRAME_END(); } FCIMPLEND FCIMPL3_VVI(void*, ArrayNative::GetSpanDataFrom, FCALLRuntimeFieldHandle structField, FCALLRuntimeTypeHandle targetTypeUnsafe, INT32* count) { FCALL_CONTRACT; struct { REFLECTFIELDREF refField; REFLECTCLASSBASEREF refClass; } gc; gc.refField = (REFLECTFIELDREF)ObjectToOBJECTREF(FCALL_RFH_TO_REFLECTFIELD(structField)); gc.refClass = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(FCALL_RTH_TO_REFLECTCLASS(targetTypeUnsafe)); void* data; HELPER_METHOD_FRAME_BEGIN_RET_PROTECT(gc); FieldDesc* pField = (FieldDesc*)gc.refField->GetField(); if (!pField->IsRVA()) COMPlusThrow(kArgumentException); TypeHandle targetTypeHandle = gc.refClass->GetType(); if (!CorTypeInfo::IsPrimitiveType(targetTypeHandle.GetSignatureCorElementType()) && !targetTypeHandle.IsEnum()) COMPlusThrow(kArgumentException); DWORD totalSize = pField->LoadSize(); DWORD targetTypeSize = targetTypeHandle.GetSize(); // Report the RVA field to the logger. g_IBCLogger.LogRVADataAccess(pField); data = pField->GetStaticAddressHandle(NULL); _ASSERTE(data != NULL); _ASSERTE(count != NULL); if (AlignUp((UINT_PTR)data, targetTypeSize) != (UINT_PTR)data) COMPlusThrow(kArgumentException); *count = (INT32)totalSize / targetTypeSize; #if BIGENDIAN COMPlusThrow(kPlatformNotSupportedException); #endif HELPER_METHOD_FRAME_END(); return data; } FCIMPLEND
1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/coreclr/classlibnative/bcltype/arraynative.h
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // File: ArrayNative.h // // // ArrayNative // This file defines the native methods for the Array // #ifndef _ARRAYNATIVE_H_ #define _ARRAYNATIVE_H_ #include "fcall.h" #include "runtimehandles.h" struct FCALLRuntimeFieldHandle { ReflectFieldObject *pFieldDONOTUSEDIRECTLY; }; #define FCALL_RFH_TO_REFLECTFIELD(x) (x).pFieldDONOTUSEDIRECTLY class ArrayNative { public: static FCDECL1(INT32, GetCorElementTypeOfElementType, ArrayBase* arrayUNSAFE); static FCDECL1(void, Initialize, ArrayBase* pArray); static FCDECL2(FC_BOOL_RET, IsSimpleCopy, ArrayBase* pSrc, ArrayBase* pDst); static FCDECL5(void, CopySlow, ArrayBase* pSrc, INT32 iSrcIndex, ArrayBase* pDst, INT32 iDstIndex, INT32 iLength); // This method will create a new array of type type, with zero lower // bounds and rank. static FCDECL4(Object*, CreateInstance, void* elementTypeHandle, INT32 rank, INT32* pLengths, INT32* pBounds); // This method will return a TypedReference to the array element static FCDECL2(Object*, GetValue, ArrayBase* refThisUNSAFE, INT_PTR flattenedIndex); // This set of methods will set a value in an array static FCDECL3(void, SetValue, ArrayBase* refThisUNSAFE, Object* objUNSAFE, INT_PTR flattenedIndex); // This method will initialize an array from a TypeHandle // to a field. static FCDECL2_IV(void, InitializeArray, ArrayBase* vArrayRef, FCALLRuntimeFieldHandle structField); // This method will acquire data to create a span from a TypeHandle // to a field. static FCDECL3_VVI(void*, GetSpanDataFrom, FCALLRuntimeFieldHandle structField, FCALLRuntimeTypeHandle targetTypeUnsafe, INT32* count); private: // Helper for CreateInstance static void CheckElementType(TypeHandle elementType); // Return values for CanAssignArrayType enum AssignArrayEnum { AssignWrongType, AssignMustCast, AssignBoxValueClassOrPrimitive, AssignUnboxValueClass, AssignPrimitiveWiden, }; // The following functions are all helpers for ArrayCopy static AssignArrayEnum CanAssignArrayType(const BASEARRAYREF pSrc, const BASEARRAYREF pDest); static void CastCheckEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length); static void BoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length); static void UnBoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length); static void PrimitiveWiden(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length); }; #endif // _ARRAYNATIVE_H_
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // File: ArrayNative.h // // // ArrayNative // This file defines the native methods for the Array // #ifndef _ARRAYNATIVE_H_ #define _ARRAYNATIVE_H_ #include "fcall.h" #include "runtimehandles.h" struct FCALLRuntimeFieldHandle { ReflectFieldObject *pFieldDONOTUSEDIRECTLY; }; #define FCALL_RFH_TO_REFLECTFIELD(x) (x).pFieldDONOTUSEDIRECTLY class ArrayNative { public: static FCDECL1(INT32, GetCorElementTypeOfElementType, ArrayBase* arrayUNSAFE); static FCDECL1(void, Initialize, ArrayBase* pArray); static FCDECL2(FC_BOOL_RET, IsSimpleCopy, ArrayBase* pSrc, ArrayBase* pDst); static FCDECL5(void, CopySlow, ArrayBase* pSrc, INT32 iSrcIndex, ArrayBase* pDst, INT32 iDstIndex, INT32 iLength); static FCDECL4(Object*, CreateInstance, ReflectClassBaseObject* pElementTypeUNSAFE, INT32 rank, INT32* pLengths, INT32* pBounds); // This method will return a TypedReference to the array element static FCDECL2(Object*, GetValue, ArrayBase* refThisUNSAFE, INT_PTR flattenedIndex); // This set of methods will set a value in an array static FCDECL3(void, SetValue, ArrayBase* refThisUNSAFE, Object* objUNSAFE, INT_PTR flattenedIndex); // This method will initialize an array from a TypeHandle // to a field. static FCDECL2_IV(void, InitializeArray, ArrayBase* vArrayRef, FCALLRuntimeFieldHandle structField); // This method will acquire data to create a span from a TypeHandle // to a field. static FCDECL3_VVI(void*, GetSpanDataFrom, FCALLRuntimeFieldHandle structField, FCALLRuntimeTypeHandle targetTypeUnsafe, INT32* count); private: // Helper for CreateInstance static void CheckElementType(TypeHandle elementType); // Return values for CanAssignArrayType enum AssignArrayEnum { AssignWrongType, AssignMustCast, AssignBoxValueClassOrPrimitive, AssignUnboxValueClass, AssignPrimitiveWiden, }; // The following functions are all helpers for ArrayCopy static AssignArrayEnum CanAssignArrayType(const BASEARRAYREF pSrc, const BASEARRAYREF pDest); static void CastCheckEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length); static void BoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length); static void UnBoxEachElement(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length); static void PrimitiveWiden(BASEARRAYREF pSrc, unsigned int srcIndex, BASEARRAYREF pDest, unsigned int destIndex, unsigned int length); }; #endif // _ARRAYNATIVE_H_
1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. //Internal.Runtime.Augments //------------------------------------------------- // Why does this exist?: // Reflection.Execution cannot physically live in System.Private.CoreLib.dll // as it has a dependency on System.Reflection.Metadata. Its inherently // low-level nature means, however, it is closely tied to System.Private.CoreLib.dll. // This contract provides the two-communication between those two .dll's. // // // Implemented by: // System.Private.CoreLib.dll // // Consumed by: // Reflection.Execution.dll using System; using System.Runtime; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Threading; using Internal.Runtime.CompilerHelpers; using Internal.Runtime.CompilerServices; namespace Internal.Runtime.Augments { using BinderBundle = System.Reflection.BinderBundle; using Pointer = System.Reflection.Pointer; [ReflectionBlocked] public static class RuntimeAugments { /// <summary> /// Callbacks used for metadata-based stack trace resolution. /// </summary> private static StackTraceMetadataCallbacks s_stackTraceMetadataCallbacks; //============================================================================================== // One-time initialization. //============================================================================================== [CLSCompliant(false)] public static void Initialize(ReflectionExecutionDomainCallbacks callbacks) { s_reflectionExecutionDomainCallbacks = callbacks; } [CLSCompliant(false)] public static void InitializeLookups(TypeLoaderCallbacks callbacks) { s_typeLoaderCallbacks = callbacks; } [CLSCompliant(false)] public static void InitializeInteropLookups(InteropCallbacks callbacks) { s_interopCallbacks = callbacks; } [CLSCompliant(false)] public static void InitializeStackTraceMetadataSupport(StackTraceMetadataCallbacks callbacks) { s_stackTraceMetadataCallbacks = callbacks; } //============================================================================================== // Access to the underlying execution engine's object allocation routines. //============================================================================================== // // Perform the equivalent of a "newobj", but without invoking any constructors. Other than the MethodTable, the result object is zero-initialized. // // Special cases: // // Strings: The .ctor performs both the construction and initialization // and compiler special cases these. // // Nullable<T>: the boxed result is the underlying type rather than Nullable so the constructor // cannot truly initialize it. // // In these cases, this helper returns "null" and ConstructorInfo.Invoke() must deal with these specially. // public static object NewObject(RuntimeTypeHandle typeHandle) { EETypePtr eeType = typeHandle.ToEETypePtr(); if (eeType.IsNullable || eeType == EETypePtr.EETypePtrOf<string>() ) return null; return RuntimeImports.RhNewObject(eeType); } // // Helper API to perform the equivalent of a "newobj" for any MethodTable. // Unlike the NewObject API, this is the raw version that does not special case any MethodTable, and should be used with // caution for very specific scenarios. // public static object RawNewObject(RuntimeTypeHandle typeHandle) { return RuntimeImports.RhNewObject(typeHandle.ToEETypePtr()); } // // Perform the equivalent of a "newarr" The resulting array is zero-initialized. // public static Array NewArray(RuntimeTypeHandle typeHandleForArrayType, int count) { // Don't make the easy mistake of passing in the element MethodTable rather than the "array of element" MethodTable. Debug.Assert(typeHandleForArrayType.ToEETypePtr().IsSzArray); return RuntimeImports.RhNewArray(typeHandleForArrayType.ToEETypePtr(), count); } // // Perform the equivalent of a "newarr" The resulting array is zero-initialized. // // Note that invoking NewMultiDimArray on a rank-1 array type is not the same thing as invoking NewArray(). // // As a concession to the fact that we don't actually support non-zero lower bounds, "lowerBounds" accepts "null" // to avoid unnecessary array allocations by the caller. // [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "The compiler ensures that if we have a TypeHandle of a Rank-1 MdArray, we also generated the SzArray.")] public static unsafe Array NewMultiDimArray(RuntimeTypeHandle typeHandleForArrayType, int[] lengths, int[]? lowerBounds) { Debug.Assert(lengths != null); Debug.Assert(lowerBounds == null || lowerBounds.Length == lengths.Length); if (lowerBounds != null) { foreach (int lowerBound in lowerBounds) { if (lowerBound != 0) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NonZeroLowerBound); } } if (lengths.Length == 1) { // We just checked above that all lower bounds are zero. In that case, we should actually allocate // a new SzArray instead. RuntimeTypeHandle elementTypeHandle = new RuntimeTypeHandle(typeHandleForArrayType.ToEETypePtr().ArrayElementType); int length = lengths[0]; if (length < 0) throw new OverflowException(); // For compat: we need to throw OverflowException(): Array.CreateInstance throws ArgumentOutOfRangeException() return Array.CreateInstance(Type.GetTypeFromHandle(elementTypeHandle), length); } // Create a local copy of the lenghts that cannot be motified by the caller int* pLengths = stackalloc int[lengths.Length]; for (int i = 0; i < lengths.Length; i++) pLengths[i] = lengths[i]; return Array.NewMultiDimArray(typeHandleForArrayType.ToEETypePtr(), pLengths, lengths.Length); } // // Helper to create an array from a newobj instruction // public static unsafe Array NewObjArray(RuntimeTypeHandle typeHandleForArrayType, int[] arguments) { EETypePtr eeTypePtr = typeHandleForArrayType.ToEETypePtr(); Debug.Assert(eeTypePtr.IsArray); fixed (int* pArguments = arguments) { return ArrayHelpers.NewObjArray((IntPtr)eeTypePtr.ToPointer(), arguments.Length, pArguments); } } public static ref byte GetSzArrayElementAddress(Array array, int index) { if ((uint)index >= (uint)array.Length) throw new IndexOutOfRangeException(); ref byte start = ref Unsafe.As<RawArrayData>(array).Data; return ref Unsafe.Add(ref start, (IntPtr)(nint)((nuint)index * array.ElementSize)); } public static IntPtr GetAllocateObjectHelperForType(RuntimeTypeHandle type) { return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeHelperKind.AllocateObject); } public static IntPtr GetAllocateArrayHelperForType(RuntimeTypeHandle type) { return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeHelperKind.AllocateArray); } public static IntPtr GetCastingHelperForType(RuntimeTypeHandle type, bool throwing) { return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), throwing ? RuntimeHelperKind.CastClass : RuntimeHelperKind.IsInst); } public static IntPtr GetDispatchMapForType(RuntimeTypeHandle typeHandle) { return CreateEETypePtr(typeHandle).DispatchMap; } public static IntPtr GetFallbackDefaultConstructor() { return Activator.GetFallbackDefaultConstructor(); } // // Helper to create a delegate on a runtime-supplied type. // public static Delegate CreateDelegate(RuntimeTypeHandle typeHandleForDelegate, IntPtr ldftnResult, object thisObject, bool isStatic, bool isOpen) { return Delegate.CreateDelegate(typeHandleForDelegate.ToEETypePtr(), ldftnResult, thisObject, isStatic: isStatic, isOpen: isOpen); } // // Helper to extract the artifact that uniquely identifies a method in the runtime mapping tables. // public static IntPtr GetDelegateLdFtnResult(Delegate d, out RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate, out bool isOpenResolver, out bool isInterpreterEntrypoint) { return d.GetFunctionPointer(out typeOfFirstParameterIfInstanceDelegate, out isOpenResolver, out isInterpreterEntrypoint); } public static void GetDelegateData(Delegate delegateObj, out object firstParameter, out object helperObject, out IntPtr extraFunctionPointerOrData, out IntPtr functionPointer) { firstParameter = delegateObj.m_firstParameter; helperObject = delegateObj.m_helperObject; extraFunctionPointerOrData = delegateObj.m_extraFunctionPointerOrData; functionPointer = delegateObj.m_functionPointer; } public static int GetLoadedModules(TypeManagerHandle[] resultArray) { return Internal.Runtime.CompilerHelpers.StartupCodeHelpers.GetLoadedModules(resultArray); } public static IntPtr GetOSModuleFromPointer(IntPtr pointerVal) { return RuntimeImports.RhGetOSModuleFromPointer(pointerVal); } public static unsafe bool FindBlob(TypeManagerHandle typeManager, int blobId, IntPtr ppbBlob, IntPtr pcbBlob) { return RuntimeImports.RhFindBlob(typeManager, (uint)blobId, (byte**)ppbBlob, (uint*)pcbBlob); } public static IntPtr GetPointerFromTypeHandle(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().RawValue; } public static TypeManagerHandle GetModuleFromTypeHandle(RuntimeTypeHandle typeHandle) { return RuntimeImports.RhGetModuleFromEEType(GetPointerFromTypeHandle(typeHandle)); } public static RuntimeTypeHandle CreateRuntimeTypeHandle(IntPtr ldTokenResult) { return new RuntimeTypeHandle(new EETypePtr(ldTokenResult)); } public static unsafe void StoreValueTypeField(IntPtr address, object fieldValue, RuntimeTypeHandle fieldType) { RuntimeImports.RhUnbox(fieldValue, ref *(byte*)address, fieldType.ToEETypePtr()); } public static unsafe ref byte GetRawData(object obj) { return ref obj.GetRawData(); } public static unsafe object LoadValueTypeField(IntPtr address, RuntimeTypeHandle fieldType) { return RuntimeImports.RhBox(fieldType.ToEETypePtr(), ref *(byte*)address); } public static unsafe object LoadPointerTypeField(IntPtr address, RuntimeTypeHandle fieldType) { return Pointer.Box(*(void**)address, Type.GetTypeFromHandle(fieldType)); } public static unsafe void StoreValueTypeField(ref byte address, object fieldValue, RuntimeTypeHandle fieldType) { RuntimeImports.RhUnbox(fieldValue, ref address, fieldType.ToEETypePtr()); } public static unsafe void StoreValueTypeField(object obj, int fieldOffset, object fieldValue, RuntimeTypeHandle fieldType) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); RuntimeImports.RhUnbox(fieldValue, ref address, fieldType.ToEETypePtr()); } public static unsafe object LoadValueTypeField(object obj, int fieldOffset, RuntimeTypeHandle fieldType) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); return RuntimeImports.RhBox(fieldType.ToEETypePtr(), ref address); } public static unsafe object LoadPointerTypeField(object obj, int fieldOffset, RuntimeTypeHandle fieldType) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); return Pointer.Box((void*)Unsafe.As<byte, IntPtr>(ref address), Type.GetTypeFromHandle(fieldType)); } public static unsafe void StoreReferenceTypeField(IntPtr address, object fieldValue) { Volatile.Write<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address), fieldValue); } public static unsafe object LoadReferenceTypeField(IntPtr address) { return Volatile.Read<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address)); } public static void StoreReferenceTypeField(object obj, int fieldOffset, object fieldValue) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); Volatile.Write<object>(ref Unsafe.As<byte, object>(ref address), fieldValue); } public static object LoadReferenceTypeField(object obj, int fieldOffset) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); return Unsafe.As<byte, object>(ref address); } [CLSCompliant(false)] public static void StoreValueTypeFieldValueIntoValueType(TypedReference typedReference, int fieldOffset, object fieldValue, RuntimeTypeHandle fieldTypeHandle) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); RuntimeImports.RhUnbox(fieldValue, ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset), fieldTypeHandle.ToEETypePtr()); } [CLSCompliant(false)] public static object LoadValueTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset, RuntimeTypeHandle fieldTypeHandle) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); Debug.Assert(fieldTypeHandle.ToEETypePtr().IsValueType); return RuntimeImports.RhBox(fieldTypeHandle.ToEETypePtr(), ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)); } [CLSCompliant(false)] public static void StoreReferenceTypeFieldValueIntoValueType(TypedReference typedReference, int fieldOffset, object fieldValue) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); Unsafe.As<byte, object>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)) = fieldValue; } [CLSCompliant(false)] public static object LoadReferenceTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); return Unsafe.As<byte, object>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)); } [CLSCompliant(false)] public static unsafe object LoadPointerTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset, RuntimeTypeHandle fieldTypeHandle) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); Debug.Assert(fieldTypeHandle.ToEETypePtr().IsPointer); IntPtr ptrValue = Unsafe.As<byte, IntPtr>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)); return Pointer.Box((void*)ptrValue, Type.GetTypeFromHandle(fieldTypeHandle)); } public static unsafe object GetThreadStaticBase(IntPtr cookie) { return ThreadStatics.GetThreadStaticBaseForType(*(TypeManagerSlot**)cookie, (int)*((IntPtr*)(cookie) + 1)); } public static unsafe int ObjectHeaderSize => sizeof(EETypePtr); [DebuggerGuidedStepThroughAttribute] public static object CallDynamicInvokeMethod( object thisPtr, IntPtr methodToCall, IntPtr dynamicInvokeHelperMethod, IntPtr dynamicInvokeHelperGenericDictionary, object defaultParametersContext, object[] parameters, BinderBundle binderBundle, bool wrapInTargetInvocationException, bool methodToCallIsThisCall) { object result = InvokeUtils.CallDynamicInvokeMethod( thisPtr, methodToCall, dynamicInvokeHelperMethod, dynamicInvokeHelperGenericDictionary, defaultParametersContext, parameters, binderBundle, wrapInTargetInvocationException, methodToCallIsThisCall); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); return result; } public static unsafe void EnsureClassConstructorRun(IntPtr staticClassConstructionContext) { StaticClassConstructionContext* context = (StaticClassConstructionContext*)staticClassConstructionContext; ClassConstructorRunner.EnsureClassConstructorRun(context); } public static object GetEnumValue(Enum e) { return e.GetValue(); } public static Type GetEnumUnderlyingType(RuntimeTypeHandle enumTypeHandle) { Debug.Assert(enumTypeHandle.ToEETypePtr().IsEnum); EETypeElementType elementType = enumTypeHandle.ToEETypePtr().ElementType; switch (elementType) { case EETypeElementType.Boolean: return typeof(bool); case EETypeElementType.Char: return typeof(char); case EETypeElementType.SByte: return typeof(sbyte); case EETypeElementType.Byte: return typeof(byte); case EETypeElementType.Int16: return typeof(short); case EETypeElementType.UInt16: return typeof(ushort); case EETypeElementType.Int32: return typeof(int); case EETypeElementType.UInt32: return typeof(uint); case EETypeElementType.Int64: return typeof(long); case EETypeElementType.UInt64: return typeof(ulong); default: throw new NotSupportedException(); } } public static RuntimeTypeHandle GetRelatedParameterTypeHandle(RuntimeTypeHandle parameterTypeHandle) { EETypePtr elementType = parameterTypeHandle.ToEETypePtr().ArrayElementType; return new RuntimeTypeHandle(elementType); } public static bool IsValueType(RuntimeTypeHandle type) { return type.ToEETypePtr().IsValueType; } public static bool IsInterface(RuntimeTypeHandle type) { return type.ToEETypePtr().IsInterface; } public static unsafe object Box(RuntimeTypeHandle type, IntPtr address) { return RuntimeImports.RhBox(type.ToEETypePtr(), ref *(byte*)address); } // Used to mutate the first parameter in a closed static delegate. Note that this does no synchronization of any kind; // use only on delegate instances you're sure nobody else is using. public static void SetClosedStaticDelegateFirstParameter(Delegate del, object firstParameter) { del.SetClosedStaticFirstParameter(firstParameter); } //============================================================================================== // Execution engine policies. //============================================================================================== // // This returns a generic type with one generic parameter (representing the array element type) // whose base type and interface list determines what TypeInfo.BaseType and TypeInfo.ImplementedInterfaces // return for types that return true for IsArray. // public static RuntimeTypeHandle ProjectionTypeForArrays { get { return typeof(Array<>).TypeHandle; } } // // Returns the name of a virtual assembly we dump types private class library-Reflectable ty[es for internal class library use. // The assembly binder visible to apps will never reveal this assembly. // // Note that this is not versionable as it is exposed as a const (and needs to be a const so we can used as a custom attribute argument - which // is the other reason this string is not versionable.) // public const string HiddenScopeAssemblyName = "HiddenScope, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; // // This implements the "IsAssignableFrom()" api for runtime-created types. By policy, we let the underlying runtime decide assignability. // public static bool IsAssignableFrom(RuntimeTypeHandle dstType, RuntimeTypeHandle srcType) { EETypePtr dstEEType = dstType.ToEETypePtr(); EETypePtr srcEEType = srcType.ToEETypePtr(); return RuntimeImports.AreTypesAssignable(srcEEType, dstEEType); } public static bool IsInstanceOfInterface(object obj, RuntimeTypeHandle interfaceTypeHandle) { return (null != RuntimeImports.IsInstanceOfInterface(interfaceTypeHandle.ToEETypePtr(), obj)); } // // Return a type's base type using the runtime type system. If the underlying runtime type system does not support // this operation, return false and TypeInfo.BaseType will fall back to metadata. // // Note that "default(RuntimeTypeHandle)" is a valid result that will map to a null result. (For example, System.Object has a "null" base type.) // public static bool TryGetBaseType(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle baseTypeHandle) { EETypePtr eeType = typeHandle.ToEETypePtr(); if (eeType.IsGenericTypeDefinition || eeType.IsPointer || eeType.IsByRef) { baseTypeHandle = default(RuntimeTypeHandle); return false; } baseTypeHandle = new RuntimeTypeHandle(eeType.BaseType); return true; } // // Return a type's transitive implemeted interface list using the runtime type system. If the underlying runtime type system does not support // this operation, return null and TypeInfo.ImplementedInterfaces will fall back to metadata. Note that returning null is not the same thing // as returning a 0-length enumerable. // public static IEnumerable<RuntimeTypeHandle> TryGetImplementedInterfaces(RuntimeTypeHandle typeHandle) { EETypePtr eeType = typeHandle.ToEETypePtr(); if (eeType.IsGenericTypeDefinition || eeType.IsPointer || eeType.IsByRef) return null; LowLevelList<RuntimeTypeHandle> implementedInterfaces = new LowLevelList<RuntimeTypeHandle>(); for (int i = 0; i < eeType.Interfaces.Count; i++) { EETypePtr ifcEEType = eeType.Interfaces[i]; RuntimeTypeHandle ifcrth = new RuntimeTypeHandle(ifcEEType); if (Callbacks.IsReflectionBlocked(ifcrth)) continue; implementedInterfaces.Add(ifcrth); } return implementedInterfaces.ToArray(); } private static RuntimeTypeHandle CreateRuntimeTypeHandle(EETypePtr eeType) { return new RuntimeTypeHandle(eeType); } private static EETypePtr CreateEETypePtr(RuntimeTypeHandle runtimeTypeHandle) { return runtimeTypeHandle.ToEETypePtr(); } public static int GetGCDescSize(RuntimeTypeHandle typeHandle) { EETypePtr eeType = CreateEETypePtr(typeHandle); return RuntimeImports.RhGetGCDescSize(eeType); } public static int GetInterfaceCount(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().Interfaces.Count; } public static RuntimeTypeHandle GetInterface(RuntimeTypeHandle typeHandle, int index) { EETypePtr eeInterface = typeHandle.ToEETypePtr().Interfaces[index]; return CreateRuntimeTypeHandle(eeInterface); } public static IntPtr NewInterfaceDispatchCell(RuntimeTypeHandle interfaceTypeHandle, int slotNumber) { EETypePtr eeInterfaceType = CreateEETypePtr(interfaceTypeHandle); IntPtr cell = RuntimeImports.RhNewInterfaceDispatchCell(eeInterfaceType, slotNumber); if (cell == IntPtr.Zero) throw new OutOfMemoryException(); return cell; } public static int GetValueTypeSize(RuntimeTypeHandle typeHandle) { return (int)typeHandle.ToEETypePtr().ValueTypeSize; } [Intrinsic] public static RuntimeTypeHandle GetCanonType(CanonTypeKind kind) { // Compiler needs to expand this. This is not expressible in IL. throw new NotSupportedException(); } public static RuntimeTypeHandle GetGenericDefinition(RuntimeTypeHandle typeHandle) { EETypePtr eeType = typeHandle.ToEETypePtr(); Debug.Assert(eeType.IsGeneric); return new RuntimeTypeHandle(eeType.GenericDefinition); } public static RuntimeTypeHandle GetGenericArgument(RuntimeTypeHandle typeHandle, int argumentIndex) { EETypePtr eeType = typeHandle.ToEETypePtr(); Debug.Assert(eeType.IsGeneric); return new RuntimeTypeHandle(eeType.Instantiation[argumentIndex]); } public static RuntimeTypeHandle GetGenericInstantiation(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle[] genericTypeArgumentHandles) { EETypePtr eeType = typeHandle.ToEETypePtr(); Debug.Assert(eeType.IsGeneric); var instantiation = eeType.Instantiation; genericTypeArgumentHandles = new RuntimeTypeHandle[instantiation.Length]; for (int i = 0; i < instantiation.Length; i++) { genericTypeArgumentHandles[i] = new RuntimeTypeHandle(instantiation[i]); } return new RuntimeTypeHandle(eeType.GenericDefinition); } public static bool IsGenericType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsGeneric; } public static bool IsArrayType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsArray; } public static bool IsByRefLike(RuntimeTypeHandle typeHandle) => typeHandle.ToEETypePtr().IsByRefLike; public static bool IsDynamicType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsDynamicType; } public static bool HasCctor(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().HasCctor; } public static RuntimeTypeHandle RuntimeTypeHandleOf<T>() { return new RuntimeTypeHandle(EETypePtr.EETypePtrOf<T>()); } public static IntPtr ResolveDispatchOnType(RuntimeTypeHandle instanceType, RuntimeTypeHandle interfaceType, int slot) { return RuntimeImports.RhResolveDispatchOnType(CreateEETypePtr(instanceType), CreateEETypePtr(interfaceType), checked((ushort)slot)); } public static IntPtr ResolveDispatch(object instance, RuntimeTypeHandle interfaceType, int slot) { return RuntimeImports.RhResolveDispatch(instance, CreateEETypePtr(interfaceType), checked((ushort)slot)); } public static IntPtr GVMLookupForSlot(RuntimeTypeHandle type, RuntimeMethodHandle slot) { return GenericVirtualMethodSupport.GVMLookupForSlot(type, slot); } public static bool IsUnmanagedPointerType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsPointer; } public static bool IsByRefType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsByRef; } public static bool IsGenericTypeDefinition(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsGenericTypeDefinition; } // // This implements the equivalent of the desktop's InvokeUtil::CanPrimitiveWiden() routine. // public static bool CanPrimitiveWiden(RuntimeTypeHandle srcType, RuntimeTypeHandle dstType) { EETypePtr srcEEType = srcType.ToEETypePtr(); EETypePtr dstEEType = dstType.ToEETypePtr(); if (srcEEType.IsGenericTypeDefinition || dstEEType.IsGenericTypeDefinition) return false; if (srcEEType.IsPointer || dstEEType.IsPointer) return false; if (srcEEType.IsByRef || dstEEType.IsByRef) return false; if (!srcEEType.IsPrimitive) return false; if (!dstEEType.IsPrimitive) return false; if (!srcEEType.CorElementTypeInfo.CanWidenTo(dstEEType.CorElementType)) return false; return true; } public static object CheckArgument(object srcObject, RuntimeTypeHandle dstType, BinderBundle binderBundle) { return InvokeUtils.CheckArgument(srcObject, dstType, binderBundle); } // FieldInfo.SetValueDirect() has a completely different set of rules on how to coerce the argument from // the other Reflection api. public static object CheckArgumentForDirectFieldAccess(object srcObject, RuntimeTypeHandle dstType) { return InvokeUtils.CheckArgument(srcObject, dstType.ToEETypePtr(), InvokeUtils.CheckArgumentSemantics.SetFieldDirect, binderBundle: null); } public static bool IsAssignable(object srcObject, RuntimeTypeHandle dstType) { EETypePtr srcEEType = srcObject.EETypePtr; return RuntimeImports.AreTypesAssignable(srcEEType, dstType.ToEETypePtr()); } //============================================================================================== // Nullable<> support //============================================================================================== public static bool IsNullable(RuntimeTypeHandle declaringTypeHandle) { return declaringTypeHandle.ToEETypePtr().IsNullable; } public static RuntimeTypeHandle GetNullableType(RuntimeTypeHandle nullableType) { EETypePtr theT = nullableType.ToEETypePtr().NullableType; return new RuntimeTypeHandle(theT); } /// <summary> /// Locate the file path for a given native application module. /// </summary> /// <param name="ip">Address inside the module</param> /// <param name="moduleBase">Module base address</param> public static unsafe string TryGetFullPathToApplicationModule(IntPtr ip, out IntPtr moduleBase) { moduleBase = RuntimeImports.RhGetOSModuleFromPointer(ip); if (moduleBase == IntPtr.Zero) return null; #if TARGET_UNIX // RhGetModuleFileName on Unix calls dladdr that accepts any ip. Avoid the redundant lookup // and pass the ip into RhGetModuleFileName directly. Also, older versions of Musl have a bug // that leads to crash with the redundant lookup. byte* pModuleNameUtf8; int numUtf8Chars = RuntimeImports.RhGetModuleFileName(ip, out pModuleNameUtf8); string modulePath = System.Text.Encoding.UTF8.GetString(pModuleNameUtf8, numUtf8Chars); #else // TARGET_UNIX char* pModuleName; int numChars = RuntimeImports.RhGetModuleFileName(moduleBase, out pModuleName); string modulePath = new string(pModuleName, 0, numChars); #endif // TARGET_UNIX return modulePath; } public static IntPtr GetRuntimeTypeHandleRawValue(RuntimeTypeHandle runtimeTypeHandle) { return runtimeTypeHandle.RawValue; } // if functionPointer points at an import or unboxing stub, find the target of the stub public static IntPtr GetCodeTarget(IntPtr functionPointer) { return RuntimeImports.RhGetCodeTarget(functionPointer); } public static IntPtr GetTargetOfUnboxingAndInstantiatingStub(IntPtr functionPointer) { return RuntimeImports.RhGetTargetOfUnboxingAndInstantiatingStub(functionPointer); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IntPtr RuntimeCacheLookup(IntPtr context, IntPtr signature, RuntimeObjectFactory factory, object contextObject, out IntPtr auxResult) { return TypeLoaderExports.RuntimeCacheLookupInCache(context, signature, factory, contextObject, out auxResult); } //============================================================================================== // Internals //============================================================================================== [CLSCompliant(false)] public static ReflectionExecutionDomainCallbacks CallbacksIfAvailable { get { return s_reflectionExecutionDomainCallbacks; } } [CLSCompliant(false)] public static ReflectionExecutionDomainCallbacks Callbacks { get { ReflectionExecutionDomainCallbacks callbacks = s_reflectionExecutionDomainCallbacks; Debug.Assert(callbacks != null); return callbacks; } } internal static TypeLoaderCallbacks TypeLoaderCallbacksIfAvailable { get { return s_typeLoaderCallbacks; } } internal static TypeLoaderCallbacks TypeLoaderCallbacks { get { TypeLoaderCallbacks callbacks = s_typeLoaderCallbacks; Debug.Assert(callbacks != null); return callbacks; } } internal static InteropCallbacks InteropCallbacks { get { InteropCallbacks callbacks = s_interopCallbacks; Debug.Assert(callbacks != null); return callbacks; } } internal static StackTraceMetadataCallbacks StackTraceCallbacksIfAvailable { get { return s_stackTraceMetadataCallbacks; } } public static string TryGetMethodDisplayStringFromIp(IntPtr ip) { StackTraceMetadataCallbacks callbacks = StackTraceCallbacksIfAvailable; if (callbacks == null) return null; ip = RuntimeImports.RhFindMethodStartAddress(ip); if (ip == IntPtr.Zero) return null; return callbacks.TryGetMethodNameFromStartAddress(ip); } private static volatile ReflectionExecutionDomainCallbacks s_reflectionExecutionDomainCallbacks; private static TypeLoaderCallbacks s_typeLoaderCallbacks; private static InteropCallbacks s_interopCallbacks; public static void ReportUnhandledException(Exception exception) { RuntimeExceptionHelpers.ReportUnhandledException(exception); } public static unsafe RuntimeTypeHandle GetRuntimeTypeHandleFromObjectReference(object obj) { return new RuntimeTypeHandle(obj.EETypePtr); } // Move memory which may be on the heap which may have object references in it. // In general, a memcpy on the heap is unsafe, but this is able to perform the // correct write barrier such that the GC is not incorrectly impacted. public static unsafe void BulkMoveWithWriteBarrier(IntPtr dmem, IntPtr smem, int size) { RuntimeImports.RhBulkMoveWithWriteBarrier(ref *(byte*)dmem.ToPointer(), ref *(byte*)smem.ToPointer(), (uint)size); } public static IntPtr GetUniversalTransitionThunk() { return RuntimeImports.RhGetUniversalTransitionThunk(); } public static object CreateThunksHeap(IntPtr commonStubAddress) { object newHeap = RuntimeImports.RhCreateThunksHeap(commonStubAddress); if (newHeap == null) throw new OutOfMemoryException(); return newHeap; } public static IntPtr AllocateThunk(object thunksHeap) { IntPtr newThunk = RuntimeImports.RhAllocateThunk(thunksHeap); if (newThunk == IntPtr.Zero) throw new OutOfMemoryException(); TypeLoaderCallbacks.RegisterThunk(newThunk); return newThunk; } public static void FreeThunk(object thunksHeap, IntPtr thunkAddress) { RuntimeImports.RhFreeThunk(thunksHeap, thunkAddress); } public static void SetThunkData(object thunksHeap, IntPtr thunkAddress, IntPtr context, IntPtr target) { RuntimeImports.RhSetThunkData(thunksHeap, thunkAddress, context, target); } public static bool TryGetThunkData(object thunksHeap, IntPtr thunkAddress, out IntPtr context, out IntPtr target) { return RuntimeImports.RhTryGetThunkData(thunksHeap, thunkAddress, out context, out target); } public static int GetThunkSize() { return RuntimeImports.RhGetThunkSize(); } [DebuggerStepThrough] /* TEMP workaround due to bug 149078 */ [MethodImpl(MethodImplOptions.NoInlining)] public static void CallDescrWorker(IntPtr callDescr) { RuntimeImports.RhCallDescrWorker(callDescr); } [DebuggerStepThrough] /* TEMP workaround due to bug 149078 */ [MethodImpl(MethodImplOptions.NoInlining)] public static void CallDescrWorkerNative(IntPtr callDescr) { RuntimeImports.RhCallDescrWorkerNative(callDescr); } public static Delegate CreateObjectArrayDelegate(Type delegateType, Func<object?[], object?> invoker) { return Delegate.CreateObjectArrayDelegate(delegateType, invoker); } internal static class RawCalliHelper { [DebuggerHidden] [DebuggerStepThrough] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] public static unsafe void Call<T>(System.IntPtr pfn, void* arg1, ref T arg2) => ((delegate*<void*, ref T, void>)pfn)(arg1, ref arg2); [DebuggerHidden] [DebuggerStepThrough] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] public static unsafe void Call<T, U>(System.IntPtr pfn, void* arg1, ref T arg2, ref U arg3) => ((delegate*<void*, ref T, ref U, void>)pfn)(arg1, ref arg2, ref arg3); } /// <summary> /// This method creates a conservatively reported region and calls a function /// while that region is conservatively reported. /// </summary> /// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param> /// <param name="pfnTargetToInvoke">function pointer to execute.</param> /// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param> [DebuggerGuidedStepThroughAttribute] [CLSCompliant(false)] public static unsafe void RunFunctionWithConservativelyReportedBuffer<T>(int cbBuffer, delegate*<void*, ref T, void> pfnTargetToInvoke, ref T context) { RuntimeImports.ConservativelyReportedRegionDesc regionDesc = default; RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref regionDesc); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); } // Marked as no-inlining so optimizer won't decide to optimize away the fact that pRegionDesc is a pinned interior pointer. // This function must also not make a p/invoke transition, or the fixed statement reporting of the ConservativelyReportedRegionDesc // will be ignored. [DebuggerGuidedStepThroughAttribute] [MethodImpl(MethodImplOptions.NoInlining)] private static unsafe void RunFunctionWithConservativelyReportedBufferInternal<T>(int cbBuffer, delegate*<void*, ref T, void> pfnTargetToInvoke, ref T context, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc) { fixed (RuntimeImports.ConservativelyReportedRegionDesc* pRegionDesc = &regionDesc) { int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1); // The conservative region must be IntPtr aligned, and a multiple of IntPtr in size void* region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)]; Buffer.ZeroMemory((byte*)region, (nuint)cbBufferAligned); RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned); RawCalliHelper.Call<T>((IntPtr)pfnTargetToInvoke, region, ref context); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc); } } /// <summary> /// This method creates a conservatively reported region and calls a function /// while that region is conservatively reported. /// </summary> /// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param> /// <param name="pfnTargetToInvoke">function pointer to execute.</param> /// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param> /// <param name="context2">context2 to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param> [DebuggerGuidedStepThroughAttribute] [CLSCompliant(false)] public static unsafe void RunFunctionWithConservativelyReportedBuffer<T, U>(int cbBuffer, delegate*<void*, ref T, ref U, void> pfnTargetToInvoke, ref T context, ref U context2) { RuntimeImports.ConservativelyReportedRegionDesc regionDesc = default; RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref context2, ref regionDesc); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); } // Marked as no-inlining so optimizer won't decide to optimize away the fact that pRegionDesc is a pinned interior pointer. // This function must also not make a p/invoke transition, or the fixed statement reporting of the ConservativelyReportedRegionDesc // will be ignored. [DebuggerGuidedStepThroughAttribute] [MethodImpl(MethodImplOptions.NoInlining)] private static unsafe void RunFunctionWithConservativelyReportedBufferInternal<T, U>(int cbBuffer, delegate*<void*, ref T, ref U, void> pfnTargetToInvoke, ref T context, ref U context2, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc) { fixed (RuntimeImports.ConservativelyReportedRegionDesc* pRegionDesc = &regionDesc) { int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1); // The conservative region must be IntPtr aligned, and a multiple of IntPtr in size void* region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)]; Buffer.ZeroMemory((byte*)region, (nuint)cbBufferAligned); RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned); RawCalliHelper.Call<T, U>((IntPtr)pfnTargetToInvoke, region, ref context, ref context2); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc); } } public static string GetLastResortString(RuntimeTypeHandle typeHandle) { return typeHandle.LastResortToString; } public static IntPtr RhHandleAlloc(object value, GCHandleType type) { return RuntimeImports.RhHandleAlloc(value, type); } public static void RhHandleFree(IntPtr handle) { RuntimeImports.RhHandleFree(handle); } public static IntPtr RhpGetCurrentThread() { return RuntimeImports.RhpGetCurrentThread(); } public static void RhpInitiateThreadAbort(IntPtr thread, bool rude) { Exception ex = new ThreadAbortException(); RuntimeImports.RhpInitiateThreadAbort(thread, ex, rude); } public static void RhpCancelThreadAbort(IntPtr thread) { RuntimeImports.RhpCancelThreadAbort(thread); } public static void RhYield() { RuntimeImports.RhYield(); } public static bool SupportsRelativePointers { get { return Internal.Runtime.MethodTable.SupportsRelativePointers; } } public static bool IsPrimitive(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsPrimitive && !typeHandle.ToEETypePtr().IsEnum; } public static byte[] ComputePublicKeyToken(byte[] publicKey) { return System.Reflection.AssemblyNameHelpers.ComputePublicKeyToken(publicKey); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. //Internal.Runtime.Augments //------------------------------------------------- // Why does this exist?: // Reflection.Execution cannot physically live in System.Private.CoreLib.dll // as it has a dependency on System.Reflection.Metadata. Its inherently // low-level nature means, however, it is closely tied to System.Private.CoreLib.dll. // This contract provides the two-communication between those two .dll's. // // // Implemented by: // System.Private.CoreLib.dll // // Consumed by: // Reflection.Execution.dll using System; using System.Runtime; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Threading; using Internal.Runtime.CompilerHelpers; using Internal.Runtime.CompilerServices; namespace Internal.Runtime.Augments { using BinderBundle = System.Reflection.BinderBundle; using Pointer = System.Reflection.Pointer; [ReflectionBlocked] public static class RuntimeAugments { /// <summary> /// Callbacks used for metadata-based stack trace resolution. /// </summary> private static StackTraceMetadataCallbacks s_stackTraceMetadataCallbacks; //============================================================================================== // One-time initialization. //============================================================================================== [CLSCompliant(false)] public static void Initialize(ReflectionExecutionDomainCallbacks callbacks) { s_reflectionExecutionDomainCallbacks = callbacks; } [CLSCompliant(false)] public static void InitializeLookups(TypeLoaderCallbacks callbacks) { s_typeLoaderCallbacks = callbacks; } [CLSCompliant(false)] public static void InitializeInteropLookups(InteropCallbacks callbacks) { s_interopCallbacks = callbacks; } [CLSCompliant(false)] public static void InitializeStackTraceMetadataSupport(StackTraceMetadataCallbacks callbacks) { s_stackTraceMetadataCallbacks = callbacks; } //============================================================================================== // Access to the underlying execution engine's object allocation routines. //============================================================================================== // // Perform the equivalent of a "newobj", but without invoking any constructors. Other than the MethodTable, the result object is zero-initialized. // // Special cases: // // Strings: The .ctor performs both the construction and initialization // and compiler special cases these. // // Nullable<T>: the boxed result is the underlying type rather than Nullable so the constructor // cannot truly initialize it. // // In these cases, this helper returns "null" and ConstructorInfo.Invoke() must deal with these specially. // public static object NewObject(RuntimeTypeHandle typeHandle) { EETypePtr eeType = typeHandle.ToEETypePtr(); if (eeType.IsNullable || eeType == EETypePtr.EETypePtrOf<string>() ) return null; return RuntimeImports.RhNewObject(eeType); } // // Helper API to perform the equivalent of a "newobj" for any MethodTable. // Unlike the NewObject API, this is the raw version that does not special case any MethodTable, and should be used with // caution for very specific scenarios. // public static object RawNewObject(RuntimeTypeHandle typeHandle) { return RuntimeImports.RhNewObject(typeHandle.ToEETypePtr()); } // // Perform the equivalent of a "newarr" The resulting array is zero-initialized. // public static Array NewArray(RuntimeTypeHandle typeHandleForArrayType, int count) { // Don't make the easy mistake of passing in the element MethodTable rather than the "array of element" MethodTable. Debug.Assert(typeHandleForArrayType.ToEETypePtr().IsSzArray); return RuntimeImports.RhNewArray(typeHandleForArrayType.ToEETypePtr(), count); } // // Perform the equivalent of a "newarr" The resulting array is zero-initialized. // // Note that invoking NewMultiDimArray on a rank-1 array type is not the same thing as invoking NewArray(). // // As a concession to the fact that we don't actually support non-zero lower bounds, "lowerBounds" accepts "null" // to avoid unnecessary array allocations by the caller. // [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "The compiler ensures that if we have a TypeHandle of a Rank-1 MdArray, we also generated the SzArray.")] public static unsafe Array NewMultiDimArray(RuntimeTypeHandle typeHandleForArrayType, int[] lengths, int[]? lowerBounds) { Debug.Assert(lengths != null); Debug.Assert(lowerBounds == null || lowerBounds.Length == lengths.Length); if (lowerBounds != null) { foreach (int lowerBound in lowerBounds) { if (lowerBound != 0) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NonZeroLowerBound); } } if (lengths.Length == 1) { // We just checked above that all lower bounds are zero. In that case, we should actually allocate // a new SzArray instead. Type elementType = Type.GetTypeFromHandle(new RuntimeTypeHandle(typeHandleForArrayType.ToEETypePtr().ArrayElementType)); return RuntimeImports.RhNewArray(elementType.MakeArrayType().TypeHandle.ToEETypePtr(), lengths[0]); } // Create a local copy of the lengths that cannot be modified by the caller int* pImmutableLengths = stackalloc int[lengths.Length]; for (int i = 0; i < lengths.Length; i++) pImmutableLengths[i] = lengths[i]; return Array.NewMultiDimArray(typeHandleForArrayType.ToEETypePtr(), pImmutableLengths, lengths.Length); } public static IntPtr GetAllocateObjectHelperForType(RuntimeTypeHandle type) { return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeHelperKind.AllocateObject); } public static IntPtr GetAllocateArrayHelperForType(RuntimeTypeHandle type) { return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), RuntimeHelperKind.AllocateArray); } public static IntPtr GetCastingHelperForType(RuntimeTypeHandle type, bool throwing) { return RuntimeImports.RhGetRuntimeHelperForType(CreateEETypePtr(type), throwing ? RuntimeHelperKind.CastClass : RuntimeHelperKind.IsInst); } public static IntPtr GetDispatchMapForType(RuntimeTypeHandle typeHandle) { return CreateEETypePtr(typeHandle).DispatchMap; } public static IntPtr GetFallbackDefaultConstructor() { return Activator.GetFallbackDefaultConstructor(); } // // Helper to create a delegate on a runtime-supplied type. // public static Delegate CreateDelegate(RuntimeTypeHandle typeHandleForDelegate, IntPtr ldftnResult, object thisObject, bool isStatic, bool isOpen) { return Delegate.CreateDelegate(typeHandleForDelegate.ToEETypePtr(), ldftnResult, thisObject, isStatic: isStatic, isOpen: isOpen); } // // Helper to extract the artifact that uniquely identifies a method in the runtime mapping tables. // public static IntPtr GetDelegateLdFtnResult(Delegate d, out RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate, out bool isOpenResolver, out bool isInterpreterEntrypoint) { return d.GetFunctionPointer(out typeOfFirstParameterIfInstanceDelegate, out isOpenResolver, out isInterpreterEntrypoint); } public static void GetDelegateData(Delegate delegateObj, out object firstParameter, out object helperObject, out IntPtr extraFunctionPointerOrData, out IntPtr functionPointer) { firstParameter = delegateObj.m_firstParameter; helperObject = delegateObj.m_helperObject; extraFunctionPointerOrData = delegateObj.m_extraFunctionPointerOrData; functionPointer = delegateObj.m_functionPointer; } public static int GetLoadedModules(TypeManagerHandle[] resultArray) { return Internal.Runtime.CompilerHelpers.StartupCodeHelpers.GetLoadedModules(resultArray); } public static IntPtr GetOSModuleFromPointer(IntPtr pointerVal) { return RuntimeImports.RhGetOSModuleFromPointer(pointerVal); } public static unsafe bool FindBlob(TypeManagerHandle typeManager, int blobId, IntPtr ppbBlob, IntPtr pcbBlob) { return RuntimeImports.RhFindBlob(typeManager, (uint)blobId, (byte**)ppbBlob, (uint*)pcbBlob); } public static IntPtr GetPointerFromTypeHandle(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().RawValue; } public static TypeManagerHandle GetModuleFromTypeHandle(RuntimeTypeHandle typeHandle) { return RuntimeImports.RhGetModuleFromEEType(GetPointerFromTypeHandle(typeHandle)); } public static RuntimeTypeHandle CreateRuntimeTypeHandle(IntPtr ldTokenResult) { return new RuntimeTypeHandle(new EETypePtr(ldTokenResult)); } public static unsafe void StoreValueTypeField(IntPtr address, object fieldValue, RuntimeTypeHandle fieldType) { RuntimeImports.RhUnbox(fieldValue, ref *(byte*)address, fieldType.ToEETypePtr()); } public static unsafe ref byte GetRawData(object obj) { return ref obj.GetRawData(); } public static unsafe object LoadValueTypeField(IntPtr address, RuntimeTypeHandle fieldType) { return RuntimeImports.RhBox(fieldType.ToEETypePtr(), ref *(byte*)address); } public static unsafe object LoadPointerTypeField(IntPtr address, RuntimeTypeHandle fieldType) { return Pointer.Box(*(void**)address, Type.GetTypeFromHandle(fieldType)); } public static unsafe void StoreValueTypeField(ref byte address, object fieldValue, RuntimeTypeHandle fieldType) { RuntimeImports.RhUnbox(fieldValue, ref address, fieldType.ToEETypePtr()); } public static unsafe void StoreValueTypeField(object obj, int fieldOffset, object fieldValue, RuntimeTypeHandle fieldType) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); RuntimeImports.RhUnbox(fieldValue, ref address, fieldType.ToEETypePtr()); } public static unsafe object LoadValueTypeField(object obj, int fieldOffset, RuntimeTypeHandle fieldType) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); return RuntimeImports.RhBox(fieldType.ToEETypePtr(), ref address); } public static unsafe object LoadPointerTypeField(object obj, int fieldOffset, RuntimeTypeHandle fieldType) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); return Pointer.Box((void*)Unsafe.As<byte, IntPtr>(ref address), Type.GetTypeFromHandle(fieldType)); } public static unsafe void StoreReferenceTypeField(IntPtr address, object fieldValue) { Volatile.Write<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address), fieldValue); } public static unsafe object LoadReferenceTypeField(IntPtr address) { return Volatile.Read<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address)); } public static void StoreReferenceTypeField(object obj, int fieldOffset, object fieldValue) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); Volatile.Write<object>(ref Unsafe.As<byte, object>(ref address), fieldValue); } public static object LoadReferenceTypeField(object obj, int fieldOffset) { ref byte address = ref Unsafe.AddByteOffset(ref obj.GetRawData(), new IntPtr(fieldOffset - ObjectHeaderSize)); return Unsafe.As<byte, object>(ref address); } [CLSCompliant(false)] public static void StoreValueTypeFieldValueIntoValueType(TypedReference typedReference, int fieldOffset, object fieldValue, RuntimeTypeHandle fieldTypeHandle) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); RuntimeImports.RhUnbox(fieldValue, ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset), fieldTypeHandle.ToEETypePtr()); } [CLSCompliant(false)] public static object LoadValueTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset, RuntimeTypeHandle fieldTypeHandle) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); Debug.Assert(fieldTypeHandle.ToEETypePtr().IsValueType); return RuntimeImports.RhBox(fieldTypeHandle.ToEETypePtr(), ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)); } [CLSCompliant(false)] public static void StoreReferenceTypeFieldValueIntoValueType(TypedReference typedReference, int fieldOffset, object fieldValue) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); Unsafe.As<byte, object>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)) = fieldValue; } [CLSCompliant(false)] public static object LoadReferenceTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); return Unsafe.As<byte, object>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)); } [CLSCompliant(false)] public static unsafe object LoadPointerTypeFieldValueFromValueType(TypedReference typedReference, int fieldOffset, RuntimeTypeHandle fieldTypeHandle) { Debug.Assert(TypedReference.TargetTypeToken(typedReference).ToEETypePtr().IsValueType); Debug.Assert(fieldTypeHandle.ToEETypePtr().IsPointer); IntPtr ptrValue = Unsafe.As<byte, IntPtr>(ref Unsafe.Add<byte>(ref typedReference.Value, fieldOffset)); return Pointer.Box((void*)ptrValue, Type.GetTypeFromHandle(fieldTypeHandle)); } public static unsafe object GetThreadStaticBase(IntPtr cookie) { return ThreadStatics.GetThreadStaticBaseForType(*(TypeManagerSlot**)cookie, (int)*((IntPtr*)(cookie) + 1)); } public static unsafe int ObjectHeaderSize => sizeof(EETypePtr); [DebuggerGuidedStepThroughAttribute] public static object CallDynamicInvokeMethod( object thisPtr, IntPtr methodToCall, IntPtr dynamicInvokeHelperMethod, IntPtr dynamicInvokeHelperGenericDictionary, object defaultParametersContext, object[] parameters, BinderBundle binderBundle, bool wrapInTargetInvocationException, bool methodToCallIsThisCall) { object result = InvokeUtils.CallDynamicInvokeMethod( thisPtr, methodToCall, dynamicInvokeHelperMethod, dynamicInvokeHelperGenericDictionary, defaultParametersContext, parameters, binderBundle, wrapInTargetInvocationException, methodToCallIsThisCall); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); return result; } public static unsafe void EnsureClassConstructorRun(IntPtr staticClassConstructionContext) { StaticClassConstructionContext* context = (StaticClassConstructionContext*)staticClassConstructionContext; ClassConstructorRunner.EnsureClassConstructorRun(context); } public static object GetEnumValue(Enum e) { return e.GetValue(); } public static Type GetEnumUnderlyingType(RuntimeTypeHandle enumTypeHandle) { Debug.Assert(enumTypeHandle.ToEETypePtr().IsEnum); EETypeElementType elementType = enumTypeHandle.ToEETypePtr().ElementType; switch (elementType) { case EETypeElementType.Boolean: return typeof(bool); case EETypeElementType.Char: return typeof(char); case EETypeElementType.SByte: return typeof(sbyte); case EETypeElementType.Byte: return typeof(byte); case EETypeElementType.Int16: return typeof(short); case EETypeElementType.UInt16: return typeof(ushort); case EETypeElementType.Int32: return typeof(int); case EETypeElementType.UInt32: return typeof(uint); case EETypeElementType.Int64: return typeof(long); case EETypeElementType.UInt64: return typeof(ulong); default: throw new NotSupportedException(); } } public static RuntimeTypeHandle GetRelatedParameterTypeHandle(RuntimeTypeHandle parameterTypeHandle) { EETypePtr elementType = parameterTypeHandle.ToEETypePtr().ArrayElementType; return new RuntimeTypeHandle(elementType); } public static bool IsValueType(RuntimeTypeHandle type) { return type.ToEETypePtr().IsValueType; } public static bool IsInterface(RuntimeTypeHandle type) { return type.ToEETypePtr().IsInterface; } public static unsafe object Box(RuntimeTypeHandle type, IntPtr address) { return RuntimeImports.RhBox(type.ToEETypePtr(), ref *(byte*)address); } // Used to mutate the first parameter in a closed static delegate. Note that this does no synchronization of any kind; // use only on delegate instances you're sure nobody else is using. public static void SetClosedStaticDelegateFirstParameter(Delegate del, object firstParameter) { del.SetClosedStaticFirstParameter(firstParameter); } //============================================================================================== // Execution engine policies. //============================================================================================== // // This returns a generic type with one generic parameter (representing the array element type) // whose base type and interface list determines what TypeInfo.BaseType and TypeInfo.ImplementedInterfaces // return for types that return true for IsArray. // public static RuntimeTypeHandle ProjectionTypeForArrays { get { return typeof(Array<>).TypeHandle; } } // // Returns the name of a virtual assembly we dump types private class library-Reflectable ty[es for internal class library use. // The assembly binder visible to apps will never reveal this assembly. // // Note that this is not versionable as it is exposed as a const (and needs to be a const so we can used as a custom attribute argument - which // is the other reason this string is not versionable.) // public const string HiddenScopeAssemblyName = "HiddenScope, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; // // This implements the "IsAssignableFrom()" api for runtime-created types. By policy, we let the underlying runtime decide assignability. // public static bool IsAssignableFrom(RuntimeTypeHandle dstType, RuntimeTypeHandle srcType) { EETypePtr dstEEType = dstType.ToEETypePtr(); EETypePtr srcEEType = srcType.ToEETypePtr(); return RuntimeImports.AreTypesAssignable(srcEEType, dstEEType); } public static bool IsInstanceOfInterface(object obj, RuntimeTypeHandle interfaceTypeHandle) { return (null != RuntimeImports.IsInstanceOfInterface(interfaceTypeHandle.ToEETypePtr(), obj)); } // // Return a type's base type using the runtime type system. If the underlying runtime type system does not support // this operation, return false and TypeInfo.BaseType will fall back to metadata. // // Note that "default(RuntimeTypeHandle)" is a valid result that will map to a null result. (For example, System.Object has a "null" base type.) // public static bool TryGetBaseType(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle baseTypeHandle) { EETypePtr eeType = typeHandle.ToEETypePtr(); if (eeType.IsGenericTypeDefinition || eeType.IsPointer || eeType.IsByRef) { baseTypeHandle = default(RuntimeTypeHandle); return false; } baseTypeHandle = new RuntimeTypeHandle(eeType.BaseType); return true; } // // Return a type's transitive implemeted interface list using the runtime type system. If the underlying runtime type system does not support // this operation, return null and TypeInfo.ImplementedInterfaces will fall back to metadata. Note that returning null is not the same thing // as returning a 0-length enumerable. // public static IEnumerable<RuntimeTypeHandle> TryGetImplementedInterfaces(RuntimeTypeHandle typeHandle) { EETypePtr eeType = typeHandle.ToEETypePtr(); if (eeType.IsGenericTypeDefinition || eeType.IsPointer || eeType.IsByRef) return null; LowLevelList<RuntimeTypeHandle> implementedInterfaces = new LowLevelList<RuntimeTypeHandle>(); for (int i = 0; i < eeType.Interfaces.Count; i++) { EETypePtr ifcEEType = eeType.Interfaces[i]; RuntimeTypeHandle ifcrth = new RuntimeTypeHandle(ifcEEType); if (Callbacks.IsReflectionBlocked(ifcrth)) continue; implementedInterfaces.Add(ifcrth); } return implementedInterfaces.ToArray(); } private static RuntimeTypeHandle CreateRuntimeTypeHandle(EETypePtr eeType) { return new RuntimeTypeHandle(eeType); } private static EETypePtr CreateEETypePtr(RuntimeTypeHandle runtimeTypeHandle) { return runtimeTypeHandle.ToEETypePtr(); } public static int GetGCDescSize(RuntimeTypeHandle typeHandle) { EETypePtr eeType = CreateEETypePtr(typeHandle); return RuntimeImports.RhGetGCDescSize(eeType); } public static int GetInterfaceCount(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().Interfaces.Count; } public static RuntimeTypeHandle GetInterface(RuntimeTypeHandle typeHandle, int index) { EETypePtr eeInterface = typeHandle.ToEETypePtr().Interfaces[index]; return CreateRuntimeTypeHandle(eeInterface); } public static IntPtr NewInterfaceDispatchCell(RuntimeTypeHandle interfaceTypeHandle, int slotNumber) { EETypePtr eeInterfaceType = CreateEETypePtr(interfaceTypeHandle); IntPtr cell = RuntimeImports.RhNewInterfaceDispatchCell(eeInterfaceType, slotNumber); if (cell == IntPtr.Zero) throw new OutOfMemoryException(); return cell; } public static int GetValueTypeSize(RuntimeTypeHandle typeHandle) { return (int)typeHandle.ToEETypePtr().ValueTypeSize; } [Intrinsic] public static RuntimeTypeHandle GetCanonType(CanonTypeKind kind) { // Compiler needs to expand this. This is not expressible in IL. throw new NotSupportedException(); } public static RuntimeTypeHandle GetGenericDefinition(RuntimeTypeHandle typeHandle) { EETypePtr eeType = typeHandle.ToEETypePtr(); Debug.Assert(eeType.IsGeneric); return new RuntimeTypeHandle(eeType.GenericDefinition); } public static RuntimeTypeHandle GetGenericArgument(RuntimeTypeHandle typeHandle, int argumentIndex) { EETypePtr eeType = typeHandle.ToEETypePtr(); Debug.Assert(eeType.IsGeneric); return new RuntimeTypeHandle(eeType.Instantiation[argumentIndex]); } public static RuntimeTypeHandle GetGenericInstantiation(RuntimeTypeHandle typeHandle, out RuntimeTypeHandle[] genericTypeArgumentHandles) { EETypePtr eeType = typeHandle.ToEETypePtr(); Debug.Assert(eeType.IsGeneric); var instantiation = eeType.Instantiation; genericTypeArgumentHandles = new RuntimeTypeHandle[instantiation.Length]; for (int i = 0; i < instantiation.Length; i++) { genericTypeArgumentHandles[i] = new RuntimeTypeHandle(instantiation[i]); } return new RuntimeTypeHandle(eeType.GenericDefinition); } public static bool IsGenericType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsGeneric; } public static bool IsArrayType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsArray; } public static bool IsByRefLike(RuntimeTypeHandle typeHandle) => typeHandle.ToEETypePtr().IsByRefLike; public static bool IsDynamicType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsDynamicType; } public static bool HasCctor(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().HasCctor; } public static RuntimeTypeHandle RuntimeTypeHandleOf<T>() { return new RuntimeTypeHandle(EETypePtr.EETypePtrOf<T>()); } public static IntPtr ResolveDispatchOnType(RuntimeTypeHandle instanceType, RuntimeTypeHandle interfaceType, int slot) { return RuntimeImports.RhResolveDispatchOnType(CreateEETypePtr(instanceType), CreateEETypePtr(interfaceType), checked((ushort)slot)); } public static IntPtr ResolveDispatch(object instance, RuntimeTypeHandle interfaceType, int slot) { return RuntimeImports.RhResolveDispatch(instance, CreateEETypePtr(interfaceType), checked((ushort)slot)); } public static IntPtr GVMLookupForSlot(RuntimeTypeHandle type, RuntimeMethodHandle slot) { return GenericVirtualMethodSupport.GVMLookupForSlot(type, slot); } public static bool IsUnmanagedPointerType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsPointer; } public static bool IsByRefType(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsByRef; } public static bool IsGenericTypeDefinition(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsGenericTypeDefinition; } // // This implements the equivalent of the desktop's InvokeUtil::CanPrimitiveWiden() routine. // public static bool CanPrimitiveWiden(RuntimeTypeHandle srcType, RuntimeTypeHandle dstType) { EETypePtr srcEEType = srcType.ToEETypePtr(); EETypePtr dstEEType = dstType.ToEETypePtr(); if (srcEEType.IsGenericTypeDefinition || dstEEType.IsGenericTypeDefinition) return false; if (srcEEType.IsPointer || dstEEType.IsPointer) return false; if (srcEEType.IsByRef || dstEEType.IsByRef) return false; if (!srcEEType.IsPrimitive) return false; if (!dstEEType.IsPrimitive) return false; if (!srcEEType.CorElementTypeInfo.CanWidenTo(dstEEType.CorElementType)) return false; return true; } public static object CheckArgument(object srcObject, RuntimeTypeHandle dstType, BinderBundle binderBundle) { return InvokeUtils.CheckArgument(srcObject, dstType, binderBundle); } // FieldInfo.SetValueDirect() has a completely different set of rules on how to coerce the argument from // the other Reflection api. public static object CheckArgumentForDirectFieldAccess(object srcObject, RuntimeTypeHandle dstType) { return InvokeUtils.CheckArgument(srcObject, dstType.ToEETypePtr(), InvokeUtils.CheckArgumentSemantics.SetFieldDirect, binderBundle: null); } public static bool IsAssignable(object srcObject, RuntimeTypeHandle dstType) { EETypePtr srcEEType = srcObject.EETypePtr; return RuntimeImports.AreTypesAssignable(srcEEType, dstType.ToEETypePtr()); } //============================================================================================== // Nullable<> support //============================================================================================== public static bool IsNullable(RuntimeTypeHandle declaringTypeHandle) { return declaringTypeHandle.ToEETypePtr().IsNullable; } public static RuntimeTypeHandle GetNullableType(RuntimeTypeHandle nullableType) { EETypePtr theT = nullableType.ToEETypePtr().NullableType; return new RuntimeTypeHandle(theT); } /// <summary> /// Locate the file path for a given native application module. /// </summary> /// <param name="ip">Address inside the module</param> /// <param name="moduleBase">Module base address</param> public static unsafe string TryGetFullPathToApplicationModule(IntPtr ip, out IntPtr moduleBase) { moduleBase = RuntimeImports.RhGetOSModuleFromPointer(ip); if (moduleBase == IntPtr.Zero) return null; #if TARGET_UNIX // RhGetModuleFileName on Unix calls dladdr that accepts any ip. Avoid the redundant lookup // and pass the ip into RhGetModuleFileName directly. Also, older versions of Musl have a bug // that leads to crash with the redundant lookup. byte* pModuleNameUtf8; int numUtf8Chars = RuntimeImports.RhGetModuleFileName(ip, out pModuleNameUtf8); string modulePath = System.Text.Encoding.UTF8.GetString(pModuleNameUtf8, numUtf8Chars); #else // TARGET_UNIX char* pModuleName; int numChars = RuntimeImports.RhGetModuleFileName(moduleBase, out pModuleName); string modulePath = new string(pModuleName, 0, numChars); #endif // TARGET_UNIX return modulePath; } public static IntPtr GetRuntimeTypeHandleRawValue(RuntimeTypeHandle runtimeTypeHandle) { return runtimeTypeHandle.RawValue; } // if functionPointer points at an import or unboxing stub, find the target of the stub public static IntPtr GetCodeTarget(IntPtr functionPointer) { return RuntimeImports.RhGetCodeTarget(functionPointer); } public static IntPtr GetTargetOfUnboxingAndInstantiatingStub(IntPtr functionPointer) { return RuntimeImports.RhGetTargetOfUnboxingAndInstantiatingStub(functionPointer); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IntPtr RuntimeCacheLookup(IntPtr context, IntPtr signature, RuntimeObjectFactory factory, object contextObject, out IntPtr auxResult) { return TypeLoaderExports.RuntimeCacheLookupInCache(context, signature, factory, contextObject, out auxResult); } //============================================================================================== // Internals //============================================================================================== [CLSCompliant(false)] public static ReflectionExecutionDomainCallbacks CallbacksIfAvailable { get { return s_reflectionExecutionDomainCallbacks; } } [CLSCompliant(false)] public static ReflectionExecutionDomainCallbacks Callbacks { get { ReflectionExecutionDomainCallbacks callbacks = s_reflectionExecutionDomainCallbacks; Debug.Assert(callbacks != null); return callbacks; } } internal static TypeLoaderCallbacks TypeLoaderCallbacksIfAvailable { get { return s_typeLoaderCallbacks; } } internal static TypeLoaderCallbacks TypeLoaderCallbacks { get { TypeLoaderCallbacks callbacks = s_typeLoaderCallbacks; Debug.Assert(callbacks != null); return callbacks; } } internal static InteropCallbacks InteropCallbacks { get { InteropCallbacks callbacks = s_interopCallbacks; Debug.Assert(callbacks != null); return callbacks; } } internal static StackTraceMetadataCallbacks StackTraceCallbacksIfAvailable { get { return s_stackTraceMetadataCallbacks; } } public static string TryGetMethodDisplayStringFromIp(IntPtr ip) { StackTraceMetadataCallbacks callbacks = StackTraceCallbacksIfAvailable; if (callbacks == null) return null; ip = RuntimeImports.RhFindMethodStartAddress(ip); if (ip == IntPtr.Zero) return null; return callbacks.TryGetMethodNameFromStartAddress(ip); } private static volatile ReflectionExecutionDomainCallbacks s_reflectionExecutionDomainCallbacks; private static TypeLoaderCallbacks s_typeLoaderCallbacks; private static InteropCallbacks s_interopCallbacks; public static void ReportUnhandledException(Exception exception) { RuntimeExceptionHelpers.ReportUnhandledException(exception); } public static unsafe RuntimeTypeHandle GetRuntimeTypeHandleFromObjectReference(object obj) { return new RuntimeTypeHandle(obj.EETypePtr); } // Move memory which may be on the heap which may have object references in it. // In general, a memcpy on the heap is unsafe, but this is able to perform the // correct write barrier such that the GC is not incorrectly impacted. public static unsafe void BulkMoveWithWriteBarrier(IntPtr dmem, IntPtr smem, int size) { RuntimeImports.RhBulkMoveWithWriteBarrier(ref *(byte*)dmem.ToPointer(), ref *(byte*)smem.ToPointer(), (uint)size); } public static IntPtr GetUniversalTransitionThunk() { return RuntimeImports.RhGetUniversalTransitionThunk(); } public static object CreateThunksHeap(IntPtr commonStubAddress) { object newHeap = RuntimeImports.RhCreateThunksHeap(commonStubAddress); if (newHeap == null) throw new OutOfMemoryException(); return newHeap; } public static IntPtr AllocateThunk(object thunksHeap) { IntPtr newThunk = RuntimeImports.RhAllocateThunk(thunksHeap); if (newThunk == IntPtr.Zero) throw new OutOfMemoryException(); TypeLoaderCallbacks.RegisterThunk(newThunk); return newThunk; } public static void FreeThunk(object thunksHeap, IntPtr thunkAddress) { RuntimeImports.RhFreeThunk(thunksHeap, thunkAddress); } public static void SetThunkData(object thunksHeap, IntPtr thunkAddress, IntPtr context, IntPtr target) { RuntimeImports.RhSetThunkData(thunksHeap, thunkAddress, context, target); } public static bool TryGetThunkData(object thunksHeap, IntPtr thunkAddress, out IntPtr context, out IntPtr target) { return RuntimeImports.RhTryGetThunkData(thunksHeap, thunkAddress, out context, out target); } public static int GetThunkSize() { return RuntimeImports.RhGetThunkSize(); } [DebuggerStepThrough] /* TEMP workaround due to bug 149078 */ [MethodImpl(MethodImplOptions.NoInlining)] public static void CallDescrWorker(IntPtr callDescr) { RuntimeImports.RhCallDescrWorker(callDescr); } [DebuggerStepThrough] /* TEMP workaround due to bug 149078 */ [MethodImpl(MethodImplOptions.NoInlining)] public static void CallDescrWorkerNative(IntPtr callDescr) { RuntimeImports.RhCallDescrWorkerNative(callDescr); } public static Delegate CreateObjectArrayDelegate(Type delegateType, Func<object?[], object?> invoker) { return Delegate.CreateObjectArrayDelegate(delegateType, invoker); } internal static class RawCalliHelper { [DebuggerHidden] [DebuggerStepThrough] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] public static unsafe void Call<T>(System.IntPtr pfn, void* arg1, ref T arg2) => ((delegate*<void*, ref T, void>)pfn)(arg1, ref arg2); [DebuggerHidden] [DebuggerStepThrough] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] public static unsafe void Call<T, U>(System.IntPtr pfn, void* arg1, ref T arg2, ref U arg3) => ((delegate*<void*, ref T, ref U, void>)pfn)(arg1, ref arg2, ref arg3); } /// <summary> /// This method creates a conservatively reported region and calls a function /// while that region is conservatively reported. /// </summary> /// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param> /// <param name="pfnTargetToInvoke">function pointer to execute.</param> /// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param> [DebuggerGuidedStepThroughAttribute] [CLSCompliant(false)] public static unsafe void RunFunctionWithConservativelyReportedBuffer<T>(int cbBuffer, delegate*<void*, ref T, void> pfnTargetToInvoke, ref T context) { RuntimeImports.ConservativelyReportedRegionDesc regionDesc = default; RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref regionDesc); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); } // Marked as no-inlining so optimizer won't decide to optimize away the fact that pRegionDesc is a pinned interior pointer. // This function must also not make a p/invoke transition, or the fixed statement reporting of the ConservativelyReportedRegionDesc // will be ignored. [DebuggerGuidedStepThroughAttribute] [MethodImpl(MethodImplOptions.NoInlining)] private static unsafe void RunFunctionWithConservativelyReportedBufferInternal<T>(int cbBuffer, delegate*<void*, ref T, void> pfnTargetToInvoke, ref T context, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc) { fixed (RuntimeImports.ConservativelyReportedRegionDesc* pRegionDesc = &regionDesc) { int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1); // The conservative region must be IntPtr aligned, and a multiple of IntPtr in size void* region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)]; Buffer.ZeroMemory((byte*)region, (nuint)cbBufferAligned); RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned); RawCalliHelper.Call<T>((IntPtr)pfnTargetToInvoke, region, ref context); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc); } } /// <summary> /// This method creates a conservatively reported region and calls a function /// while that region is conservatively reported. /// </summary> /// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param> /// <param name="pfnTargetToInvoke">function pointer to execute.</param> /// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param> /// <param name="context2">context2 to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param> [DebuggerGuidedStepThroughAttribute] [CLSCompliant(false)] public static unsafe void RunFunctionWithConservativelyReportedBuffer<T, U>(int cbBuffer, delegate*<void*, ref T, ref U, void> pfnTargetToInvoke, ref T context, ref U context2) { RuntimeImports.ConservativelyReportedRegionDesc regionDesc = default; RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref context2, ref regionDesc); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); } // Marked as no-inlining so optimizer won't decide to optimize away the fact that pRegionDesc is a pinned interior pointer. // This function must also not make a p/invoke transition, or the fixed statement reporting of the ConservativelyReportedRegionDesc // will be ignored. [DebuggerGuidedStepThroughAttribute] [MethodImpl(MethodImplOptions.NoInlining)] private static unsafe void RunFunctionWithConservativelyReportedBufferInternal<T, U>(int cbBuffer, delegate*<void*, ref T, ref U, void> pfnTargetToInvoke, ref T context, ref U context2, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc) { fixed (RuntimeImports.ConservativelyReportedRegionDesc* pRegionDesc = &regionDesc) { int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1); // The conservative region must be IntPtr aligned, and a multiple of IntPtr in size void* region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)]; Buffer.ZeroMemory((byte*)region, (nuint)cbBufferAligned); RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned); RawCalliHelper.Call<T, U>((IntPtr)pfnTargetToInvoke, region, ref context, ref context2); System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode(); RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc); } } public static string GetLastResortString(RuntimeTypeHandle typeHandle) { return typeHandle.LastResortToString; } public static IntPtr RhHandleAlloc(object value, GCHandleType type) { return RuntimeImports.RhHandleAlloc(value, type); } public static void RhHandleFree(IntPtr handle) { RuntimeImports.RhHandleFree(handle); } public static IntPtr RhpGetCurrentThread() { return RuntimeImports.RhpGetCurrentThread(); } public static void RhpInitiateThreadAbort(IntPtr thread, bool rude) { Exception ex = new ThreadAbortException(); RuntimeImports.RhpInitiateThreadAbort(thread, ex, rude); } public static void RhpCancelThreadAbort(IntPtr thread) { RuntimeImports.RhpCancelThreadAbort(thread); } public static void RhYield() { RuntimeImports.RhYield(); } public static bool SupportsRelativePointers { get { return Internal.Runtime.MethodTable.SupportsRelativePointers; } } public static bool IsPrimitive(RuntimeTypeHandle typeHandle) { return typeHandle.ToEETypePtr().IsPrimitive && !typeHandle.ToEETypePtr().IsEnum; } public static byte[] ComputePublicKeyToken(byte[] publicKey) { return System.Reflection.AssemblyNameHelpers.ComputePublicKeyToken(publicKey); } } }
1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/ArrayHelpers.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; using System.Diagnostics.CodeAnalysis; using Debug = System.Diagnostics.Debug; namespace Internal.Runtime.CompilerHelpers { /// <summary> /// Array helpers for generated code. /// </summary> internal static class ArrayHelpers { /// <summary> /// Helper for array allocations via `newobj` IL instruction. Dimensions are passed in as block of integers. /// The content of the dimensions block may be modified by the helper. /// </summary> [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "The compiler ensures that if we have a TypeHandle of a Rank-1 MdArray, we also generated the SzArray.")] public static unsafe Array NewObjArray(IntPtr pEEType, int nDimensions, int* pDimensions) { EETypePtr eeType = new EETypePtr(pEEType); Debug.Assert(eeType.IsArray); Debug.Assert(nDimensions > 0); if (eeType.IsSzArray) { Array ret = (Array)RuntimeImports.RhNewArray(eeType, pDimensions[0]); if (nDimensions > 1) { // Jagged arrays have constructor for each possible depth EETypePtr elementType = eeType.ArrayElementType; Debug.Assert(elementType.IsSzArray); Array[] arrayOfArrays = (Array[])ret; for (int i = 0; i < arrayOfArrays.Length; i++) arrayOfArrays[i] = NewObjArray(elementType.RawValue, nDimensions - 1, pDimensions + 1); } return ret; } else { // Multidimensional arrays have two ctors, one with and one without lower bounds int rank = eeType.ArrayRank; Debug.Assert(rank == nDimensions || 2 * rank == nDimensions); if (rank < nDimensions) { for (int i = 0; i < rank; i++) { if (pDimensions[2 * i] != 0) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NonZeroLowerBound); pDimensions[i] = pDimensions[2 * i + 1]; } } if (rank == 1) { // Multidimensional array of rank 1 with 0 lower bounds gets actually allocated // as an SzArray. SzArray is castable to MdArray rank 1. int length = pDimensions[0]; if (length < 0) { // Compat: we need to throw OverflowException. Array.CreateInstance would throw ArgumentOutOfRange throw new OverflowException(); } RuntimeTypeHandle elementTypeHandle = new RuntimeTypeHandle(eeType.ArrayElementType); return Array.CreateInstance(Type.GetTypeFromHandle(elementTypeHandle), length); } return Array.NewMultiDimArray(eeType, pDimensions, rank); } } } }
// 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; using System.Diagnostics.CodeAnalysis; using Debug = System.Diagnostics.Debug; namespace Internal.Runtime.CompilerHelpers { /// <summary> /// Array helpers for generated code. /// </summary> internal static class ArrayHelpers { /// <summary> /// Helper for array allocations via `newobj` IL instruction. Dimensions are passed in as block of integers. /// The content of the dimensions block may be modified by the helper. /// </summary> [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "The compiler ensures that if we have a TypeHandle of a Rank-1 MdArray, we also generated the SzArray.")] public static unsafe Array NewObjArray(IntPtr pEEType, int nDimensions, int* pDimensions) { EETypePtr eeType = new EETypePtr(pEEType); Debug.Assert(eeType.IsArray); Debug.Assert(nDimensions > 0); if (eeType.IsSzArray) { Array ret = (Array)RuntimeImports.RhNewArray(eeType, pDimensions[0]); if (nDimensions > 1) { // Jagged arrays have constructor for each possible depth EETypePtr elementType = eeType.ArrayElementType; Debug.Assert(elementType.IsSzArray); Array[] arrayOfArrays = (Array[])ret; for (int i = 0; i < arrayOfArrays.Length; i++) arrayOfArrays[i] = NewObjArray(elementType.RawValue, nDimensions - 1, pDimensions + 1); } return ret; } else { // Multidimensional arrays have two ctors, one with and one without lower bounds int rank = eeType.ArrayRank; Debug.Assert(rank == nDimensions || 2 * rank == nDimensions); if (rank < nDimensions) { for (int i = 0; i < rank; i++) { if (pDimensions[2 * i] != 0) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NonZeroLowerBound); pDimensions[i] = pDimensions[2 * i + 1]; } } if (rank == 1) { // Multidimensional array of rank 1 with 0 lower bounds gets actually allocated // as an SzArray. SzArray is castable to MdArray rank 1. Type elementType = Type.GetTypeFromHandle(new RuntimeTypeHandle(eeType.ArrayElementType)); return RuntimeImports.RhNewArray(elementType.MakeArrayType().TypeHandle.ToEETypePtr(), pDimensions[0]); } return Array.NewMultiDimArray(eeType, pDimensions, rank); } } } }
1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/coreclr/nativeaot/System.Private.CoreLib/src/System/Array.CoreRT.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; using System.Threading; using System.Collections; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Internal.Runtime.Augments; using Internal.Runtime.CompilerServices; using Internal.Reflection.Core.NonPortable; using Internal.IntrinsicSupport; using MethodTable = Internal.Runtime.MethodTable; using EETypeElementType = Internal.Runtime.EETypeElementType; namespace System { // Note that we make a T[] (single-dimensional w/ zero as the lower bound) implement both // IList<U> and IReadOnlyList<U>, where T : U dynamically. See the SZArrayHelper class for details. public abstract partial class Array : ICollection, IEnumerable, IList, IStructuralComparable, IStructuralEquatable, ICloneable { // CS0169: The field 'Array._numComponents' is never used #pragma warning disable 0169 // This field should be the first field in Array as the runtime/compilers depend on it [NonSerialized] private int _numComponents; #pragma warning restore #if TARGET_64BIT private const int POINTER_SIZE = 8; #else private const int POINTER_SIZE = 4; #endif // Header + m_pEEType + _numComponents (with an optional padding) private const int SZARRAY_BASE_SIZE = POINTER_SIZE + POINTER_SIZE + POINTER_SIZE; public int Length => checked((int)Unsafe.As<RawArrayData>(this).Length); // This could return a length greater than int.MaxValue internal nuint NativeLength => Unsafe.As<RawArrayData>(this).Length; public long LongLength => (long)NativeLength; internal bool IsSzArray { get { return this.EETypePtr.BaseSize == SZARRAY_BASE_SIZE; } } // This is the classlib-provided "get array MethodTable" function that will be invoked whenever the runtime // needs to know the base type of an array. [RuntimeExport("GetSystemArrayEEType")] private static unsafe MethodTable* GetSystemArrayEEType() { return EETypePtr.EETypePtrOf<Array>().ToPointer(); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static Array CreateInstance(Type elementType, int length) { if (elementType is null) throw new ArgumentNullException(nameof(elementType)); return CreateSzArray(elementType, length); } [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "MDArrays of Rank != 1 can be created because they don't implement generic interfaces.")] public static unsafe Array CreateInstance(Type elementType, int length1, int length2) { if (elementType is null) throw new ArgumentNullException(nameof(elementType)); if (length1 < 0) throw new ArgumentOutOfRangeException(nameof(length1)); if (length2 < 0) throw new ArgumentOutOfRangeException(nameof(length2)); Type arrayType = GetArrayTypeFromElementType(elementType, true, 2); int* pLengths = stackalloc int[2]; pLengths[0] = length1; pLengths[1] = length2; return NewMultiDimArray(arrayType.TypeHandle.ToEETypePtr(), pLengths, 2); } [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "MDArrays of Rank != 1 can be created because they don't implement generic interfaces.")] public static unsafe Array CreateInstance(Type elementType, int length1, int length2, int length3) { if (elementType is null) throw new ArgumentNullException(nameof(elementType)); if (length1 < 0) throw new ArgumentOutOfRangeException(nameof(length1)); if (length2 < 0) throw new ArgumentOutOfRangeException(nameof(length2)); if (length3 < 0) throw new ArgumentOutOfRangeException(nameof(length3)); Type arrayType = GetArrayTypeFromElementType(elementType, true, 3); int* pLengths = stackalloc int[3]; pLengths[0] = length1; pLengths[1] = length2; pLengths[2] = length3; return NewMultiDimArray(arrayType.TypeHandle.ToEETypePtr(), pLengths, 3); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static Array CreateInstance(Type elementType, params int[] lengths) { if (elementType is null) throw new ArgumentNullException(nameof(elementType)); if (lengths is null) throw new ArgumentNullException(nameof(lengths)); if (lengths.Length == 0) throw new ArgumentException(SR.Arg_NeedAtLeast1Rank); // Check to make sure the lengths are all positive. Note that we check this here to give // a good exception message if they are not; however we check this again inside the execution // engine's low level allocation function after having made a copy of the array to prevent a // malicious caller from mutating the array after this check. for (int i = 0; i < lengths.Length; i++) if (lengths[i] < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (lengths.Length == 1) { int length = lengths[0]; return CreateSzArray(elementType, length); } else { return CreateMultiDimArray(elementType, lengths, null); } } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static Array CreateInstance(Type elementType, int[] lengths, int[] lowerBounds) { if (elementType is null) throw new ArgumentNullException(nameof(elementType)); if (lengths is null) throw new ArgumentNullException(nameof(lengths)); if (lowerBounds is null) throw new ArgumentNullException(nameof(lowerBounds)); if (lengths.Length != lowerBounds.Length) throw new ArgumentException(SR.Arg_RanksAndBounds); if (lengths.Length == 0) throw new ArgumentException(SR.Arg_NeedAtLeast1Rank); return CreateMultiDimArray(elementType, lengths, lowerBounds); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] private static Array CreateSzArray(Type elementType, int length) { // Though our callers already validated length once, this parameter is passed via arrays, so we must check it again // in case a malicious caller modified the array after the check. if (length < 0) throw new ArgumentOutOfRangeException(nameof(length)); Type arrayType = GetArrayTypeFromElementType(elementType, false, 1); return RuntimeImports.RhNewArray(arrayType.TypeHandle.ToEETypePtr(), length); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] private static Array CreateMultiDimArray(Type elementType, int[] lengths, int[] lowerBounds) { Debug.Assert(lengths != null); Debug.Assert(lowerBounds == null || lowerBounds.Length == lengths.Length); for (int i = 0; i < lengths.Length; i++) { if (lengths[i] < 0) throw new ArgumentOutOfRangeException("lengths[" + i + "]", SR.ArgumentOutOfRange_NeedNonNegNum); } int rank = lengths.Length; Type arrayType = GetArrayTypeFromElementType(elementType, true, rank); return RuntimeAugments.NewMultiDimArray(arrayType.TypeHandle, lengths, lowerBounds); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] private static Type GetArrayTypeFromElementType(Type elementType, bool multiDim, int rank) { elementType = elementType.UnderlyingSystemType; ValidateElementType(elementType); if (multiDim) return elementType.MakeArrayType(rank); else return elementType.MakeArrayType(); } private static void ValidateElementType(Type elementType) { if (elementType is not RuntimeType) throw new ArgumentException(SR.Arg_MustBeType, nameof(elementType)); while (elementType.IsArray) { elementType = elementType.GetElementType()!; } if (elementType.IsByRef || elementType.IsByRefLike) throw new NotSupportedException(SR.NotSupported_ByRefLikeArray); if (elementType == typeof(void)) throw new NotSupportedException(SR.NotSupported_VoidArray); if (elementType.ContainsGenericParameters) throw new NotSupportedException(SR.NotSupported_OpenType); } public void Initialize() { // Project N port note: On the desktop, this api is a nop unless the array element type is a value type with // an explicit nullary constructor. Such a type cannot be expressed in C# so Project N does not support this. // The ILC toolchain fails the build if it encounters such a type. return; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private ref int GetRawMultiDimArrayBounds() { Debug.Assert(!IsSzArray); return ref Unsafe.As<byte, int>(ref Unsafe.As<RawArrayData>(this).Data); } // Provides a strong exception guarantee - either it succeeds, or // it throws an exception with no side effects. The arrays must be // compatible array types based on the array element type - this // method does not support casting, boxing, or primitive widening. // It will up-cast, assuming the array types are correct. public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { CopyImpl(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable: true); } public static void Copy(Array sourceArray, Array destinationArray, int length) { if (sourceArray is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray); if (destinationArray is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray); EETypePtr eeType = sourceArray.EETypePtr; if (eeType.FastEquals(destinationArray.EETypePtr) && eeType.IsSzArray && (uint)length <= sourceArray.NativeLength && (uint)length <= destinationArray.NativeLength) { nuint byteCount = (uint)length * (nuint)eeType.ComponentSize; ref byte src = ref Unsafe.As<RawArrayData>(sourceArray).Data; ref byte dst = ref Unsafe.As<RawArrayData>(destinationArray).Data; if (eeType.HasPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } // Less common CopyImpl(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length, reliable: false); } public static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { if (sourceArray != null && destinationArray != null) { EETypePtr eeType = sourceArray.EETypePtr; if (eeType.FastEquals(destinationArray.EETypePtr) && eeType.IsSzArray && length >= 0 && sourceIndex >= 0 && destinationIndex >= 0 && (uint)(sourceIndex + length) <= sourceArray.NativeLength && (uint)(destinationIndex + length) <= destinationArray.NativeLength) { nuint elementSize = (nuint)eeType.ComponentSize; nuint byteCount = (uint)length * elementSize; ref byte src = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(sourceArray).Data, (uint)sourceIndex * elementSize); ref byte dst = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(destinationArray).Data, (uint)destinationIndex * elementSize); if (eeType.HasPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } } // Less common CopyImpl(sourceArray!, sourceIndex, destinationArray!, destinationIndex, length, reliable: false); } // // Funnel for all the Array.Copy() overloads. The "reliable" parameter indicates whether the caller for ConstrainedCopy() // (must leave destination array unchanged on any exception.) // private static unsafe void CopyImpl(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { if (sourceArray is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray); if (destinationArray is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray); if (sourceArray.GetType() != destinationArray.GetType() && sourceArray.Rank != destinationArray.Rank) throw new RankException(SR.Rank_MustMatch); if (length < 0) throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum); const int srcLB = 0; if (sourceIndex < srcLB || sourceIndex - srcLB < 0) throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_ArrayLB); sourceIndex -= srcLB; const int dstLB = 0; if (destinationIndex < dstLB || destinationIndex - dstLB < 0) throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_ArrayLB); destinationIndex -= dstLB; if ((uint)(sourceIndex + length) > sourceArray.NativeLength) throw new ArgumentException(SR.Arg_LongerThanSrcArray, nameof(sourceArray)); if ((uint)(destinationIndex + length) > destinationArray.NativeLength) throw new ArgumentException(SR.Arg_LongerThanDestArray, nameof(destinationArray)); EETypePtr sourceElementEEType = sourceArray.ElementEEType; EETypePtr destinationElementEEType = destinationArray.ElementEEType; if (!destinationElementEEType.IsValueType && !destinationElementEEType.IsPointer) { if (!sourceElementEEType.IsValueType && !sourceElementEEType.IsPointer) { CopyImplGcRefArray(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } else if (RuntimeImports.AreTypesAssignable(sourceElementEEType, destinationElementEEType)) { CopyImplValueTypeArrayToReferenceArray(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } else { throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } else { if (RuntimeImports.AreTypesEquivalent(sourceElementEEType, destinationElementEEType)) { if (sourceElementEEType.HasPointers) { CopyImplValueTypeArrayWithInnerGcRefs(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } else { CopyImplValueTypeArrayNoInnerGcRefs(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } } else if (sourceElementEEType.IsPointer && destinationElementEEType.IsPointer) { // CLR compat note: CLR only allows Array.Copy between pointee types that would be assignable // to using array covariance rules (so int*[] can be copied to uint*[], but not to float*[]). // This is rather weird since e.g. we don't allow casting int*[] to uint*[] otherwise. // Instead of trying to replicate the behavior, we're choosing to be simply more permissive here. CopyImplValueTypeArrayNoInnerGcRefs(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } else if (IsSourceElementABaseClassOrInterfaceOfDestinationValueType(sourceElementEEType, destinationElementEEType)) { CopyImplReferenceArrayToValueTypeArray(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } else if (sourceElementEEType.IsPrimitive && destinationElementEEType.IsPrimitive) { if (RuntimeImports.AreTypesAssignable(sourceArray.EETypePtr, destinationArray.EETypePtr)) { // If we're okay casting between these two, we're also okay blitting the values over CopyImplValueTypeArrayNoInnerGcRefs(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } else { // The only case remaining is that primitive types could have a widening conversion between the source element type and the destination // If a widening conversion does not exist we are going to throw an ArrayTypeMismatchException from it. CopyImplPrimitiveTypeWithWidening(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } } else { throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } } private static bool IsSourceElementABaseClassOrInterfaceOfDestinationValueType(EETypePtr sourceElementEEType, EETypePtr destinationElementEEType) { if (sourceElementEEType.IsValueType || sourceElementEEType.IsPointer) return false; // It may look like we're passing the arguments to AreTypesAssignable in the wrong order but we're not. The source array is an interface or Object array, the destination // array is a value type array. Our job is to check if the destination value type implements the interface - which is what this call to AreTypesAssignable does. // The copy loop still checks each element to make sure it actually is the correct valuetype. if (!RuntimeImports.AreTypesAssignable(destinationElementEEType, sourceElementEEType)) return false; return true; } // // Array.CopyImpl case: Gc-ref array to gc-ref array copy. // private static unsafe void CopyImplGcRefArray(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { // For mismatched array types, the desktop Array.Copy has a policy that determines whether to throw an ArrayTypeMismatch without any attempt to copy // or to throw an InvalidCastException in the middle of a copy. This code replicates that policy. EETypePtr sourceElementEEType = sourceArray.ElementEEType; EETypePtr destinationElementEEType = destinationArray.ElementEEType; Debug.Assert(!sourceElementEEType.IsValueType && !sourceElementEEType.IsPointer); Debug.Assert(!destinationElementEEType.IsValueType && !destinationElementEEType.IsPointer); bool attemptCopy = RuntimeImports.AreTypesAssignable(sourceElementEEType, destinationElementEEType); bool mustCastCheckEachElement = !attemptCopy; if (reliable) { if (mustCastCheckEachElement) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_ConstrainedCopy); } else { attemptCopy = attemptCopy || RuntimeImports.AreTypesAssignable(destinationElementEEType, sourceElementEEType); // If either array is an interface array, we allow the attempt to copy even if the other element type does not statically implement the interface. // We don't have an "IsInterface" property in EETypePtr so we instead check for a null BaseType. The only the other MethodTable with a null BaseType is // System.Object but if that were the case, we would already have passed one of the AreTypesAssignable checks above. attemptCopy = attemptCopy || sourceElementEEType.BaseType.IsNull; attemptCopy = attemptCopy || destinationElementEEType.BaseType.IsNull; if (!attemptCopy) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } bool reverseCopy = ((object)sourceArray == (object)destinationArray) && (sourceIndex < destinationIndex); ref object? refDestinationArray = ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(destinationArray)); ref object? refSourceArray = ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(sourceArray)); if (reverseCopy) { sourceIndex += length - 1; destinationIndex += length - 1; for (int i = 0; i < length; i++) { object? value = Unsafe.Add(ref refSourceArray, sourceIndex - i); if (mustCastCheckEachElement && value != null && RuntimeImports.IsInstanceOf(destinationElementEEType, value) == null) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); Unsafe.Add(ref refDestinationArray, destinationIndex - i) = value; } } else { for (int i = 0; i < length; i++) { object? value = Unsafe.Add(ref refSourceArray, sourceIndex + i); if (mustCastCheckEachElement && value != null && RuntimeImports.IsInstanceOf(destinationElementEEType, value) == null) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); Unsafe.Add(ref refDestinationArray, destinationIndex + i) = value; } } } // // Array.CopyImpl case: Value-type array to Object[] or interface array copy. // private static unsafe void CopyImplValueTypeArrayToReferenceArray(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { Debug.Assert(sourceArray.ElementEEType.IsValueType || sourceArray.ElementEEType.IsPointer); Debug.Assert(!destinationArray.ElementEEType.IsValueType && !destinationArray.ElementEEType.IsPointer); // Caller has already validated this. Debug.Assert(RuntimeImports.AreTypesAssignable(sourceArray.ElementEEType, destinationArray.ElementEEType)); if (reliable) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_ConstrainedCopy); EETypePtr sourceElementEEType = sourceArray.ElementEEType; nuint sourceElementSize = sourceArray.ElementSize; fixed (byte* pSourceArray = &MemoryMarshal.GetArrayDataReference(sourceArray)) { byte* pElement = pSourceArray + (nuint)sourceIndex * sourceElementSize; ref object refDestinationArray = ref Unsafe.As<byte, object>(ref MemoryMarshal.GetArrayDataReference(destinationArray)); for (int i = 0; i < length; i++) { object boxedValue = RuntimeImports.RhBox(sourceElementEEType, ref *pElement); Unsafe.Add(ref refDestinationArray, destinationIndex + i) = boxedValue; pElement += sourceElementSize; } } } // // Array.CopyImpl case: Object[] or interface array to value-type array copy. // private static unsafe void CopyImplReferenceArrayToValueTypeArray(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { Debug.Assert(!sourceArray.ElementEEType.IsValueType && !sourceArray.ElementEEType.IsPointer); Debug.Assert(destinationArray.ElementEEType.IsValueType || destinationArray.ElementEEType.IsPointer); if (reliable) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); EETypePtr destinationElementEEType = destinationArray.ElementEEType; nuint destinationElementSize = destinationArray.ElementSize; bool isNullable = destinationElementEEType.IsNullable; fixed (byte* pDestinationArray = &MemoryMarshal.GetArrayDataReference(destinationArray)) { ref object refSourceArray = ref Unsafe.As<byte, object>(ref MemoryMarshal.GetArrayDataReference(sourceArray)); byte* pElement = pDestinationArray + (nuint)destinationIndex * destinationElementSize; for (int i = 0; i < length; i++) { object boxedValue = Unsafe.Add(ref refSourceArray, sourceIndex + i); if (boxedValue == null) { if (!isNullable) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); } else { EETypePtr eeType = boxedValue.EETypePtr; if (!(RuntimeImports.AreTypesAssignable(eeType, destinationElementEEType))) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); } RuntimeImports.RhUnbox(boxedValue, ref *pElement, destinationElementEEType); pElement += destinationElementSize; } } } // // Array.CopyImpl case: Value-type array with embedded gc-references. // private static unsafe void CopyImplValueTypeArrayWithInnerGcRefs(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { Debug.Assert(RuntimeImports.AreTypesEquivalent(sourceArray.EETypePtr, destinationArray.EETypePtr)); Debug.Assert(sourceArray.ElementEEType.IsValueType); EETypePtr sourceElementEEType = sourceArray.EETypePtr.ArrayElementType; bool reverseCopy = ((object)sourceArray == (object)destinationArray) && (sourceIndex < destinationIndex); // Copy scenario: ValueType-array to value-type array with embedded gc-refs. object[]? boxedElements = null; if (reliable) { boxedElements = new object[length]; reverseCopy = false; } fixed (byte* pDstArray = &MemoryMarshal.GetArrayDataReference(destinationArray), pSrcArray = &MemoryMarshal.GetArrayDataReference(sourceArray)) { nuint cbElementSize = sourceArray.ElementSize; byte* pSourceElement = pSrcArray + (nuint)sourceIndex * cbElementSize; byte* pDestinationElement = pDstArray + (nuint)destinationIndex * cbElementSize; if (reverseCopy) { pSourceElement += (nuint)length * cbElementSize; pDestinationElement += (nuint)length * cbElementSize; } for (int i = 0; i < length; i++) { if (reverseCopy) { pSourceElement -= cbElementSize; pDestinationElement -= cbElementSize; } object boxedValue = RuntimeImports.RhBox(sourceElementEEType, ref *pSourceElement); if (boxedElements != null) boxedElements[i] = boxedValue; else RuntimeImports.RhUnbox(boxedValue, ref *pDestinationElement, sourceElementEEType); if (!reverseCopy) { pSourceElement += cbElementSize; pDestinationElement += cbElementSize; } } } if (boxedElements != null) { fixed (byte* pDstArray = &MemoryMarshal.GetArrayDataReference(destinationArray)) { nuint cbElementSize = sourceArray.ElementSize; byte* pDestinationElement = pDstArray + (nuint)destinationIndex * cbElementSize; for (int i = 0; i < length; i++) { RuntimeImports.RhUnbox(boxedElements[i], ref *pDestinationElement, sourceElementEEType); pDestinationElement += cbElementSize; } } } } // // Array.CopyImpl case: Value-type array without embedded gc-references. // private static unsafe void CopyImplValueTypeArrayNoInnerGcRefs(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { Debug.Assert((sourceArray.ElementEEType.IsValueType && !sourceArray.ElementEEType.HasPointers) || sourceArray.ElementEEType.IsPointer); Debug.Assert((destinationArray.ElementEEType.IsValueType && !destinationArray.ElementEEType.HasPointers) || destinationArray.ElementEEType.IsPointer); // Copy scenario: ValueType-array to value-type array with no embedded gc-refs. nuint elementSize = sourceArray.ElementSize; Buffer.Memmove( ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(destinationArray), (nuint)destinationIndex * elementSize), ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(sourceArray), (nuint)sourceIndex * elementSize), elementSize * (nuint)length); } // // Array.CopyImpl case: Primitive types that have a widening conversion // private static unsafe void CopyImplPrimitiveTypeWithWidening(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { EETypePtr sourceElementEEType = sourceArray.ElementEEType; EETypePtr destinationElementEEType = destinationArray.ElementEEType; Debug.Assert(sourceElementEEType.IsPrimitive && destinationElementEEType.IsPrimitive); // Caller has already validated this. EETypeElementType sourceElementType = sourceElementEEType.ElementType; EETypeElementType destElementType = destinationElementEEType.ElementType; nuint srcElementSize = sourceArray.ElementSize; nuint destElementSize = destinationArray.ElementSize; if ((sourceElementEEType.IsEnum || destinationElementEEType.IsEnum) && sourceElementType != destElementType) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); if (reliable) { // ContrainedCopy() cannot even widen - it can only copy same type or enum to its exact integral subtype. if (sourceElementType != destElementType) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_ConstrainedCopy); } fixed (byte* pSrcArray = &MemoryMarshal.GetArrayDataReference(sourceArray), pDstArray = &MemoryMarshal.GetArrayDataReference(destinationArray)) { byte* srcData = pSrcArray + (nuint)sourceIndex * srcElementSize; byte* data = pDstArray + (nuint)destinationIndex * destElementSize; if (sourceElementType == destElementType) { // Multidim arrays and enum->int copies can still reach this path. Buffer.Memmove(ref *data, ref *srcData, (nuint)length * srcElementSize); return; } ulong dummyElementForZeroLengthCopies = 0; // If the element types aren't identical and the length is zero, we're still obliged to check the types for widening compatibility. // We do this by forcing the loop below to copy one dummy element. if (length == 0) { srcData = (byte*)&dummyElementForZeroLengthCopies; data = (byte*)&dummyElementForZeroLengthCopies; length = 1; } for (int i = 0; i < length; i++, srcData += srcElementSize, data += destElementSize) { // We pretty much have to do some fancy datatype mangling every time here, for // converting w/ sign extension and floating point conversions. switch (sourceElementType) { case EETypeElementType.Byte: { switch (destElementType) { case EETypeElementType.Single: *(float*)data = *(byte*)srcData; break; case EETypeElementType.Double: *(double*)data = *(byte*)srcData; break; case EETypeElementType.Char: case EETypeElementType.Int16: case EETypeElementType.UInt16: *(short*)data = *(byte*)srcData; break; case EETypeElementType.Int32: case EETypeElementType.UInt32: *(int*)data = *(byte*)srcData; break; case EETypeElementType.Int64: case EETypeElementType.UInt64: *(long*)data = *(byte*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; } case EETypeElementType.SByte: switch (destElementType) { case EETypeElementType.Int16: *(short*)data = *(sbyte*)srcData; break; case EETypeElementType.Int32: *(int*)data = *(sbyte*)srcData; break; case EETypeElementType.Int64: *(long*)data = *(sbyte*)srcData; break; case EETypeElementType.Single: *(float*)data = *(sbyte*)srcData; break; case EETypeElementType.Double: *(double*)data = *(sbyte*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.UInt16: case EETypeElementType.Char: switch (destElementType) { case EETypeElementType.Single: *(float*)data = *(ushort*)srcData; break; case EETypeElementType.Double: *(double*)data = *(ushort*)srcData; break; case EETypeElementType.UInt16: case EETypeElementType.Char: *(ushort*)data = *(ushort*)srcData; break; case EETypeElementType.Int32: case EETypeElementType.UInt32: *(uint*)data = *(ushort*)srcData; break; case EETypeElementType.Int64: case EETypeElementType.UInt64: *(ulong*)data = *(ushort*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.Int16: switch (destElementType) { case EETypeElementType.Int32: *(int*)data = *(short*)srcData; break; case EETypeElementType.Int64: *(long*)data = *(short*)srcData; break; case EETypeElementType.Single: *(float*)data = *(short*)srcData; break; case EETypeElementType.Double: *(double*)data = *(short*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.Int32: switch (destElementType) { case EETypeElementType.Int64: *(long*)data = *(int*)srcData; break; case EETypeElementType.Single: *(float*)data = (float)*(int*)srcData; break; case EETypeElementType.Double: *(double*)data = *(int*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.UInt32: switch (destElementType) { case EETypeElementType.Int64: case EETypeElementType.UInt64: *(long*)data = *(uint*)srcData; break; case EETypeElementType.Single: *(float*)data = (float)*(uint*)srcData; break; case EETypeElementType.Double: *(double*)data = *(uint*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.Int64: switch (destElementType) { case EETypeElementType.Single: *(float*)data = (float)*(long*)srcData; break; case EETypeElementType.Double: *(double*)data = (double)*(long*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.UInt64: switch (destElementType) { case EETypeElementType.Single: //*(float*) data = (float) *(Ulong*)srcData; long srcValToFloat = *(long*)srcData; float f = (float)srcValToFloat; if (srcValToFloat < 0) f += 4294967296.0f * 4294967296.0f; // This is 2^64 *(float*)data = f; break; case EETypeElementType.Double: //*(double*) data = (double) *(Ulong*)srcData; long srcValToDouble = *(long*)srcData; double d = (double)srcValToDouble; if (srcValToDouble < 0) d += 4294967296.0 * 4294967296.0; // This is 2^64 *(double*)data = d; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.Single: switch (destElementType) { case EETypeElementType.Double: *(double*)data = *(float*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } } } public static unsafe void Clear(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); EETypePtr eeType = array.EETypePtr; nuint totalByteLength = eeType.ComponentSize * array.NativeLength; ref byte pStart = ref MemoryMarshal.GetArrayDataReference(array); if (!eeType.HasPointers) { SpanHelpers.ClearWithoutReferences(ref pStart, totalByteLength); } else { Debug.Assert(totalByteLength % (nuint)sizeof(IntPtr) == 0); SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref pStart), totalByteLength / (nuint)sizeof(IntPtr)); } } public static unsafe void Clear(Array array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); ref byte p = ref Unsafe.As<RawArrayData>(array).Data; int lowerBound = 0; EETypePtr eeType = array.EETypePtr; if (!eeType.IsSzArray) { int rank = eeType.ArrayRank; lowerBound = Unsafe.Add(ref Unsafe.As<byte, int>(ref p), rank); p = ref Unsafe.Add(ref p, 2 * sizeof(int) * rank); // skip the bounds } int offset = index - lowerBound; if (index < lowerBound || offset < 0 || length < 0 || (uint)(offset + length) > array.NativeLength) ThrowHelper.ThrowIndexOutOfRangeException(); nuint elementSize = eeType.ComponentSize; ref byte ptr = ref Unsafe.AddByteOffset(ref p, (uint)offset * elementSize); nuint byteLength = (uint)length * elementSize; if (eeType.HasPointers) { Debug.Assert(byteLength % (nuint)sizeof(IntPtr) == 0); SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); } else { SpanHelpers.ClearWithoutReferences(ref ptr, byteLength); } // GC.KeepAlive(array) not required. pMT kept alive via `ptr` } [Intrinsic] public int GetLength(int dimension) { int length = GetUpperBound(dimension) + 1; // We don't support non-zero lower bounds so don't incur the cost of obtaining it. Debug.Assert(GetLowerBound(dimension) == 0); return length; } public int Rank { get { return this.EETypePtr.ArrayRank; } } // Allocate new multidimensional array of given dimensions. Assumes that that pLengths is immutable. internal static unsafe Array NewMultiDimArray(EETypePtr eeType, int* pLengths, int rank) { Debug.Assert(eeType.IsArray && !eeType.IsSzArray); Debug.Assert(rank == eeType.ArrayRank); // Code below assumes 0 lower bounds. MdArray of rank 1 with zero lower bounds should never be allocated. // The runtime always allocates an SzArray for those: // * newobj instance void int32[0...]::.ctor(int32)" actually gives you int[] // * int[] is castable to int[*] to make it mostly transparent // The callers need to check for this. Debug.Assert(rank != 1); ulong totalLength = 1; bool maxArrayDimensionLengthOverflow = false; for (int i = 0; i < rank; i++) { int length = pLengths[i]; if (length < 0) throw new OverflowException(); if (length > MaxLength) maxArrayDimensionLengthOverflow = true; totalLength = totalLength * (ulong)length; if (totalLength > int.MaxValue) throw new OutOfMemoryException(); // "Array dimensions exceeded supported range." } // Throw this exception only after everything else was validated for backward compatibility. if (maxArrayDimensionLengthOverflow) throw new OutOfMemoryException(); // "Array dimensions exceeded supported range." Array ret = RuntimeImports.RhNewArray(eeType, (int)totalLength); ref int bounds = ref ret.GetRawMultiDimArrayBounds(); for (int i = 0; i < rank; i++) { Unsafe.Add(ref bounds, i) = pLengths[i]; } return ret; } [Intrinsic] public int GetLowerBound(int dimension) { if (!IsSzArray) { int rank = Rank; if ((uint)dimension >= rank) throw new IndexOutOfRangeException(); return Unsafe.Add(ref GetRawMultiDimArrayBounds(), rank + dimension); } if (dimension != 0) throw new IndexOutOfRangeException(); return 0; } [Intrinsic] public int GetUpperBound(int dimension) { if (!IsSzArray) { int rank = Rank; if ((uint)dimension >= rank) throw new IndexOutOfRangeException(); ref int bounds = ref GetRawMultiDimArrayBounds(); int length = Unsafe.Add(ref bounds, dimension); int lowerBound = Unsafe.Add(ref bounds, rank + dimension); return length + lowerBound - 1; } if (dimension != 0) throw new IndexOutOfRangeException(); return Length - 1; } private unsafe nint GetFlattenedIndex(ReadOnlySpan<int> indices) { // Checked by the caller Debug.Assert(indices.Length == Rank); if (!IsSzArray) { ref int bounds = ref GetRawMultiDimArrayBounds(); nint flattenedIndex = 0; for (int i = 0; i < indices.Length; i++) { int index = indices[i] - Unsafe.Add(ref bounds, indices.Length + i); int length = Unsafe.Add(ref bounds, i); if ((uint)index >= (uint)length) ThrowHelper.ThrowIndexOutOfRangeException(); flattenedIndex = (length * flattenedIndex) + index; } Debug.Assert((nuint)flattenedIndex < NativeLength); return flattenedIndex; } else { int index = indices[0]; if ((uint)index >= NativeLength) ThrowHelper.ThrowIndexOutOfRangeException(); return index; } } internal object? InternalGetValue(nint flattenedIndex) { Debug.Assert((nuint)flattenedIndex < NativeLength); if (ElementEEType.IsPointer) throw new NotSupportedException(SR.NotSupported_Type); ref byte element = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(this), (nuint)flattenedIndex * ElementSize); EETypePtr pElementEEType = ElementEEType; if (pElementEEType.IsValueType) { return RuntimeImports.RhBox(pElementEEType, ref element); } else { Debug.Assert(!pElementEEType.IsPointer); return Unsafe.As<byte, object>(ref element); } } private unsafe void InternalSetValue(object? value, nint flattenedIndex) { Debug.Assert((nuint)flattenedIndex < NativeLength); if (ElementEEType.IsPointer) throw new NotSupportedException(SR.NotSupported_Type); ref byte element = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(this), (nuint)flattenedIndex * ElementSize); EETypePtr pElementEEType = ElementEEType; if (pElementEEType.IsValueType) { // Unlike most callers of InvokeUtils.ChangeType(), Array.SetValue() does *not* permit conversion from a primitive to an Enum. if (value != null && !(value.EETypePtr == pElementEEType) && pElementEEType.IsEnum) throw new InvalidCastException(SR.Format(SR.Arg_ObjObjEx, value.GetType(), Type.GetTypeFromHandle(new RuntimeTypeHandle(pElementEEType)))); value = InvokeUtils.CheckArgument(value, pElementEEType, InvokeUtils.CheckArgumentSemantics.ArraySet, binderBundle: null); Debug.Assert(value == null || RuntimeImports.AreTypesAssignable(value.EETypePtr, pElementEEType)); RuntimeImports.RhUnbox(value, ref element, pElementEEType); } else if (pElementEEType.IsPointer) { throw new NotSupportedException(SR.NotSupported_Type); } else { try { RuntimeImports.RhCheckArrayStore(this, value); } catch (ArrayTypeMismatchException) { throw new InvalidCastException(SR.InvalidCast_StoreArrayElement); } Unsafe.As<byte, object?>(ref element) = value; } } internal EETypePtr ElementEEType { get { return this.EETypePtr.ArrayElementType; } } internal CorElementType GetCorElementTypeOfElementType() { return ElementEEType.CorElementType; } internal bool IsValueOfElementType(object o) { return ElementEEType.Equals(o.EETypePtr); } // // Return storage size of an individual element in bytes. // internal nuint ElementSize { get { return EETypePtr.ComponentSize; } } private static int IndexOfImpl<T>(T[] array, T value, int startIndex, int count) { // See comment in EqualityComparerHelpers.GetComparerForReferenceTypesOnly for details EqualityComparer<T> comparer = EqualityComparerHelpers.GetComparerForReferenceTypesOnly<T>(); int endIndex = startIndex + count; if (comparer != null) { for (int i = startIndex; i < endIndex; i++) { if (comparer.Equals(array[i], value)) return i; } } else { for (int i = startIndex; i < endIndex; i++) { if (EqualityComparerHelpers.StructOnlyEquals<T>(array[i], value)) return i; } } return -1; } private static int LastIndexOfImpl<T>(T[] array, T value, int startIndex, int count) { // See comment in EqualityComparerHelpers.GetComparerForReferenceTypesOnly for details EqualityComparer<T> comparer = EqualityComparerHelpers.GetComparerForReferenceTypesOnly<T>(); int endIndex = startIndex - count + 1; if (comparer != null) { for (int i = startIndex; i >= endIndex; i--) { if (comparer.Equals(array[i], value)) return i; } } else { for (int i = startIndex; i >= endIndex; i--) { if (EqualityComparerHelpers.StructOnlyEquals<T>(array[i], value)) return i; } } return -1; } } internal class ArrayEnumeratorBase : ICloneable { protected int _index; protected int _endIndex; internal ArrayEnumeratorBase() { _index = -1; } public bool MoveNext() { if (_index < _endIndex) { _index++; return (_index < _endIndex); } return false; } public void Dispose() { } public object Clone() { return MemberwiseClone(); } } // // Note: the declared base type and interface list also determines what Reflection returns from TypeInfo.BaseType and TypeInfo.ImplementedInterfaces for array types. // This also means the class must be declared "public" so that the framework can reflect on it. // public class Array<T> : Array, IEnumerable<T>, ICollection<T>, IList<T>, IReadOnlyList<T> { // Prevent the C# compiler from generating a public default constructor private Array() { } public new IEnumerator<T> GetEnumerator() { // get length so we don't have to call the Length property again in ArrayEnumerator constructor // and avoid more checking there too. int length = this.Length; return length == 0 ? ArrayEnumerator.Empty : new ArrayEnumerator(Unsafe.As<T[]>(this), length); } public int Count { get { return this.Length; } } // // Fun fact: // // ((int[])a).IsReadOnly returns false. // ((IList<int>)a).IsReadOnly returns true. // public new bool IsReadOnly { get { return true; } } public void Add(T item) { ThrowHelper.ThrowNotSupportedException(); } public void Clear() { ThrowHelper.ThrowNotSupportedException(); } public bool Contains(T item) { T[] array = Unsafe.As<T[]>(this); return Array.IndexOf(array, item, 0, array.Length) >= 0; } public void CopyTo(T[] array, int arrayIndex) { Array.Copy(Unsafe.As<T[]>(this), 0, array, arrayIndex, this.Length); } public bool Remove(T item) { ThrowHelper.ThrowNotSupportedException(); return false; // unreachable } public T this[int index] { get { try { return Unsafe.As<T[]>(this)[index]; } catch (IndexOutOfRangeException) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); return default; // unreachable } } set { try { Unsafe.As<T[]>(this)[index] = value; } catch (IndexOutOfRangeException) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } } } public int IndexOf(T item) { T[] array = Unsafe.As<T[]>(this); return Array.IndexOf(array, item, 0, array.Length); } public void Insert(int index, T item) { ThrowHelper.ThrowNotSupportedException(); } public void RemoveAt(int index) { ThrowHelper.ThrowNotSupportedException(); } private sealed class ArrayEnumerator : ArrayEnumeratorBase, IEnumerator<T> { private readonly T[] _array; // Passing -1 for endIndex so that MoveNext always returns false without mutating _index internal static readonly ArrayEnumerator Empty = new ArrayEnumerator(null, -1); internal ArrayEnumerator(T[] array, int endIndex) { _array = array; _endIndex = endIndex; } public T Current { get { if ((uint)_index >= (uint)_endIndex) ThrowHelper.ThrowInvalidOperationException(); return _array[_index]; } } object IEnumerator.Current { get { return Current; } } void IEnumerator.Reset() { _index = -1; } } } public class MDArray { public const int MinRank = 1; public const int MaxRank = 32; } }
// 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; using System.Threading; using System.Collections; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Internal.Runtime.Augments; using Internal.Runtime.CompilerServices; using Internal.Reflection.Core.NonPortable; using Internal.IntrinsicSupport; using MethodTable = Internal.Runtime.MethodTable; using EETypeElementType = Internal.Runtime.EETypeElementType; namespace System { // Note that we make a T[] (single-dimensional w/ zero as the lower bound) implement both // IList<U> and IReadOnlyList<U>, where T : U dynamically. See the SZArrayHelper class for details. public abstract partial class Array : ICollection, IEnumerable, IList, IStructuralComparable, IStructuralEquatable, ICloneable { // CS0169: The field 'Array._numComponents' is never used #pragma warning disable 0169 // This field should be the first field in Array as the runtime/compilers depend on it [NonSerialized] private int _numComponents; #pragma warning restore #if TARGET_64BIT private const int POINTER_SIZE = 8; #else private const int POINTER_SIZE = 4; #endif // Header + m_pEEType + _numComponents (with an optional padding) private const int SZARRAY_BASE_SIZE = POINTER_SIZE + POINTER_SIZE + POINTER_SIZE; public int Length => checked((int)Unsafe.As<RawArrayData>(this).Length); // This could return a length greater than int.MaxValue internal nuint NativeLength => Unsafe.As<RawArrayData>(this).Length; public long LongLength => (long)NativeLength; internal bool IsSzArray { get { return this.EETypePtr.BaseSize == SZARRAY_BASE_SIZE; } } // This is the classlib-provided "get array MethodTable" function that will be invoked whenever the runtime // needs to know the base type of an array. [RuntimeExport("GetSystemArrayEEType")] private static unsafe MethodTable* GetSystemArrayEEType() { return EETypePtr.EETypePtrOf<Array>().ToPointer(); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] private static unsafe Array InternalCreate(RuntimeType elementType, int rank, int* pLengths, int* pLowerBounds) { ValidateElementType(elementType); if (pLowerBounds != null) { for (int i = 0; i < rank; i++) { if (pLowerBounds[i] != 0) throw new PlatformNotSupportedException(SR.PlatformNotSupported_NonZeroLowerBound); } } if (rank == 1) { return RuntimeImports.RhNewArray(elementType.MakeArrayType().TypeHandle.ToEETypePtr(), pLengths[0]); } else { // Create a local copy of the lenghts that cannot be motified by the caller int* pImmutableLengths = stackalloc int[rank]; for (int i = 0; i < rank; i++) pImmutableLengths[i] = pLengths[i]; return NewMultiDimArray(elementType.MakeArrayType(rank).TypeHandle.ToEETypePtr(), pImmutableLengths, rank); } } private static void ValidateElementType(Type elementType) { while (elementType.IsArray) { elementType = elementType.GetElementType()!; } if (elementType.IsByRef || elementType.IsByRefLike) throw new NotSupportedException(SR.NotSupported_ByRefLikeArray); if (elementType == typeof(void)) throw new NotSupportedException(SR.NotSupported_VoidArray); if (elementType.ContainsGenericParameters) throw new NotSupportedException(SR.NotSupported_OpenType); } public void Initialize() { // Project N port note: On the desktop, this api is a nop unless the array element type is a value type with // an explicit nullary constructor. Such a type cannot be expressed in C# so Project N does not support this. // The ILC toolchain fails the build if it encounters such a type. return; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private ref int GetRawMultiDimArrayBounds() { Debug.Assert(!IsSzArray); return ref Unsafe.As<byte, int>(ref Unsafe.As<RawArrayData>(this).Data); } // Provides a strong exception guarantee - either it succeeds, or // it throws an exception with no side effects. The arrays must be // compatible array types based on the array element type - this // method does not support casting, boxing, or primitive widening. // It will up-cast, assuming the array types are correct. public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { CopyImpl(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable: true); } public static void Copy(Array sourceArray, Array destinationArray, int length) { if (sourceArray is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray); if (destinationArray is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray); EETypePtr eeType = sourceArray.EETypePtr; if (eeType.FastEquals(destinationArray.EETypePtr) && eeType.IsSzArray && (uint)length <= sourceArray.NativeLength && (uint)length <= destinationArray.NativeLength) { nuint byteCount = (uint)length * (nuint)eeType.ComponentSize; ref byte src = ref Unsafe.As<RawArrayData>(sourceArray).Data; ref byte dst = ref Unsafe.As<RawArrayData>(destinationArray).Data; if (eeType.HasPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } // Less common CopyImpl(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length, reliable: false); } public static unsafe void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { if (sourceArray != null && destinationArray != null) { EETypePtr eeType = sourceArray.EETypePtr; if (eeType.FastEquals(destinationArray.EETypePtr) && eeType.IsSzArray && length >= 0 && sourceIndex >= 0 && destinationIndex >= 0 && (uint)(sourceIndex + length) <= sourceArray.NativeLength && (uint)(destinationIndex + length) <= destinationArray.NativeLength) { nuint elementSize = (nuint)eeType.ComponentSize; nuint byteCount = (uint)length * elementSize; ref byte src = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(sourceArray).Data, (uint)sourceIndex * elementSize); ref byte dst = ref Unsafe.AddByteOffset(ref Unsafe.As<RawArrayData>(destinationArray).Data, (uint)destinationIndex * elementSize); if (eeType.HasPointers) Buffer.BulkMoveWithWriteBarrier(ref dst, ref src, byteCount); else Buffer.Memmove(ref dst, ref src, byteCount); // GC.KeepAlive(sourceArray) not required. pMT kept alive via sourceArray return; } } // Less common CopyImpl(sourceArray!, sourceIndex, destinationArray!, destinationIndex, length, reliable: false); } // // Funnel for all the Array.Copy() overloads. The "reliable" parameter indicates whether the caller for ConstrainedCopy() // (must leave destination array unchanged on any exception.) // private static unsafe void CopyImpl(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { if (sourceArray is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.sourceArray); if (destinationArray is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.destinationArray); if (sourceArray.GetType() != destinationArray.GetType() && sourceArray.Rank != destinationArray.Rank) throw new RankException(SR.Rank_MustMatch); if (length < 0) throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum); const int srcLB = 0; if (sourceIndex < srcLB || sourceIndex - srcLB < 0) throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_ArrayLB); sourceIndex -= srcLB; const int dstLB = 0; if (destinationIndex < dstLB || destinationIndex - dstLB < 0) throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_ArrayLB); destinationIndex -= dstLB; if ((uint)(sourceIndex + length) > sourceArray.NativeLength) throw new ArgumentException(SR.Arg_LongerThanSrcArray, nameof(sourceArray)); if ((uint)(destinationIndex + length) > destinationArray.NativeLength) throw new ArgumentException(SR.Arg_LongerThanDestArray, nameof(destinationArray)); EETypePtr sourceElementEEType = sourceArray.ElementEEType; EETypePtr destinationElementEEType = destinationArray.ElementEEType; if (!destinationElementEEType.IsValueType && !destinationElementEEType.IsPointer) { if (!sourceElementEEType.IsValueType && !sourceElementEEType.IsPointer) { CopyImplGcRefArray(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } else if (RuntimeImports.AreTypesAssignable(sourceElementEEType, destinationElementEEType)) { CopyImplValueTypeArrayToReferenceArray(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } else { throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } else { if (RuntimeImports.AreTypesEquivalent(sourceElementEEType, destinationElementEEType)) { if (sourceElementEEType.HasPointers) { CopyImplValueTypeArrayWithInnerGcRefs(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } else { CopyImplValueTypeArrayNoInnerGcRefs(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } } else if (sourceElementEEType.IsPointer && destinationElementEEType.IsPointer) { // CLR compat note: CLR only allows Array.Copy between pointee types that would be assignable // to using array covariance rules (so int*[] can be copied to uint*[], but not to float*[]). // This is rather weird since e.g. we don't allow casting int*[] to uint*[] otherwise. // Instead of trying to replicate the behavior, we're choosing to be simply more permissive here. CopyImplValueTypeArrayNoInnerGcRefs(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } else if (IsSourceElementABaseClassOrInterfaceOfDestinationValueType(sourceElementEEType, destinationElementEEType)) { CopyImplReferenceArrayToValueTypeArray(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } else if (sourceElementEEType.IsPrimitive && destinationElementEEType.IsPrimitive) { if (RuntimeImports.AreTypesAssignable(sourceArray.EETypePtr, destinationArray.EETypePtr)) { // If we're okay casting between these two, we're also okay blitting the values over CopyImplValueTypeArrayNoInnerGcRefs(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } else { // The only case remaining is that primitive types could have a widening conversion between the source element type and the destination // If a widening conversion does not exist we are going to throw an ArrayTypeMismatchException from it. CopyImplPrimitiveTypeWithWidening(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } } else { throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } } private static bool IsSourceElementABaseClassOrInterfaceOfDestinationValueType(EETypePtr sourceElementEEType, EETypePtr destinationElementEEType) { if (sourceElementEEType.IsValueType || sourceElementEEType.IsPointer) return false; // It may look like we're passing the arguments to AreTypesAssignable in the wrong order but we're not. The source array is an interface or Object array, the destination // array is a value type array. Our job is to check if the destination value type implements the interface - which is what this call to AreTypesAssignable does. // The copy loop still checks each element to make sure it actually is the correct valuetype. if (!RuntimeImports.AreTypesAssignable(destinationElementEEType, sourceElementEEType)) return false; return true; } // // Array.CopyImpl case: Gc-ref array to gc-ref array copy. // private static unsafe void CopyImplGcRefArray(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { // For mismatched array types, the desktop Array.Copy has a policy that determines whether to throw an ArrayTypeMismatch without any attempt to copy // or to throw an InvalidCastException in the middle of a copy. This code replicates that policy. EETypePtr sourceElementEEType = sourceArray.ElementEEType; EETypePtr destinationElementEEType = destinationArray.ElementEEType; Debug.Assert(!sourceElementEEType.IsValueType && !sourceElementEEType.IsPointer); Debug.Assert(!destinationElementEEType.IsValueType && !destinationElementEEType.IsPointer); bool attemptCopy = RuntimeImports.AreTypesAssignable(sourceElementEEType, destinationElementEEType); bool mustCastCheckEachElement = !attemptCopy; if (reliable) { if (mustCastCheckEachElement) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_ConstrainedCopy); } else { attemptCopy = attemptCopy || RuntimeImports.AreTypesAssignable(destinationElementEEType, sourceElementEEType); // If either array is an interface array, we allow the attempt to copy even if the other element type does not statically implement the interface. // We don't have an "IsInterface" property in EETypePtr so we instead check for a null BaseType. The only the other MethodTable with a null BaseType is // System.Object but if that were the case, we would already have passed one of the AreTypesAssignable checks above. attemptCopy = attemptCopy || sourceElementEEType.BaseType.IsNull; attemptCopy = attemptCopy || destinationElementEEType.BaseType.IsNull; if (!attemptCopy) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } bool reverseCopy = ((object)sourceArray == (object)destinationArray) && (sourceIndex < destinationIndex); ref object? refDestinationArray = ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(destinationArray)); ref object? refSourceArray = ref Unsafe.As<byte, object?>(ref MemoryMarshal.GetArrayDataReference(sourceArray)); if (reverseCopy) { sourceIndex += length - 1; destinationIndex += length - 1; for (int i = 0; i < length; i++) { object? value = Unsafe.Add(ref refSourceArray, sourceIndex - i); if (mustCastCheckEachElement && value != null && RuntimeImports.IsInstanceOf(destinationElementEEType, value) == null) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); Unsafe.Add(ref refDestinationArray, destinationIndex - i) = value; } } else { for (int i = 0; i < length; i++) { object? value = Unsafe.Add(ref refSourceArray, sourceIndex + i); if (mustCastCheckEachElement && value != null && RuntimeImports.IsInstanceOf(destinationElementEEType, value) == null) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); Unsafe.Add(ref refDestinationArray, destinationIndex + i) = value; } } } // // Array.CopyImpl case: Value-type array to Object[] or interface array copy. // private static unsafe void CopyImplValueTypeArrayToReferenceArray(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { Debug.Assert(sourceArray.ElementEEType.IsValueType || sourceArray.ElementEEType.IsPointer); Debug.Assert(!destinationArray.ElementEEType.IsValueType && !destinationArray.ElementEEType.IsPointer); // Caller has already validated this. Debug.Assert(RuntimeImports.AreTypesAssignable(sourceArray.ElementEEType, destinationArray.ElementEEType)); if (reliable) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_ConstrainedCopy); EETypePtr sourceElementEEType = sourceArray.ElementEEType; nuint sourceElementSize = sourceArray.ElementSize; fixed (byte* pSourceArray = &MemoryMarshal.GetArrayDataReference(sourceArray)) { byte* pElement = pSourceArray + (nuint)sourceIndex * sourceElementSize; ref object refDestinationArray = ref Unsafe.As<byte, object>(ref MemoryMarshal.GetArrayDataReference(destinationArray)); for (int i = 0; i < length; i++) { object boxedValue = RuntimeImports.RhBox(sourceElementEEType, ref *pElement); Unsafe.Add(ref refDestinationArray, destinationIndex + i) = boxedValue; pElement += sourceElementSize; } } } // // Array.CopyImpl case: Object[] or interface array to value-type array copy. // private static unsafe void CopyImplReferenceArrayToValueTypeArray(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { Debug.Assert(!sourceArray.ElementEEType.IsValueType && !sourceArray.ElementEEType.IsPointer); Debug.Assert(destinationArray.ElementEEType.IsValueType || destinationArray.ElementEEType.IsPointer); if (reliable) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); EETypePtr destinationElementEEType = destinationArray.ElementEEType; nuint destinationElementSize = destinationArray.ElementSize; bool isNullable = destinationElementEEType.IsNullable; fixed (byte* pDestinationArray = &MemoryMarshal.GetArrayDataReference(destinationArray)) { ref object refSourceArray = ref Unsafe.As<byte, object>(ref MemoryMarshal.GetArrayDataReference(sourceArray)); byte* pElement = pDestinationArray + (nuint)destinationIndex * destinationElementSize; for (int i = 0; i < length; i++) { object boxedValue = Unsafe.Add(ref refSourceArray, sourceIndex + i); if (boxedValue == null) { if (!isNullable) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); } else { EETypePtr eeType = boxedValue.EETypePtr; if (!(RuntimeImports.AreTypesAssignable(eeType, destinationElementEEType))) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); } RuntimeImports.RhUnbox(boxedValue, ref *pElement, destinationElementEEType); pElement += destinationElementSize; } } } // // Array.CopyImpl case: Value-type array with embedded gc-references. // private static unsafe void CopyImplValueTypeArrayWithInnerGcRefs(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { Debug.Assert(RuntimeImports.AreTypesEquivalent(sourceArray.EETypePtr, destinationArray.EETypePtr)); Debug.Assert(sourceArray.ElementEEType.IsValueType); EETypePtr sourceElementEEType = sourceArray.EETypePtr.ArrayElementType; bool reverseCopy = ((object)sourceArray == (object)destinationArray) && (sourceIndex < destinationIndex); // Copy scenario: ValueType-array to value-type array with embedded gc-refs. object[]? boxedElements = null; if (reliable) { boxedElements = new object[length]; reverseCopy = false; } fixed (byte* pDstArray = &MemoryMarshal.GetArrayDataReference(destinationArray), pSrcArray = &MemoryMarshal.GetArrayDataReference(sourceArray)) { nuint cbElementSize = sourceArray.ElementSize; byte* pSourceElement = pSrcArray + (nuint)sourceIndex * cbElementSize; byte* pDestinationElement = pDstArray + (nuint)destinationIndex * cbElementSize; if (reverseCopy) { pSourceElement += (nuint)length * cbElementSize; pDestinationElement += (nuint)length * cbElementSize; } for (int i = 0; i < length; i++) { if (reverseCopy) { pSourceElement -= cbElementSize; pDestinationElement -= cbElementSize; } object boxedValue = RuntimeImports.RhBox(sourceElementEEType, ref *pSourceElement); if (boxedElements != null) boxedElements[i] = boxedValue; else RuntimeImports.RhUnbox(boxedValue, ref *pDestinationElement, sourceElementEEType); if (!reverseCopy) { pSourceElement += cbElementSize; pDestinationElement += cbElementSize; } } } if (boxedElements != null) { fixed (byte* pDstArray = &MemoryMarshal.GetArrayDataReference(destinationArray)) { nuint cbElementSize = sourceArray.ElementSize; byte* pDestinationElement = pDstArray + (nuint)destinationIndex * cbElementSize; for (int i = 0; i < length; i++) { RuntimeImports.RhUnbox(boxedElements[i], ref *pDestinationElement, sourceElementEEType); pDestinationElement += cbElementSize; } } } } // // Array.CopyImpl case: Value-type array without embedded gc-references. // private static unsafe void CopyImplValueTypeArrayNoInnerGcRefs(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { Debug.Assert((sourceArray.ElementEEType.IsValueType && !sourceArray.ElementEEType.HasPointers) || sourceArray.ElementEEType.IsPointer); Debug.Assert((destinationArray.ElementEEType.IsValueType && !destinationArray.ElementEEType.HasPointers) || destinationArray.ElementEEType.IsPointer); // Copy scenario: ValueType-array to value-type array with no embedded gc-refs. nuint elementSize = sourceArray.ElementSize; Buffer.Memmove( ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(destinationArray), (nuint)destinationIndex * elementSize), ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(sourceArray), (nuint)sourceIndex * elementSize), elementSize * (nuint)length); } // // Array.CopyImpl case: Primitive types that have a widening conversion // private static unsafe void CopyImplPrimitiveTypeWithWidening(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { EETypePtr sourceElementEEType = sourceArray.ElementEEType; EETypePtr destinationElementEEType = destinationArray.ElementEEType; Debug.Assert(sourceElementEEType.IsPrimitive && destinationElementEEType.IsPrimitive); // Caller has already validated this. EETypeElementType sourceElementType = sourceElementEEType.ElementType; EETypeElementType destElementType = destinationElementEEType.ElementType; nuint srcElementSize = sourceArray.ElementSize; nuint destElementSize = destinationArray.ElementSize; if ((sourceElementEEType.IsEnum || destinationElementEEType.IsEnum) && sourceElementType != destElementType) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); if (reliable) { // ContrainedCopy() cannot even widen - it can only copy same type or enum to its exact integral subtype. if (sourceElementType != destElementType) throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_ConstrainedCopy); } fixed (byte* pSrcArray = &MemoryMarshal.GetArrayDataReference(sourceArray), pDstArray = &MemoryMarshal.GetArrayDataReference(destinationArray)) { byte* srcData = pSrcArray + (nuint)sourceIndex * srcElementSize; byte* data = pDstArray + (nuint)destinationIndex * destElementSize; if (sourceElementType == destElementType) { // Multidim arrays and enum->int copies can still reach this path. Buffer.Memmove(ref *data, ref *srcData, (nuint)length * srcElementSize); return; } ulong dummyElementForZeroLengthCopies = 0; // If the element types aren't identical and the length is zero, we're still obliged to check the types for widening compatibility. // We do this by forcing the loop below to copy one dummy element. if (length == 0) { srcData = (byte*)&dummyElementForZeroLengthCopies; data = (byte*)&dummyElementForZeroLengthCopies; length = 1; } for (int i = 0; i < length; i++, srcData += srcElementSize, data += destElementSize) { // We pretty much have to do some fancy datatype mangling every time here, for // converting w/ sign extension and floating point conversions. switch (sourceElementType) { case EETypeElementType.Byte: { switch (destElementType) { case EETypeElementType.Single: *(float*)data = *(byte*)srcData; break; case EETypeElementType.Double: *(double*)data = *(byte*)srcData; break; case EETypeElementType.Char: case EETypeElementType.Int16: case EETypeElementType.UInt16: *(short*)data = *(byte*)srcData; break; case EETypeElementType.Int32: case EETypeElementType.UInt32: *(int*)data = *(byte*)srcData; break; case EETypeElementType.Int64: case EETypeElementType.UInt64: *(long*)data = *(byte*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; } case EETypeElementType.SByte: switch (destElementType) { case EETypeElementType.Int16: *(short*)data = *(sbyte*)srcData; break; case EETypeElementType.Int32: *(int*)data = *(sbyte*)srcData; break; case EETypeElementType.Int64: *(long*)data = *(sbyte*)srcData; break; case EETypeElementType.Single: *(float*)data = *(sbyte*)srcData; break; case EETypeElementType.Double: *(double*)data = *(sbyte*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.UInt16: case EETypeElementType.Char: switch (destElementType) { case EETypeElementType.Single: *(float*)data = *(ushort*)srcData; break; case EETypeElementType.Double: *(double*)data = *(ushort*)srcData; break; case EETypeElementType.UInt16: case EETypeElementType.Char: *(ushort*)data = *(ushort*)srcData; break; case EETypeElementType.Int32: case EETypeElementType.UInt32: *(uint*)data = *(ushort*)srcData; break; case EETypeElementType.Int64: case EETypeElementType.UInt64: *(ulong*)data = *(ushort*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.Int16: switch (destElementType) { case EETypeElementType.Int32: *(int*)data = *(short*)srcData; break; case EETypeElementType.Int64: *(long*)data = *(short*)srcData; break; case EETypeElementType.Single: *(float*)data = *(short*)srcData; break; case EETypeElementType.Double: *(double*)data = *(short*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.Int32: switch (destElementType) { case EETypeElementType.Int64: *(long*)data = *(int*)srcData; break; case EETypeElementType.Single: *(float*)data = (float)*(int*)srcData; break; case EETypeElementType.Double: *(double*)data = *(int*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.UInt32: switch (destElementType) { case EETypeElementType.Int64: case EETypeElementType.UInt64: *(long*)data = *(uint*)srcData; break; case EETypeElementType.Single: *(float*)data = (float)*(uint*)srcData; break; case EETypeElementType.Double: *(double*)data = *(uint*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.Int64: switch (destElementType) { case EETypeElementType.Single: *(float*)data = (float)*(long*)srcData; break; case EETypeElementType.Double: *(double*)data = (double)*(long*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.UInt64: switch (destElementType) { case EETypeElementType.Single: //*(float*) data = (float) *(Ulong*)srcData; long srcValToFloat = *(long*)srcData; float f = (float)srcValToFloat; if (srcValToFloat < 0) f += 4294967296.0f * 4294967296.0f; // This is 2^64 *(float*)data = f; break; case EETypeElementType.Double: //*(double*) data = (double) *(Ulong*)srcData; long srcValToDouble = *(long*)srcData; double d = (double)srcValToDouble; if (srcValToDouble < 0) d += 4294967296.0 * 4294967296.0; // This is 2^64 *(double*)data = d; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; case EETypeElementType.Single: switch (destElementType) { case EETypeElementType.Double: *(double*)data = *(float*)srcData; break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } break; default: throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } } } public static unsafe void Clear(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); EETypePtr eeType = array.EETypePtr; nuint totalByteLength = eeType.ComponentSize * array.NativeLength; ref byte pStart = ref MemoryMarshal.GetArrayDataReference(array); if (!eeType.HasPointers) { SpanHelpers.ClearWithoutReferences(ref pStart, totalByteLength); } else { Debug.Assert(totalByteLength % (nuint)sizeof(IntPtr) == 0); SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref pStart), totalByteLength / (nuint)sizeof(IntPtr)); } } public static unsafe void Clear(Array array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); ref byte p = ref Unsafe.As<RawArrayData>(array).Data; int lowerBound = 0; EETypePtr eeType = array.EETypePtr; if (!eeType.IsSzArray) { int rank = eeType.ArrayRank; lowerBound = Unsafe.Add(ref Unsafe.As<byte, int>(ref p), rank); p = ref Unsafe.Add(ref p, 2 * sizeof(int) * rank); // skip the bounds } int offset = index - lowerBound; if (index < lowerBound || offset < 0 || length < 0 || (uint)(offset + length) > array.NativeLength) ThrowHelper.ThrowIndexOutOfRangeException(); nuint elementSize = eeType.ComponentSize; ref byte ptr = ref Unsafe.AddByteOffset(ref p, (uint)offset * elementSize); nuint byteLength = (uint)length * elementSize; if (eeType.HasPointers) { Debug.Assert(byteLength % (nuint)sizeof(IntPtr) == 0); SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); } else { SpanHelpers.ClearWithoutReferences(ref ptr, byteLength); } // GC.KeepAlive(array) not required. pMT kept alive via `ptr` } [Intrinsic] public int GetLength(int dimension) { int length = GetUpperBound(dimension) + 1; // We don't support non-zero lower bounds so don't incur the cost of obtaining it. Debug.Assert(GetLowerBound(dimension) == 0); return length; } public int Rank { get { return this.EETypePtr.ArrayRank; } } // Allocate new multidimensional array of given dimensions. Assumes that that pLengths is immutable. internal static unsafe Array NewMultiDimArray(EETypePtr eeType, int* pLengths, int rank) { Debug.Assert(eeType.IsArray && !eeType.IsSzArray); Debug.Assert(rank == eeType.ArrayRank); // Code below assumes 0 lower bounds. MdArray of rank 1 with zero lower bounds should never be allocated. // The runtime always allocates an SzArray for those: // * newobj instance void int32[0...]::.ctor(int32)" actually gives you int[] // * int[] is castable to int[*] to make it mostly transparent // The callers need to check for this. Debug.Assert(rank != 1); ulong totalLength = 1; bool maxArrayDimensionLengthOverflow = false; for (int i = 0; i < rank; i++) { int length = pLengths[i]; if (length < 0) throw new OverflowException(); if (length > MaxLength) maxArrayDimensionLengthOverflow = true; totalLength = totalLength * (ulong)length; if (totalLength > int.MaxValue) throw new OutOfMemoryException(); // "Array dimensions exceeded supported range." } // Throw this exception only after everything else was validated for backward compatibility. if (maxArrayDimensionLengthOverflow) throw new OutOfMemoryException(); // "Array dimensions exceeded supported range." Array ret = RuntimeImports.RhNewArray(eeType, (int)totalLength); ref int bounds = ref ret.GetRawMultiDimArrayBounds(); for (int i = 0; i < rank; i++) { Unsafe.Add(ref bounds, i) = pLengths[i]; } return ret; } [Intrinsic] public int GetLowerBound(int dimension) { if (!IsSzArray) { int rank = Rank; if ((uint)dimension >= rank) throw new IndexOutOfRangeException(); return Unsafe.Add(ref GetRawMultiDimArrayBounds(), rank + dimension); } if (dimension != 0) throw new IndexOutOfRangeException(); return 0; } [Intrinsic] public int GetUpperBound(int dimension) { if (!IsSzArray) { int rank = Rank; if ((uint)dimension >= rank) throw new IndexOutOfRangeException(); ref int bounds = ref GetRawMultiDimArrayBounds(); int length = Unsafe.Add(ref bounds, dimension); int lowerBound = Unsafe.Add(ref bounds, rank + dimension); return length + lowerBound - 1; } if (dimension != 0) throw new IndexOutOfRangeException(); return Length - 1; } private unsafe nint GetFlattenedIndex(ReadOnlySpan<int> indices) { // Checked by the caller Debug.Assert(indices.Length == Rank); if (!IsSzArray) { ref int bounds = ref GetRawMultiDimArrayBounds(); nint flattenedIndex = 0; for (int i = 0; i < indices.Length; i++) { int index = indices[i] - Unsafe.Add(ref bounds, indices.Length + i); int length = Unsafe.Add(ref bounds, i); if ((uint)index >= (uint)length) ThrowHelper.ThrowIndexOutOfRangeException(); flattenedIndex = (length * flattenedIndex) + index; } Debug.Assert((nuint)flattenedIndex < NativeLength); return flattenedIndex; } else { int index = indices[0]; if ((uint)index >= NativeLength) ThrowHelper.ThrowIndexOutOfRangeException(); return index; } } internal object? InternalGetValue(nint flattenedIndex) { Debug.Assert((nuint)flattenedIndex < NativeLength); if (ElementEEType.IsPointer) throw new NotSupportedException(SR.NotSupported_Type); ref byte element = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(this), (nuint)flattenedIndex * ElementSize); EETypePtr pElementEEType = ElementEEType; if (pElementEEType.IsValueType) { return RuntimeImports.RhBox(pElementEEType, ref element); } else { Debug.Assert(!pElementEEType.IsPointer); return Unsafe.As<byte, object>(ref element); } } private unsafe void InternalSetValue(object? value, nint flattenedIndex) { Debug.Assert((nuint)flattenedIndex < NativeLength); if (ElementEEType.IsPointer) throw new NotSupportedException(SR.NotSupported_Type); ref byte element = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(this), (nuint)flattenedIndex * ElementSize); EETypePtr pElementEEType = ElementEEType; if (pElementEEType.IsValueType) { // Unlike most callers of InvokeUtils.ChangeType(), Array.SetValue() does *not* permit conversion from a primitive to an Enum. if (value != null && !(value.EETypePtr == pElementEEType) && pElementEEType.IsEnum) throw new InvalidCastException(SR.Format(SR.Arg_ObjObjEx, value.GetType(), Type.GetTypeFromHandle(new RuntimeTypeHandle(pElementEEType)))); value = InvokeUtils.CheckArgument(value, pElementEEType, InvokeUtils.CheckArgumentSemantics.ArraySet, binderBundle: null); Debug.Assert(value == null || RuntimeImports.AreTypesAssignable(value.EETypePtr, pElementEEType)); RuntimeImports.RhUnbox(value, ref element, pElementEEType); } else if (pElementEEType.IsPointer) { throw new NotSupportedException(SR.NotSupported_Type); } else { try { RuntimeImports.RhCheckArrayStore(this, value); } catch (ArrayTypeMismatchException) { throw new InvalidCastException(SR.InvalidCast_StoreArrayElement); } Unsafe.As<byte, object?>(ref element) = value; } } internal EETypePtr ElementEEType { get { return this.EETypePtr.ArrayElementType; } } internal CorElementType GetCorElementTypeOfElementType() { return ElementEEType.CorElementType; } internal bool IsValueOfElementType(object o) { return ElementEEType.Equals(o.EETypePtr); } // // Return storage size of an individual element in bytes. // internal nuint ElementSize { get { return EETypePtr.ComponentSize; } } private static int IndexOfImpl<T>(T[] array, T value, int startIndex, int count) { // See comment in EqualityComparerHelpers.GetComparerForReferenceTypesOnly for details EqualityComparer<T> comparer = EqualityComparerHelpers.GetComparerForReferenceTypesOnly<T>(); int endIndex = startIndex + count; if (comparer != null) { for (int i = startIndex; i < endIndex; i++) { if (comparer.Equals(array[i], value)) return i; } } else { for (int i = startIndex; i < endIndex; i++) { if (EqualityComparerHelpers.StructOnlyEquals<T>(array[i], value)) return i; } } return -1; } private static int LastIndexOfImpl<T>(T[] array, T value, int startIndex, int count) { // See comment in EqualityComparerHelpers.GetComparerForReferenceTypesOnly for details EqualityComparer<T> comparer = EqualityComparerHelpers.GetComparerForReferenceTypesOnly<T>(); int endIndex = startIndex - count + 1; if (comparer != null) { for (int i = startIndex; i >= endIndex; i--) { if (comparer.Equals(array[i], value)) return i; } } else { for (int i = startIndex; i >= endIndex; i--) { if (EqualityComparerHelpers.StructOnlyEquals<T>(array[i], value)) return i; } } return -1; } } internal class ArrayEnumeratorBase : ICloneable { protected int _index; protected int _endIndex; internal ArrayEnumeratorBase() { _index = -1; } public bool MoveNext() { if (_index < _endIndex) { _index++; return (_index < _endIndex); } return false; } public void Dispose() { } public object Clone() { return MemberwiseClone(); } } // // Note: the declared base type and interface list also determines what Reflection returns from TypeInfo.BaseType and TypeInfo.ImplementedInterfaces for array types. // This also means the class must be declared "public" so that the framework can reflect on it. // public class Array<T> : Array, IEnumerable<T>, ICollection<T>, IList<T>, IReadOnlyList<T> { // Prevent the C# compiler from generating a public default constructor private Array() { } public new IEnumerator<T> GetEnumerator() { // get length so we don't have to call the Length property again in ArrayEnumerator constructor // and avoid more checking there too. int length = this.Length; return length == 0 ? ArrayEnumerator.Empty : new ArrayEnumerator(Unsafe.As<T[]>(this), length); } public int Count { get { return this.Length; } } // // Fun fact: // // ((int[])a).IsReadOnly returns false. // ((IList<int>)a).IsReadOnly returns true. // public new bool IsReadOnly { get { return true; } } public void Add(T item) { ThrowHelper.ThrowNotSupportedException(); } public void Clear() { ThrowHelper.ThrowNotSupportedException(); } public bool Contains(T item) { T[] array = Unsafe.As<T[]>(this); return Array.IndexOf(array, item, 0, array.Length) >= 0; } public void CopyTo(T[] array, int arrayIndex) { Array.Copy(Unsafe.As<T[]>(this), 0, array, arrayIndex, this.Length); } public bool Remove(T item) { ThrowHelper.ThrowNotSupportedException(); return false; // unreachable } public T this[int index] { get { try { return Unsafe.As<T[]>(this)[index]; } catch (IndexOutOfRangeException) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); return default; // unreachable } } set { try { Unsafe.As<T[]>(this)[index] = value; } catch (IndexOutOfRangeException) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } } } public int IndexOf(T item) { T[] array = Unsafe.As<T[]>(this); return Array.IndexOf(array, item, 0, array.Length); } public void Insert(int index, T item) { ThrowHelper.ThrowNotSupportedException(); } public void RemoveAt(int index) { ThrowHelper.ThrowNotSupportedException(); } private sealed class ArrayEnumerator : ArrayEnumeratorBase, IEnumerator<T> { private readonly T[] _array; // Passing -1 for endIndex so that MoveNext always returns false without mutating _index internal static readonly ArrayEnumerator Empty = new ArrayEnumerator(null, -1); internal ArrayEnumerator(T[] array, int endIndex) { _array = array; _endIndex = endIndex; } public T Current { get { if ((uint)_index >= (uint)_endIndex) ThrowHelper.ThrowInvalidOperationException(); return _array[_index]; } } object IEnumerator.Current { get { return Current; } } void IEnumerator.Reset() { _index = -1; } } } public class MDArray { public const int MinRank = 1; public const int MaxRank = 32; } }
1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/libraries/System.Private.CoreLib/src/System/Array.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; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public abstract partial class Array : ICloneable, IList, IStructuralComparable, IStructuralEquatable { // This is the threshold where Introspective sort switches to Insertion sort. // Empirically, 16 seems to speed up most cases without slowing down others, at least for integers. // Large value types may benefit from a smaller number. internal const int IntrosortSizeThreshold = 16; // This ctor exists solely to prevent C# from generating a protected .ctor that violates the surface area. private protected Array() { } public static ReadOnlyCollection<T> AsReadOnly<T>(T[] array) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } // T[] implements IList<T>. return new ReadOnlyCollection<T>(array); } public static void Resize<T>([NotNull] ref T[]? array, int newSize) { if (newSize < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.newSize, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); T[]? larray = array; // local copy if (larray == null) { array = new T[newSize]; return; } if (larray.Length != newSize) { // Due to array variance, it's possible that the incoming array is // actually of type U[], where U:T; or that an int[] <-> uint[] or // similar cast has occurred. In any case, since it's always legal // to reinterpret U as T in this scenario (but not necessarily the // other way around), we can use Buffer.Memmove here. T[] newArray = new T[newSize]; Buffer.Memmove<T>( ref MemoryMarshal.GetArrayDataReference(newArray), ref MemoryMarshal.GetArrayDataReference(larray), (uint)Math.Min(newSize, larray.Length)); array = newArray; } Debug.Assert(array != null); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static Array CreateInstance(Type elementType, params long[] lengths) { if (lengths == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths); } if (lengths.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank); int[] intLengths = new int[lengths.Length]; for (int i = 0; i < lengths.Length; ++i) { long len = lengths[i]; int ilen = (int)len; if (len != ilen) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.len, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intLengths[i] = ilen; } return Array.CreateInstance(elementType, intLengths); } public static void Copy(Array sourceArray, Array destinationArray, long length) { int ilength = (int)length; if (length != ilength) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); Copy(sourceArray, destinationArray, ilength); } public static void Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length) { int isourceIndex = (int)sourceIndex; int idestinationIndex = (int)destinationIndex; int ilength = (int)length; if (sourceIndex != isourceIndex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.sourceIndex, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (destinationIndex != idestinationIndex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.destinationIndex, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (length != ilength) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); Copy(sourceArray, isourceIndex, destinationArray, idestinationIndex, ilength); } // The various Get values... public object? GetValue(params int[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); if (Rank != indices.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices); return InternalGetValue(GetFlattenedIndex(new ReadOnlySpan<int>(indices))); } public unsafe object? GetValue(int index) { if (Rank != 1) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray); return InternalGetValue(GetFlattenedIndex(new ReadOnlySpan<int>(&index, 1))); } public object? GetValue(int index1, int index2) { if (Rank != 2) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need2DArray); return InternalGetValue(GetFlattenedIndex(stackalloc int[] { index1, index2 })); } public object? GetValue(int index1, int index2, int index3) { if (Rank != 3) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need3DArray); return InternalGetValue(GetFlattenedIndex(stackalloc int[] { index1, index2, index3 })); } public unsafe void SetValue(object? value, int index) { if (Rank != 1) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray); InternalSetValue(value, GetFlattenedIndex(new ReadOnlySpan<int>(&index, 1))); } public void SetValue(object? value, int index1, int index2) { if (Rank != 2) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need2DArray); InternalSetValue(value, GetFlattenedIndex(stackalloc int[] { index1, index2 })); } public void SetValue(object? value, int index1, int index2, int index3) { if (Rank != 3) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need3DArray); InternalSetValue(value, GetFlattenedIndex(stackalloc int[] { index1, index2, index3 })); } public void SetValue(object? value, params int[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); if (Rank != indices.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices); InternalSetValue(value, GetFlattenedIndex(new ReadOnlySpan<int>(indices))); } public object? GetValue(long index) { int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue(iindex); } public object? GetValue(long index1, long index2) { int iindex1 = (int)index1; int iindex2 = (int)index2; if (index1 != iindex1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index2 != iindex2) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue(iindex1, iindex2); } public object? GetValue(long index1, long index2, long index3) { int iindex1 = (int)index1; int iindex2 = (int)index2; int iindex3 = (int)index3; if (index1 != iindex1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index2 != iindex2) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index3 != iindex3) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue(iindex1, iindex2, iindex3); } public object? GetValue(params long[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); if (Rank != indices.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices); int[] intIndices = new int[indices.Length]; for (int i = 0; i < indices.Length; ++i) { long index = indices[i]; int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intIndices[i] = iindex; } return this.GetValue(intIndices); } public void SetValue(object? value, long index) { int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, iindex); } public void SetValue(object? value, long index1, long index2) { int iindex1 = (int)index1; int iindex2 = (int)index2; if (index1 != iindex1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index2 != iindex2) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, iindex1, iindex2); } public void SetValue(object? value, long index1, long index2, long index3) { int iindex1 = (int)index1; int iindex2 = (int)index2; int iindex3 = (int)index3; if (index1 != iindex1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index2 != iindex2) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index3 != iindex3) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, iindex1, iindex2, iindex3); } public void SetValue(object? value, params long[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); if (Rank != indices.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices); int[] intIndices = new int[indices.Length]; for (int i = 0; i < indices.Length; ++i) { long index = indices[i]; int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intIndices[i] = iindex; } this.SetValue(value, intIndices); } private static int GetMedian(int low, int hi) { // Note both may be negative, if we are dealing with arrays w/ negative lower bounds. Debug.Assert(low <= hi); Debug.Assert(hi - low >= 0, "Length overflow!"); return low + ((hi - low) >> 1); } public long GetLongLength(int dimension) { // This method should throw an IndexOufOfRangeException for compat if dimension < 0 or >= Rank return GetLength(dimension); } // Number of elements in the Array. int ICollection.Count => Length; // Returns an object appropriate for synchronizing access to this // Array. public object SyncRoot => this; // Is this Array read-only? public bool IsReadOnly => false; public bool IsFixedSize => true; // Is this Array synchronized (i.e., thread-safe)? If you want a synchronized // collection, you can use SyncRoot as an object to synchronize your // collection with. You could also call GetSynchronized() // to get a synchronized wrapper around the Array. public bool IsSynchronized => false; object? IList.this[int index] { get => GetValue(index); set => SetValue(value, index); } int IList.Add(object? value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; } bool IList.Contains(object? value) { return Array.IndexOf(this, value) >= this.GetLowerBound(0); } void IList.Clear() { Array.Clear(this); } int IList.IndexOf(object? value) { return Array.IndexOf(this, value); } void IList.Insert(int index, object? value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } void IList.Remove(object? value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } void IList.RemoveAt(int index) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } // Make a new array which is a shallow copy of the original array. // [Intrinsic] public object Clone() { return MemberwiseClone(); } int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other == null) { return 1; } Array? o = other as Array; if (o == null || this.Length != o.Length) { ThrowHelper.ThrowArgumentException(ExceptionResource.ArgumentException_OtherNotArrayOfCorrectLength, ExceptionArgument.other); } int i = 0; int c = 0; while (i < o.Length && c == 0) { object? left = GetValue(i); object? right = o.GetValue(i); c = comparer.Compare(left, right); i++; } return c; } bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) { if (other == null) { return false; } if (object.ReferenceEquals(this, other)) { return true; } if (!(other is Array o) || o.Length != this.Length) { return false; } int i = 0; while (i < o.Length) { object? left = GetValue(i); object? right = o.GetValue(i); if (!comparer.Equals(left, right)) { return false; } i++; } return true; } int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { if (comparer == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparer); HashCode hashCode = default; for (int i = (this.Length >= 8 ? this.Length - 8 : 0); i < this.Length; i++) { hashCode.Add(comparer.GetHashCode(GetValue(i)!)); } return hashCode.ToHashCode(); } // Searches an array for a given element using a binary search algorithm. // Elements of the array are compared to the search value using the // IComparable interface, which must be implemented by all elements // of the array and the given search value. This method assumes that the // array is already sorted according to the IComparable interface; // if this is not the case, the result will be incorrect. // // The method returns the index of the given value in the array. If the // array does not contain the given value, the method returns a negative // integer. The bitwise complement operator (~) can be applied to a // negative result to produce the index of the first element (if any) that // is larger than the given search value. // public static int BinarySearch(Array array, object? value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return BinarySearch(array, array.GetLowerBound(0), array.Length, value, null); } // Searches a section of an array for a given element using a binary search // algorithm. Elements of the array are compared to the search value using // the IComparable interface, which must be implemented by all // elements of the array and the given search value. This method assumes // that the array is already sorted according to the IComparable // interface; if this is not the case, the result will be incorrect. // // The method returns the index of the given value in the array. If the // array does not contain the given value, the method returns a negative // integer. The bitwise complement operator (~) can be applied to a // negative result to produce the index of the first element (if any) that // is larger than the given search value. // public static int BinarySearch(Array array, int index, int length, object? value) { return BinarySearch(array, index, length, value, null); } // Searches an array for a given element using a binary search algorithm. // Elements of the array are compared to the search value using the given // IComparer interface. If comparer is null, elements of the // array are compared to the search value using the IComparable // interface, which in that case must be implemented by all elements of the // array and the given search value. This method assumes that the array is // already sorted; if this is not the case, the result will be incorrect. // // The method returns the index of the given value in the array. If the // array does not contain the given value, the method returns a negative // integer. The bitwise complement operator (~) can be applied to a // negative result to produce the index of the first element (if any) that // is larger than the given search value. // public static int BinarySearch(Array array, object? value, IComparer? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return BinarySearch(array, array.GetLowerBound(0), array.Length, value, comparer); } // Searches a section of an array for a given element using a binary search // algorithm. Elements of the array are compared to the search value using // the given IComparer interface. If comparer is null, // elements of the array are compared to the search value using the // IComparable interface, which in that case must be implemented by // all elements of the array and the given search value. This method // assumes that the array is already sorted; if this is not the case, the // result will be incorrect. // // The method returns the index of the given value in the array. If the // array does not contain the given value, the method returns a negative // integer. The bitwise complement operator (~) can be applied to a // negative result to produce the index of the first element (if any) that // is larger than the given search value. // public static int BinarySearch(Array array, int index, int length, object? value, IComparer? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); if (index < lb) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - (index - lb) < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (array.Rank != 1) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); comparer ??= Comparer.Default; int lo = index; int hi = index + length - 1; if (array is object[] objArray) { while (lo <= hi) { // i might overflow if lo and hi are both large positive numbers. int i = GetMedian(lo, hi); int c; try { c = comparer.Compare(objArray[i], value); } catch (Exception e) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e); return default; } if (c == 0) return i; if (c < 0) { lo = i + 1; } else { hi = i - 1; } } return ~lo; } if (comparer == Comparer.Default) { CorElementType et = array.GetCorElementTypeOfElementType(); if (et.IsPrimitiveType()) { if (value == null) return ~index; if (array.IsValueOfElementType(value)) { int adjustedIndex = index - lb; int result = -1; switch (et) { case CorElementType.ELEMENT_TYPE_I1: result = GenericBinarySearch<sbyte>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: result = GenericBinarySearch<byte>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_I2: result = GenericBinarySearch<short>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: result = GenericBinarySearch<ushort>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_I4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: #endif result = GenericBinarySearch<int>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_U: #endif result = GenericBinarySearch<uint>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_I8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: #endif result = GenericBinarySearch<long>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_U: #endif result = GenericBinarySearch<ulong>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_R4: result = GenericBinarySearch<float>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_R8: result = GenericBinarySearch<double>(array, adjustedIndex, length, value); break; default: Debug.Fail("All primitive types should be handled above"); break; } return (result >= 0) ? (index + result) : ~(index + ~result); static int GenericBinarySearch<T>(Array array, int adjustedIndex, int length, object value) where T: struct, IComparable<T> => UnsafeArrayAsSpan<T>(array, adjustedIndex, length).BinarySearch(Unsafe.As<byte, T>(ref value.GetRawData())); } } } while (lo <= hi) { int i = GetMedian(lo, hi); int c; try { c = comparer.Compare(array.GetValue(i), value); } catch (Exception e) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e); return default; } if (c == 0) return i; if (c < 0) { lo = i + 1; } else { hi = i - 1; } } return ~lo; } public static int BinarySearch<T>(T[] array, T value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return BinarySearch<T>(array, 0, array.Length, value, null); } public static int BinarySearch<T>(T[] array, T value, System.Collections.Generic.IComparer<T>? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return BinarySearch<T>(array, 0, array.Length, value, comparer); } public static int BinarySearch<T>(T[] array, int index, int length, T value) { return BinarySearch<T>(array, index, length, value, null); } public static int BinarySearch<T>(T[] array, int index, int length, T value, System.Collections.Generic.IComparer<T>? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - index < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); return ArraySortHelper<T>.Default.BinarySearch(array, index, length, value, comparer); } public static TOutput[] ConvertAll<TInput, TOutput>(TInput[] array, Converter<TInput, TOutput> converter) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (converter == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.converter); } TOutput[] newArray = new TOutput[array.Length]; for (int i = 0; i < array.Length; i++) { newArray[i] = converter(array[i]); } return newArray; } // CopyTo copies a collection into an Array, starting at a particular // index into the array. // // This method is to support the ICollection interface, and calls // Array.Copy internally. If you aren't using ICollection explicitly, // call Array.Copy to avoid an extra indirection. // public void CopyTo(Array array, int index) { if (array != null && array.Rank != 1) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported); // Note: Array.Copy throws a RankException and we want a consistent ArgumentException for all the IList CopyTo methods. Array.Copy(this, GetLowerBound(0), array!, index, Length); } public void CopyTo(Array array, long index) { int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.CopyTo(array, iindex); } private static class EmptyArray<T> { #pragma warning disable CA1825 // this is the implementation of Array.Empty<T>() internal static readonly T[] Value = new T[0]; #pragma warning restore CA1825 } public static T[] Empty<T>() { return EmptyArray<T>.Value; } public static bool Exists<T>(T[] array, Predicate<T> match) { return Array.FindIndex(array, match) != -1; } public static void Fill<T>(T[] array, T value) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (!typeof(T).IsValueType && array.GetType() != typeof(T[])) { for (int i = 0; i < array.Length; i++) { array[i] = value; } } else { new Span<T>(array).Fill(value); } } public static void Fill<T>(T[] array, T value, int startIndex, int count) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if ((uint)startIndex > (uint)array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } if ((uint)count > (uint)(array.Length - startIndex)) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } if (!typeof(T).IsValueType && array.GetType() != typeof(T[])) { for (int i = startIndex; i < startIndex + count; i++) { array[i] = value; } } else { ref T first = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)startIndex); new Span<T>(ref first, count).Fill(value); } } public static T? Find<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } for (int i = 0; i < array.Length; i++) { if (match(array[i])) { return array[i]; } } return default; } public static T[] FindAll<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } List<T> list = new List<T>(); for (int i = 0; i < array.Length; i++) { if (match(array[i])) { list.Add(array[i]); } } return list.ToArray(); } public static int FindIndex<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return FindIndex(array, 0, array.Length, match); } public static int FindIndex<T>(T[] array, int startIndex, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return FindIndex(array, startIndex, array.Length - startIndex, match); } public static int FindIndex<T>(T[] array, int startIndex, int count, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (startIndex < 0 || startIndex > array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } if (count < 0 || startIndex > array.Length - count) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } int endIndex = startIndex + count; for (int i = startIndex; i < endIndex; i++) { if (match(array[i])) return i; } return -1; } public static T? FindLast<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } for (int i = array.Length - 1; i >= 0; i--) { if (match(array[i])) { return array[i]; } } return default; } public static int FindLastIndex<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return FindLastIndex(array, array.Length - 1, array.Length, match); } public static int FindLastIndex<T>(T[] array, int startIndex, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return FindLastIndex(array, startIndex, startIndex + 1, match); } public static int FindLastIndex<T>(T[] array, int startIndex, int count, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } if (array.Length == 0) { // Special case for 0 length List if (startIndex != -1) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } } else { // Make sure we're not out of range if (startIndex < 0 || startIndex >= array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } } // 2nd have of this also catches when startIndex == MAXINT, so MAXINT - 0 + 1 == -1, which is < 0. if (count < 0 || startIndex - count + 1 < 0) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } int endIndex = startIndex - count; for (int i = startIndex; i > endIndex; i--) { if (match(array[i])) { return i; } } return -1; } public static void ForEach<T>(T[] array, Action<T> action) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (action == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action); } for (int i = 0; i < array.Length; i++) { action(array[i]); } } // Returns the index of the first occurrence of a given value in an array. // The array is searched forwards, and the elements of the array are // compared to the given value using the Object.Equals method. // public static int IndexOf(Array array, object? value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return IndexOf(array, value, array.GetLowerBound(0), array.Length); } // Returns the index of the first occurrence of a given value in a range of // an array. The array is searched forwards, starting at index // startIndex and ending at the last element of the array. The // elements of the array are compared to the given value using the // Object.Equals method. // public static int IndexOf(Array array, object? value, int startIndex) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); return IndexOf(array, value, startIndex, array.Length - startIndex + lb); } // Returns the index of the first occurrence of a given value in a range of // an array. The array is searched forwards, starting at index // startIndex and upto count elements. The // elements of the array are compared to the given value using the // Object.Equals method. // public static int IndexOf(Array array, object? value, int startIndex, int count) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (array.Rank != 1) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); int lb = array.GetLowerBound(0); if (startIndex < lb || startIndex > array.Length + lb) ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); if (count < 0 || count > array.Length - startIndex + lb) ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); int endIndex = startIndex + count; if (array is object[] objArray) { if (value == null) { for (int i = startIndex; i < endIndex; i++) { if (objArray[i] == null) return i; } } else { for (int i = startIndex; i < endIndex; i++) { object obj = objArray[i]; if (obj != null && obj.Equals(value)) return i; } } return -1; } CorElementType et = array.GetCorElementTypeOfElementType(); if (et.IsPrimitiveType()) { if (value == null) return lb - 1; if (array.IsValueOfElementType(value)) { int adjustedIndex = startIndex - lb; int result = -1; switch (et) { case CorElementType.ELEMENT_TYPE_I1: case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: result = GenericIndexOf<byte>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I2: case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: result = GenericIndexOf<char>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I4: case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif result = GenericIndexOf<int>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I8: case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif result = GenericIndexOf<long>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_R4: result = GenericIndexOf<float>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_R8: result = GenericIndexOf<double>(array, value, adjustedIndex, count); break; default: Debug.Fail("All primitive types should be handled above"); break; } return (result >= 0 ? startIndex : lb) + result; static int GenericIndexOf<T>(Array array, object value, int adjustedIndex, int length) where T : struct, IEquatable<T> => UnsafeArrayAsSpan<T>(array, adjustedIndex, length).IndexOf(Unsafe.As<byte, T>(ref value.GetRawData())); } } for (int i = startIndex; i < endIndex; i++) { object? obj = array.GetValue(i); if (obj == null) { if (value == null) return i; } else { if (obj.Equals(value)) return i; } } // Return one less than the lower bound of the array. This way, // for arrays with a lower bound of -1 we will not return -1 when the // item was not found. And for SZArrays (the vast majority), -1 still // works for them. return lb - 1; } public static int IndexOf<T>(T[] array, T value) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return IndexOf(array, value, 0, array.Length); } public static int IndexOf<T>(T[] array, T value, int startIndex) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return IndexOf(array, value, startIndex, array.Length - startIndex); } public static int IndexOf<T>(T[] array, T value, int startIndex, int count) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if ((uint)startIndex > (uint)array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } if ((uint)count > (uint)(array.Length - startIndex)) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } if (RuntimeHelpers.IsBitwiseEquatable<T>()) { if (Unsafe.SizeOf<T>() == sizeof(byte)) { int result = SpanHelpers.IndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<byte[]>(array)), startIndex), Unsafe.As<T, byte>(ref value), count); return (result >= 0 ? startIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(char)) { int result = SpanHelpers.IndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<char[]>(array)), startIndex), Unsafe.As<T, char>(ref value), count); return (result >= 0 ? startIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(int)) { int result = typeof(T).IsValueType ? SpanHelpers.IndexOfValueType( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<int[]>(array)), startIndex), Unsafe.As<T, int>(ref value), count) : SpanHelpers.IndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<int[]>(array)), startIndex), Unsafe.As<T, int>(ref value), count); return (result >= 0 ? startIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(long)) { int result = typeof(T).IsValueType ? SpanHelpers.IndexOfValueType( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<long[]>(array)), startIndex), Unsafe.As<T, long>(ref value), count) : SpanHelpers.IndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<long[]>(array)), startIndex), Unsafe.As<T, long>(ref value), count); return (result >= 0 ? startIndex : 0) + result; } } #if !CORERT return EqualityComparer<T>.Default.IndexOf(array, value, startIndex, count); #else return IndexOfImpl(array, value, startIndex, count); #endif } // Returns the index of the last occurrence of a given value in an array. // The array is searched backwards, and the elements of the array are // compared to the given value using the Object.Equals method. // public static int LastIndexOf(Array array, object? value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); return LastIndexOf(array, value, array.Length - 1 + lb, array.Length); } // Returns the index of the last occurrence of a given value in a range of // an array. The array is searched backwards, starting at index // startIndex and ending at index 0. The elements of the array are // compared to the given value using the Object.Equals method. // public static int LastIndexOf(Array array, object? value, int startIndex) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); return LastIndexOf(array, value, startIndex, startIndex + 1 - lb); } // Returns the index of the last occurrence of a given value in a range of // an array. The array is searched backwards, starting at index // startIndex and counting uptocount elements. The elements of // the array are compared to the given value using the Object.Equals // method. // public static int LastIndexOf(Array array, object? value, int startIndex, int count) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); if (array.Length == 0) { return lb - 1; } if (startIndex < lb || startIndex >= array.Length + lb) ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); if (count < 0) ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); if (count > startIndex - lb + 1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.endIndex, ExceptionResource.ArgumentOutOfRange_EndIndexStartIndex); if (array.Rank != 1) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); int endIndex = startIndex - count + 1; if (array is object[] objArray) { if (value == null) { for (int i = startIndex; i >= endIndex; i--) { if (objArray[i] == null) return i; } } else { for (int i = startIndex; i >= endIndex; i--) { object obj = objArray[i]; if (obj != null && obj.Equals(value)) return i; } } return -1; } CorElementType et = array.GetCorElementTypeOfElementType(); if (et.IsPrimitiveType()) { if (value == null) return lb - 1; if (array.IsValueOfElementType(value)) { int adjustedIndex = endIndex - lb; int result = -1; switch (et) { case CorElementType.ELEMENT_TYPE_I1: case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: result = GenericLastIndexOf<byte>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I2: case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: result = GenericLastIndexOf<char>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I4: case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif result = GenericLastIndexOf<int>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I8: case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif result = GenericLastIndexOf<long>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_R4: result = GenericLastIndexOf<float>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_R8: result = GenericLastIndexOf<double>(array, value, adjustedIndex, count); break; default: Debug.Fail("All primitive types should be handled above"); break; } return (result >= 0 ? endIndex : lb) + result; static int GenericLastIndexOf<T>(Array array, object value, int adjustedIndex, int length) where T : struct, IEquatable<T> => UnsafeArrayAsSpan<T>(array, adjustedIndex, length).LastIndexOf(Unsafe.As<byte, T>(ref value.GetRawData())); } } for (int i = startIndex; i >= endIndex; i--) { object? obj = array.GetValue(i); if (obj == null) { if (value == null) return i; } else { if (obj.Equals(value)) return i; } } return lb - 1; // Return lb-1 for arrays with negative lower bounds. } public static int LastIndexOf<T>(T[] array, T value) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return LastIndexOf(array, value, array.Length - 1, array.Length); } public static int LastIndexOf<T>(T[] array, T value, int startIndex) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } // if array is empty and startIndex is 0, we need to pass 0 as count return LastIndexOf(array, value, startIndex, (array.Length == 0) ? 0 : (startIndex + 1)); } public static int LastIndexOf<T>(T[] array, T value, int startIndex, int count) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (array.Length == 0) { // // Special case for 0 length List // accept -1 and 0 as valid startIndex for compablility reason. // if (startIndex != -1 && startIndex != 0) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } // only 0 is a valid value for count if array is empty if (count != 0) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } return -1; } // Make sure we're not out of range if ((uint)startIndex >= (uint)array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } // 2nd have of this also catches when startIndex == MAXINT, so MAXINT - 0 + 1 == -1, which is < 0. if (count < 0 || startIndex - count + 1 < 0) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } if (RuntimeHelpers.IsBitwiseEquatable<T>()) { if (Unsafe.SizeOf<T>() == sizeof(byte)) { int endIndex = startIndex - count + 1; int result = SpanHelpers.LastIndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<byte[]>(array)), endIndex), Unsafe.As<T, byte>(ref value), count); return (result >= 0 ? endIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(char)) { int endIndex = startIndex - count + 1; int result = SpanHelpers.LastIndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<char[]>(array)), endIndex), Unsafe.As<T, char>(ref value), count); return (result >= 0 ? endIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(int)) { int endIndex = startIndex - count + 1; int result = SpanHelpers.LastIndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<int[]>(array)), endIndex), Unsafe.As<T, int>(ref value), count); return (result >= 0 ? endIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(long)) { int endIndex = startIndex - count + 1; int result = SpanHelpers.LastIndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<long[]>(array)), endIndex), Unsafe.As<T, long>(ref value), count); return (result >= 0 ? endIndex : 0) + result; } } #if !CORERT return EqualityComparer<T>.Default.LastIndexOf(array, value, startIndex, count); #else return LastIndexOfImpl(array, value, startIndex, count); #endif } // Reverses all elements of the given array. Following a call to this // method, an element previously located at index i will now be // located at index length - i - 1, where length is the // length of the array. // public static void Reverse(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Reverse(array, array.GetLowerBound(0), array.Length); } // Reverses the elements in a range of an array. Following a call to this // method, an element in the range given by index and count // which was previously located at index i will now be located at // index index + (index + count - i - 1). // Reliability note: This may fail because it may have to box objects. // public static void Reverse(Array array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lowerBound = array.GetLowerBound(0); if (index < lowerBound) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - (index - lowerBound) < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (array.Rank != 1) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); if (length <= 1) return; int adjustedIndex = index - lowerBound; switch (array.GetCorElementTypeOfElementType()) { case CorElementType.ELEMENT_TYPE_I1: case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: UnsafeArrayAsSpan<byte>(array, adjustedIndex, length).Reverse(); return; case CorElementType.ELEMENT_TYPE_I2: case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: UnsafeArrayAsSpan<short>(array, adjustedIndex, length).Reverse(); return; case CorElementType.ELEMENT_TYPE_I4: case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif case CorElementType.ELEMENT_TYPE_R4: UnsafeArrayAsSpan<int>(array, adjustedIndex, length).Reverse(); return; case CorElementType.ELEMENT_TYPE_I8: case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif case CorElementType.ELEMENT_TYPE_R8: UnsafeArrayAsSpan<long>(array, adjustedIndex, length).Reverse(); return; case CorElementType.ELEMENT_TYPE_OBJECT: case CorElementType.ELEMENT_TYPE_ARRAY: case CorElementType.ELEMENT_TYPE_SZARRAY: UnsafeArrayAsSpan<object>(array, adjustedIndex, length).Reverse(); return; } int i = index; int j = index + length - 1; while (i < j) { object? temp = array.GetValue(i); array.SetValue(array.GetValue(j), i); array.SetValue(temp, j); i++; j--; } } public static void Reverse<T>(T[] array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Reverse(array, 0, array.Length); } public static void Reverse<T>(T[] array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - index < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (length <= 1) return; ref T first = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index); ref T last = ref Unsafe.Add(ref Unsafe.Add(ref first, length), -1); do { T temp = first; first = last; last = temp; first = ref Unsafe.Add(ref first, 1); last = ref Unsafe.Add(ref last, -1); } while (Unsafe.IsAddressLessThan(ref first, ref last)); } // Sorts the elements of an array. The sort compares the elements to each // other using the IComparable interface, which must be implemented // by all elements of the array. // public static void Sort(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Sort(array, null, array.GetLowerBound(0), array.Length, null); } // Sorts the elements of two arrays based on the keys in the first array. // Elements in the keys array specify the sort keys for // corresponding elements in the items array. The sort compares the // keys to each other using the IComparable interface, which must be // implemented by all elements of the keys array. // public static void Sort(Array keys, Array? items) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); Sort(keys, items, keys.GetLowerBound(0), keys.Length, null); } // Sorts the elements in a section of an array. The sort compares the // elements to each other using the IComparable interface, which // must be implemented by all elements in the given section of the array. // public static void Sort(Array array, int index, int length) { Sort(array, null, index, length, null); } // Sorts the elements in a section of two arrays based on the keys in the // first array. Elements in the keys array specify the sort keys for // corresponding elements in the items array. The sort compares the // keys to each other using the IComparable interface, which must be // implemented by all elements of the keys array. // public static void Sort(Array keys, Array? items, int index, int length) { Sort(keys, items, index, length, null); } // Sorts the elements of an array. The sort compares the elements to each // other using the given IComparer interface. If comparer is // null, the elements are compared to each other using the // IComparable interface, which in that case must be implemented by // all elements of the array. // public static void Sort(Array array, IComparer? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Sort(array, null, array.GetLowerBound(0), array.Length, comparer); } // Sorts the elements of two arrays based on the keys in the first array. // Elements in the keys array specify the sort keys for // corresponding elements in the items array. The sort compares the // keys to each other using the given IComparer interface. If // comparer is null, the elements are compared to each other using // the IComparable interface, which in that case must be implemented // by all elements of the keys array. // public static void Sort(Array keys, Array? items, IComparer? comparer) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); Sort(keys, items, keys.GetLowerBound(0), keys.Length, comparer); } // Sorts the elements in a section of an array. The sort compares the // elements to each other using the given IComparer interface. If // comparer is null, the elements are compared to each other using // the IComparable interface, which in that case must be implemented // by all elements in the given section of the array. // public static void Sort(Array array, int index, int length, IComparer? comparer) { Sort(array, null, index, length, comparer); } // Sorts the elements in a section of two arrays based on the keys in the // first array. Elements in the keys array specify the sort keys for // corresponding elements in the items array. The sort compares the // keys to each other using the given IComparer interface. If // comparer is null, the elements are compared to each other using // the IComparable interface, which in that case must be implemented // by all elements of the given section of the keys array. // public static void Sort(Array keys, Array? items, int index, int length, IComparer? comparer) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); if (keys.Rank != 1 || (items != null && items.Rank != 1)) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); int keysLowerBound = keys.GetLowerBound(0); if (items != null && keysLowerBound != items.GetLowerBound(0)) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_LowerBoundsMustMatch); if (index < keysLowerBound) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (keys.Length - (index - keysLowerBound) < length || (items != null && (index - keysLowerBound) > items.Length - length)) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (length <= 1) return; comparer ??= Comparer.Default; if (keys is object[] objKeys) { object[]? objItems = items as object[]; if (items == null || objItems != null) { new SorterObjectArray(objKeys, objItems, comparer).Sort(index, length); return; } } if (comparer == Comparer.Default) { CorElementType et = keys.GetCorElementTypeOfElementType(); if (items == null || items.GetCorElementTypeOfElementType() == et) { int adjustedIndex = index - keysLowerBound; switch (et) { case CorElementType.ELEMENT_TYPE_I1: GenericSort<sbyte>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: GenericSort<byte>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_I2: GenericSort<short>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: GenericSort<ushort>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_I4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: #endif GenericSort<int>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_U: #endif GenericSort<uint>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_I8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: #endif GenericSort<long>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_U: #endif GenericSort<ulong>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_R4: GenericSort<float>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_R8: GenericSort<double>(keys, items, adjustedIndex, length); return; } static void GenericSort<T>(Array keys, Array? items, int adjustedIndex, int length) where T: struct { Span<T> keysSpan = UnsafeArrayAsSpan<T>(keys, adjustedIndex, length); if (items != null) { keysSpan.Sort<T, T>(UnsafeArrayAsSpan<T>(items, adjustedIndex, length)); } else { keysSpan.Sort<T>(); } } } } new SorterGenericArray(keys, items, comparer).Sort(index, length); } public static void Sort<T>(T[] array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (array.Length > 1) { var span = new Span<T>(ref MemoryMarshal.GetArrayDataReference(array), array.Length); ArraySortHelper<T>.Default.Sort(span, null); } } public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); Sort<TKey, TValue>(keys, items, 0, keys.Length, null); } public static void Sort<T>(T[] array, int index, int length) { Sort<T>(array, index, length, null); } public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, int index, int length) { Sort<TKey, TValue>(keys, items, index, length, null); } public static void Sort<T>(T[] array, System.Collections.Generic.IComparer<T>? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Sort<T>(array, 0, array.Length, comparer); } public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, System.Collections.Generic.IComparer<TKey>? comparer) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); Sort<TKey, TValue>(keys, items, 0, keys.Length, comparer); } public static void Sort<T>(T[] array, int index, int length, System.Collections.Generic.IComparer<T>? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - index < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (length > 1) { var span = new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index), length); ArraySortHelper<T>.Default.Sort(span, comparer); } } public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, int index, int length, System.Collections.Generic.IComparer<TKey>? comparer) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (keys.Length - index < length || (items != null && index > items.Length - length)) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (length > 1) { if (items == null) { Sort<TKey>(keys, index, length, comparer); return; } var spanKeys = new Span<TKey>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(keys), index), length); var spanItems = new Span<TValue>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(items), index), length); ArraySortHelper<TKey, TValue>.Default.Sort(spanKeys, spanItems, comparer); } } public static void Sort<T>(T[] array, Comparison<T> comparison) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (comparison == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparison); } var span = new Span<T>(ref MemoryMarshal.GetArrayDataReference(array), array.Length); ArraySortHelper<T>.Sort(span, comparison); } public static bool TrueForAll<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } for (int i = 0; i < array.Length; i++) { if (!match(array[i])) { return false; } } return true; } /// <summary>Gets the maximum number of elements that may be contained in an array.</summary> /// <returns>The maximum count of elements allowed in any array.</returns> /// <remarks> /// <para>This property represents a runtime limitation, the maximum number of elements (not bytes) /// the runtime will allow in an array. There is no guarantee that an allocation under this length /// will succeed, but all attempts to allocate a larger array will fail.</para> /// <para>This property only applies to single-dimension, zero-bound (SZ) arrays. /// <see cref="Length"/> property may return larger value than this property for multi-dimensional arrays.</para> /// </remarks> public static int MaxLength => // Keep in sync with `inline SIZE_T MaxArrayLength()` from gchelpers and HashHelpers.MaxPrimeArrayLength. 0X7FFFFFC7; // Private value type used by the Sort methods. private readonly struct SorterObjectArray { private readonly object[] keys; private readonly object?[]? items; private readonly IComparer comparer; internal SorterObjectArray(object[] keys, object?[]? items, IComparer comparer) { this.keys = keys; this.items = items; this.comparer = comparer; } internal void SwapIfGreater(int a, int b) { if (a != b) { if (comparer.Compare(keys[a], keys[b]) > 0) { object temp = keys[a]; keys[a] = keys[b]; keys[b] = temp; if (items != null) { object? item = items[a]; items[a] = items[b]; items[b] = item; } } } } private void Swap(int i, int j) { object t = keys[i]; keys[i] = keys[j]; keys[j] = t; if (items != null) { object? item = items[i]; items[i] = items[j]; items[j] = item; } } internal void Sort(int left, int length) { IntrospectiveSort(left, length); } private void IntrospectiveSort(int left, int length) { if (length < 2) return; try { IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1)); } catch (IndexOutOfRangeException) { ThrowHelper.ThrowArgumentException_BadComparer(comparer); } catch (Exception e) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e); } } private void IntroSort(int lo, int hi, int depthLimit) { Debug.Assert(hi >= lo); Debug.Assert(depthLimit >= 0); while (hi > lo) { int partitionSize = hi - lo + 1; if (partitionSize <= IntrosortSizeThreshold) { Debug.Assert(partitionSize >= 2); if (partitionSize == 2) { SwapIfGreater(lo, hi); return; } if (partitionSize == 3) { SwapIfGreater(lo, hi - 1); SwapIfGreater(lo, hi); SwapIfGreater(hi - 1, hi); return; } InsertionSort(lo, hi); return; } if (depthLimit == 0) { Heapsort(lo, hi); return; } depthLimit--; int p = PickPivotAndPartition(lo, hi); IntroSort(p + 1, hi, depthLimit); hi = p - 1; } } private int PickPivotAndPartition(int lo, int hi) { Debug.Assert(hi - lo >= IntrosortSizeThreshold); // Compute median-of-three. But also partition them, since we've done the comparison. int mid = lo + (hi - lo) / 2; // Sort lo, mid and hi appropriately, then pick mid as the pivot. SwapIfGreater(lo, mid); SwapIfGreater(lo, hi); SwapIfGreater(mid, hi); object pivot = keys[mid]; Swap(mid, hi - 1); int left = lo, right = hi - 1; // We already partitioned lo and hi and put the pivot in hi - 1. And we pre-increment & decrement below. while (left < right) { while (comparer.Compare(keys[++left], pivot) < 0) ; while (comparer.Compare(pivot, keys[--right]) < 0) ; if (left >= right) break; Swap(left, right); } // Put pivot in the right location. if (left != hi - 1) { Swap(left, hi - 1); } return left; } private void Heapsort(int lo, int hi) { int n = hi - lo + 1; for (int i = n / 2; i >= 1; i--) { DownHeap(i, n, lo); } for (int i = n; i > 1; i--) { Swap(lo, lo + i - 1); DownHeap(1, i - 1, lo); } } private void DownHeap(int i, int n, int lo) { object d = keys[lo + i - 1]; object? dt = items?[lo + i - 1]; int child; while (i <= n / 2) { child = 2 * i; if (child < n && comparer.Compare(keys[lo + child - 1], keys[lo + child]) < 0) { child++; } if (!(comparer.Compare(d, keys[lo + child - 1]) < 0)) break; keys[lo + i - 1] = keys[lo + child - 1]; if (items != null) items[lo + i - 1] = items[lo + child - 1]; i = child; } keys[lo + i - 1] = d; if (items != null) items[lo + i - 1] = dt; } private void InsertionSort(int lo, int hi) { int i, j; object t; object? ti; for (i = lo; i < hi; i++) { j = i; t = keys[i + 1]; ti = items?[i + 1]; while (j >= lo && comparer.Compare(t, keys[j]) < 0) { keys[j + 1] = keys[j]; if (items != null) items[j + 1] = items[j]; j--; } keys[j + 1] = t; if (items != null) items[j + 1] = ti; } } } // Private value used by the Sort methods for instances of Array. // This is slower than the one for Object[], since we can't use the JIT helpers // to access the elements. We must use GetValue & SetValue. private readonly struct SorterGenericArray { private readonly Array keys; private readonly Array? items; private readonly IComparer comparer; internal SorterGenericArray(Array keys, Array? items, IComparer comparer) { this.keys = keys; this.items = items; this.comparer = comparer; } internal void SwapIfGreater(int a, int b) { if (a != b) { if (comparer.Compare(keys.GetValue(a), keys.GetValue(b)) > 0) { object? key = keys.GetValue(a); keys.SetValue(keys.GetValue(b), a); keys.SetValue(key, b); if (items != null) { object? item = items.GetValue(a); items.SetValue(items.GetValue(b), a); items.SetValue(item, b); } } } } private void Swap(int i, int j) { object? t1 = keys.GetValue(i); keys.SetValue(keys.GetValue(j), i); keys.SetValue(t1, j); if (items != null) { object? t2 = items.GetValue(i); items.SetValue(items.GetValue(j), i); items.SetValue(t2, j); } } internal void Sort(int left, int length) { IntrospectiveSort(left, length); } private void IntrospectiveSort(int left, int length) { if (length < 2) return; try { IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1)); } catch (IndexOutOfRangeException) { ThrowHelper.ThrowArgumentException_BadComparer(comparer); } catch (Exception e) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e); } } private void IntroSort(int lo, int hi, int depthLimit) { Debug.Assert(hi >= lo); Debug.Assert(depthLimit >= 0); while (hi > lo) { int partitionSize = hi - lo + 1; if (partitionSize <= IntrosortSizeThreshold) { Debug.Assert(partitionSize >= 2); if (partitionSize == 2) { SwapIfGreater(lo, hi); return; } if (partitionSize == 3) { SwapIfGreater(lo, hi - 1); SwapIfGreater(lo, hi); SwapIfGreater(hi - 1, hi); return; } InsertionSort(lo, hi); return; } if (depthLimit == 0) { Heapsort(lo, hi); return; } depthLimit--; int p = PickPivotAndPartition(lo, hi); IntroSort(p + 1, hi, depthLimit); hi = p - 1; } } private int PickPivotAndPartition(int lo, int hi) { Debug.Assert(hi - lo >= IntrosortSizeThreshold); // Compute median-of-three. But also partition them, since we've done the comparison. int mid = lo + (hi - lo) / 2; SwapIfGreater(lo, mid); SwapIfGreater(lo, hi); SwapIfGreater(mid, hi); object? pivot = keys.GetValue(mid); Swap(mid, hi - 1); int left = lo, right = hi - 1; // We already partitioned lo and hi and put the pivot in hi - 1. And we pre-increment & decrement below. while (left < right) { while (comparer.Compare(keys.GetValue(++left), pivot) < 0) ; while (comparer.Compare(pivot, keys.GetValue(--right)) < 0) ; if (left >= right) break; Swap(left, right); } // Put pivot in the right location. if (left != hi - 1) { Swap(left, hi - 1); } return left; } private void Heapsort(int lo, int hi) { int n = hi - lo + 1; for (int i = n / 2; i >= 1; i--) { DownHeap(i, n, lo); } for (int i = n; i > 1; i--) { Swap(lo, lo + i - 1); DownHeap(1, i - 1, lo); } } private void DownHeap(int i, int n, int lo) { object? d = keys.GetValue(lo + i - 1); object? dt = items?.GetValue(lo + i - 1); int child; while (i <= n / 2) { child = 2 * i; if (child < n && comparer.Compare(keys.GetValue(lo + child - 1), keys.GetValue(lo + child)) < 0) { child++; } if (!(comparer.Compare(d, keys.GetValue(lo + child - 1)) < 0)) break; keys.SetValue(keys.GetValue(lo + child - 1), lo + i - 1); if (items != null) items.SetValue(items.GetValue(lo + child - 1), lo + i - 1); i = child; } keys.SetValue(d, lo + i - 1); if (items != null) items.SetValue(dt, lo + i - 1); } private void InsertionSort(int lo, int hi) { int i, j; object? t; object? dt; for (i = lo; i < hi; i++) { j = i; t = keys.GetValue(i + 1); dt = items?.GetValue(i + 1); while (j >= lo && comparer.Compare(t, keys.GetValue(j)) < 0) { keys.SetValue(keys.GetValue(j), j + 1); if (items != null) items.SetValue(items.GetValue(j), j + 1); j--; } keys.SetValue(t, j + 1); if (items != null) items.SetValue(dt, j + 1); } } } private static Span<T> UnsafeArrayAsSpan<T>(Array array, int adjustedIndex, int length) => new Span<T>(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), array.Length).Slice(adjustedIndex, length); public IEnumerator GetEnumerator() { return new ArrayEnumerator(this); } } }
// 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; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public abstract partial class Array : ICloneable, IList, IStructuralComparable, IStructuralEquatable { // This is the threshold where Introspective sort switches to Insertion sort. // Empirically, 16 seems to speed up most cases without slowing down others, at least for integers. // Large value types may benefit from a smaller number. internal const int IntrosortSizeThreshold = 16; // This ctor exists solely to prevent C# from generating a protected .ctor that violates the surface area. private protected Array() { } public static ReadOnlyCollection<T> AsReadOnly<T>(T[] array) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } // T[] implements IList<T>. return new ReadOnlyCollection<T>(array); } public static void Resize<T>([NotNull] ref T[]? array, int newSize) { if (newSize < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.newSize, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); T[]? larray = array; // local copy if (larray == null) { array = new T[newSize]; return; } if (larray.Length != newSize) { // Due to array variance, it's possible that the incoming array is // actually of type U[], where U:T; or that an int[] <-> uint[] or // similar cast has occurred. In any case, since it's always legal // to reinterpret U as T in this scenario (but not necessarily the // other way around), we can use Buffer.Memmove here. T[] newArray = new T[newSize]; Buffer.Memmove<T>( ref MemoryMarshal.GetArrayDataReference(newArray), ref MemoryMarshal.GetArrayDataReference(larray), (uint)Math.Min(newSize, larray.Length)); array = newArray; } Debug.Assert(array != null); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, int length) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); return InternalCreate(t, 1, &length, null); } [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "MDArrays of Rank != 1 can be created because they don't implement generic interfaces.")] public static unsafe Array CreateInstance(Type elementType, int length1, int length2) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length1 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length2 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); int* pLengths = stackalloc int[] { length1, length2 }; return InternalCreate(t, 2, pLengths, null); } [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", Justification = "MDArrays of Rank != 1 can be created because they don't implement generic interfaces.")] public static unsafe Array CreateInstance(Type elementType, int length1, int length2, int length3) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length1 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length2 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length3 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length3, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); int* pLengths = stackalloc int[3] { length1, length2, length3 }; return InternalCreate(t, 3, pLengths, null); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, params int[] lengths) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (lengths == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths); if (lengths.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); // Check to make sure the lengths are all non-negative. Note that we check this here to give // a good exception message if they are not; however we check this again inside the execution // engine's low level allocation function after having made a copy of the array to prevent a // malicious caller from mutating the array after this check. for (int i = 0; i < lengths.Length; i++) if (lengths[i] < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); fixed (int* pLengths = &lengths[0]) return InternalCreate(t, lengths.Length, pLengths, null); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, int[] lengths, int[] lowerBounds) { if (elementType == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (lengths == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths); if (lowerBounds == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lowerBounds); if (lengths.Length != lowerBounds.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RanksAndBounds); if (lengths.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank); RuntimeType? t = elementType.UnderlyingSystemType as RuntimeType; if (t == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); // Check to make sure the lengths are all non-negative. Note that we check this here to give // a good exception message if they are not; however we check this again inside the execution // engine's low level allocation function after having made a copy of the array to prevent a // malicious caller from mutating the array after this check. for (int i = 0; i < lengths.Length; i++) if (lengths[i] < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); fixed (int* pLengths = &lengths[0]) fixed (int* pLowerBounds = &lowerBounds[0]) return InternalCreate(t, lengths.Length, pLengths, pLowerBounds); } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static Array CreateInstance(Type elementType, params long[] lengths) { if (lengths == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths); } if (lengths.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank); int[] intLengths = new int[lengths.Length]; for (int i = 0; i < lengths.Length; ++i) { long len = lengths[i]; int ilen = (int)len; if (len != ilen) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.len, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intLengths[i] = ilen; } return Array.CreateInstance(elementType, intLengths); } public static void Copy(Array sourceArray, Array destinationArray, long length) { int ilength = (int)length; if (length != ilength) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); Copy(sourceArray, destinationArray, ilength); } public static void Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length) { int isourceIndex = (int)sourceIndex; int idestinationIndex = (int)destinationIndex; int ilength = (int)length; if (sourceIndex != isourceIndex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.sourceIndex, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (destinationIndex != idestinationIndex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.destinationIndex, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (length != ilength) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); Copy(sourceArray, isourceIndex, destinationArray, idestinationIndex, ilength); } // The various Get values... public object? GetValue(params int[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); if (Rank != indices.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices); return InternalGetValue(GetFlattenedIndex(new ReadOnlySpan<int>(indices))); } public unsafe object? GetValue(int index) { if (Rank != 1) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray); return InternalGetValue(GetFlattenedIndex(new ReadOnlySpan<int>(&index, 1))); } public object? GetValue(int index1, int index2) { if (Rank != 2) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need2DArray); return InternalGetValue(GetFlattenedIndex(stackalloc int[] { index1, index2 })); } public object? GetValue(int index1, int index2, int index3) { if (Rank != 3) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need3DArray); return InternalGetValue(GetFlattenedIndex(stackalloc int[] { index1, index2, index3 })); } public unsafe void SetValue(object? value, int index) { if (Rank != 1) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray); InternalSetValue(value, GetFlattenedIndex(new ReadOnlySpan<int>(&index, 1))); } public void SetValue(object? value, int index1, int index2) { if (Rank != 2) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need2DArray); InternalSetValue(value, GetFlattenedIndex(stackalloc int[] { index1, index2 })); } public void SetValue(object? value, int index1, int index2, int index3) { if (Rank != 3) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need3DArray); InternalSetValue(value, GetFlattenedIndex(stackalloc int[] { index1, index2, index3 })); } public void SetValue(object? value, params int[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); if (Rank != indices.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices); InternalSetValue(value, GetFlattenedIndex(new ReadOnlySpan<int>(indices))); } public object? GetValue(long index) { int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue(iindex); } public object? GetValue(long index1, long index2) { int iindex1 = (int)index1; int iindex2 = (int)index2; if (index1 != iindex1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index2 != iindex2) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue(iindex1, iindex2); } public object? GetValue(long index1, long index2, long index3) { int iindex1 = (int)index1; int iindex2 = (int)index2; int iindex3 = (int)index3; if (index1 != iindex1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index2 != iindex2) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index3 != iindex3) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue(iindex1, iindex2, iindex3); } public object? GetValue(params long[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); if (Rank != indices.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices); int[] intIndices = new int[indices.Length]; for (int i = 0; i < indices.Length; ++i) { long index = indices[i]; int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intIndices[i] = iindex; } return this.GetValue(intIndices); } public void SetValue(object? value, long index) { int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, iindex); } public void SetValue(object? value, long index1, long index2) { int iindex1 = (int)index1; int iindex2 = (int)index2; if (index1 != iindex1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index2 != iindex2) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, iindex1, iindex2); } public void SetValue(object? value, long index1, long index2, long index3) { int iindex1 = (int)index1; int iindex2 = (int)index2; int iindex3 = (int)index3; if (index1 != iindex1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index2 != iindex2) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); if (index3 != iindex3) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, iindex1, iindex2, iindex3); } public void SetValue(object? value, params long[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); if (Rank != indices.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankIndices); int[] intIndices = new int[indices.Length]; for (int i = 0; i < indices.Length; ++i) { long index = indices[i]; int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intIndices[i] = iindex; } this.SetValue(value, intIndices); } private static int GetMedian(int low, int hi) { // Note both may be negative, if we are dealing with arrays w/ negative lower bounds. Debug.Assert(low <= hi); Debug.Assert(hi - low >= 0, "Length overflow!"); return low + ((hi - low) >> 1); } public long GetLongLength(int dimension) { // This method should throw an IndexOufOfRangeException for compat if dimension < 0 or >= Rank return GetLength(dimension); } // Number of elements in the Array. int ICollection.Count => Length; // Returns an object appropriate for synchronizing access to this // Array. public object SyncRoot => this; // Is this Array read-only? public bool IsReadOnly => false; public bool IsFixedSize => true; // Is this Array synchronized (i.e., thread-safe)? If you want a synchronized // collection, you can use SyncRoot as an object to synchronize your // collection with. You could also call GetSynchronized() // to get a synchronized wrapper around the Array. public bool IsSynchronized => false; object? IList.this[int index] { get => GetValue(index); set => SetValue(value, index); } int IList.Add(object? value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; } bool IList.Contains(object? value) { return Array.IndexOf(this, value) >= this.GetLowerBound(0); } void IList.Clear() { Array.Clear(this); } int IList.IndexOf(object? value) { return Array.IndexOf(this, value); } void IList.Insert(int index, object? value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } void IList.Remove(object? value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } void IList.RemoveAt(int index) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } // Make a new array which is a shallow copy of the original array. // [Intrinsic] public object Clone() { return MemberwiseClone(); } int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other == null) { return 1; } Array? o = other as Array; if (o == null || this.Length != o.Length) { ThrowHelper.ThrowArgumentException(ExceptionResource.ArgumentException_OtherNotArrayOfCorrectLength, ExceptionArgument.other); } int i = 0; int c = 0; while (i < o.Length && c == 0) { object? left = GetValue(i); object? right = o.GetValue(i); c = comparer.Compare(left, right); i++; } return c; } bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) { if (other == null) { return false; } if (object.ReferenceEquals(this, other)) { return true; } if (!(other is Array o) || o.Length != this.Length) { return false; } int i = 0; while (i < o.Length) { object? left = GetValue(i); object? right = o.GetValue(i); if (!comparer.Equals(left, right)) { return false; } i++; } return true; } int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { if (comparer == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparer); HashCode hashCode = default; for (int i = (this.Length >= 8 ? this.Length - 8 : 0); i < this.Length; i++) { hashCode.Add(comparer.GetHashCode(GetValue(i)!)); } return hashCode.ToHashCode(); } // Searches an array for a given element using a binary search algorithm. // Elements of the array are compared to the search value using the // IComparable interface, which must be implemented by all elements // of the array and the given search value. This method assumes that the // array is already sorted according to the IComparable interface; // if this is not the case, the result will be incorrect. // // The method returns the index of the given value in the array. If the // array does not contain the given value, the method returns a negative // integer. The bitwise complement operator (~) can be applied to a // negative result to produce the index of the first element (if any) that // is larger than the given search value. // public static int BinarySearch(Array array, object? value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return BinarySearch(array, array.GetLowerBound(0), array.Length, value, null); } // Searches a section of an array for a given element using a binary search // algorithm. Elements of the array are compared to the search value using // the IComparable interface, which must be implemented by all // elements of the array and the given search value. This method assumes // that the array is already sorted according to the IComparable // interface; if this is not the case, the result will be incorrect. // // The method returns the index of the given value in the array. If the // array does not contain the given value, the method returns a negative // integer. The bitwise complement operator (~) can be applied to a // negative result to produce the index of the first element (if any) that // is larger than the given search value. // public static int BinarySearch(Array array, int index, int length, object? value) { return BinarySearch(array, index, length, value, null); } // Searches an array for a given element using a binary search algorithm. // Elements of the array are compared to the search value using the given // IComparer interface. If comparer is null, elements of the // array are compared to the search value using the IComparable // interface, which in that case must be implemented by all elements of the // array and the given search value. This method assumes that the array is // already sorted; if this is not the case, the result will be incorrect. // // The method returns the index of the given value in the array. If the // array does not contain the given value, the method returns a negative // integer. The bitwise complement operator (~) can be applied to a // negative result to produce the index of the first element (if any) that // is larger than the given search value. // public static int BinarySearch(Array array, object? value, IComparer? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return BinarySearch(array, array.GetLowerBound(0), array.Length, value, comparer); } // Searches a section of an array for a given element using a binary search // algorithm. Elements of the array are compared to the search value using // the given IComparer interface. If comparer is null, // elements of the array are compared to the search value using the // IComparable interface, which in that case must be implemented by // all elements of the array and the given search value. This method // assumes that the array is already sorted; if this is not the case, the // result will be incorrect. // // The method returns the index of the given value in the array. If the // array does not contain the given value, the method returns a negative // integer. The bitwise complement operator (~) can be applied to a // negative result to produce the index of the first element (if any) that // is larger than the given search value. // public static int BinarySearch(Array array, int index, int length, object? value, IComparer? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); if (index < lb) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - (index - lb) < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (array.Rank != 1) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); comparer ??= Comparer.Default; int lo = index; int hi = index + length - 1; if (array is object[] objArray) { while (lo <= hi) { // i might overflow if lo and hi are both large positive numbers. int i = GetMedian(lo, hi); int c; try { c = comparer.Compare(objArray[i], value); } catch (Exception e) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e); return default; } if (c == 0) return i; if (c < 0) { lo = i + 1; } else { hi = i - 1; } } return ~lo; } if (comparer == Comparer.Default) { CorElementType et = array.GetCorElementTypeOfElementType(); if (et.IsPrimitiveType()) { if (value == null) return ~index; if (array.IsValueOfElementType(value)) { int adjustedIndex = index - lb; int result = -1; switch (et) { case CorElementType.ELEMENT_TYPE_I1: result = GenericBinarySearch<sbyte>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: result = GenericBinarySearch<byte>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_I2: result = GenericBinarySearch<short>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: result = GenericBinarySearch<ushort>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_I4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: #endif result = GenericBinarySearch<int>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_U: #endif result = GenericBinarySearch<uint>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_I8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: #endif result = GenericBinarySearch<long>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_U: #endif result = GenericBinarySearch<ulong>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_R4: result = GenericBinarySearch<float>(array, adjustedIndex, length, value); break; case CorElementType.ELEMENT_TYPE_R8: result = GenericBinarySearch<double>(array, adjustedIndex, length, value); break; default: Debug.Fail("All primitive types should be handled above"); break; } return (result >= 0) ? (index + result) : ~(index + ~result); static int GenericBinarySearch<T>(Array array, int adjustedIndex, int length, object value) where T: struct, IComparable<T> => UnsafeArrayAsSpan<T>(array, adjustedIndex, length).BinarySearch(Unsafe.As<byte, T>(ref value.GetRawData())); } } } while (lo <= hi) { int i = GetMedian(lo, hi); int c; try { c = comparer.Compare(array.GetValue(i), value); } catch (Exception e) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e); return default; } if (c == 0) return i; if (c < 0) { lo = i + 1; } else { hi = i - 1; } } return ~lo; } public static int BinarySearch<T>(T[] array, T value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return BinarySearch<T>(array, 0, array.Length, value, null); } public static int BinarySearch<T>(T[] array, T value, System.Collections.Generic.IComparer<T>? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return BinarySearch<T>(array, 0, array.Length, value, comparer); } public static int BinarySearch<T>(T[] array, int index, int length, T value) { return BinarySearch<T>(array, index, length, value, null); } public static int BinarySearch<T>(T[] array, int index, int length, T value, System.Collections.Generic.IComparer<T>? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - index < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); return ArraySortHelper<T>.Default.BinarySearch(array, index, length, value, comparer); } public static TOutput[] ConvertAll<TInput, TOutput>(TInput[] array, Converter<TInput, TOutput> converter) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (converter == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.converter); } TOutput[] newArray = new TOutput[array.Length]; for (int i = 0; i < array.Length; i++) { newArray[i] = converter(array[i]); } return newArray; } // CopyTo copies a collection into an Array, starting at a particular // index into the array. // // This method is to support the ICollection interface, and calls // Array.Copy internally. If you aren't using ICollection explicitly, // call Array.Copy to avoid an extra indirection. // public void CopyTo(Array array, int index) { if (array != null && array.Rank != 1) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported); // Note: Array.Copy throws a RankException and we want a consistent ArgumentException for all the IList CopyTo methods. Array.Copy(this, GetLowerBound(0), array!, index, Length); } public void CopyTo(Array array, long index) { int iindex = (int)index; if (index != iindex) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.CopyTo(array, iindex); } private static class EmptyArray<T> { #pragma warning disable CA1825 // this is the implementation of Array.Empty<T>() internal static readonly T[] Value = new T[0]; #pragma warning restore CA1825 } public static T[] Empty<T>() { return EmptyArray<T>.Value; } public static bool Exists<T>(T[] array, Predicate<T> match) { return Array.FindIndex(array, match) != -1; } public static void Fill<T>(T[] array, T value) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (!typeof(T).IsValueType && array.GetType() != typeof(T[])) { for (int i = 0; i < array.Length; i++) { array[i] = value; } } else { new Span<T>(array).Fill(value); } } public static void Fill<T>(T[] array, T value, int startIndex, int count) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if ((uint)startIndex > (uint)array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } if ((uint)count > (uint)(array.Length - startIndex)) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } if (!typeof(T).IsValueType && array.GetType() != typeof(T[])) { for (int i = startIndex; i < startIndex + count; i++) { array[i] = value; } } else { ref T first = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), (nint)(uint)startIndex); new Span<T>(ref first, count).Fill(value); } } public static T? Find<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } for (int i = 0; i < array.Length; i++) { if (match(array[i])) { return array[i]; } } return default; } public static T[] FindAll<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } List<T> list = new List<T>(); for (int i = 0; i < array.Length; i++) { if (match(array[i])) { list.Add(array[i]); } } return list.ToArray(); } public static int FindIndex<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return FindIndex(array, 0, array.Length, match); } public static int FindIndex<T>(T[] array, int startIndex, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return FindIndex(array, startIndex, array.Length - startIndex, match); } public static int FindIndex<T>(T[] array, int startIndex, int count, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (startIndex < 0 || startIndex > array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } if (count < 0 || startIndex > array.Length - count) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } int endIndex = startIndex + count; for (int i = startIndex; i < endIndex; i++) { if (match(array[i])) return i; } return -1; } public static T? FindLast<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } for (int i = array.Length - 1; i >= 0; i--) { if (match(array[i])) { return array[i]; } } return default; } public static int FindLastIndex<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return FindLastIndex(array, array.Length - 1, array.Length, match); } public static int FindLastIndex<T>(T[] array, int startIndex, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return FindLastIndex(array, startIndex, startIndex + 1, match); } public static int FindLastIndex<T>(T[] array, int startIndex, int count, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } if (array.Length == 0) { // Special case for 0 length List if (startIndex != -1) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } } else { // Make sure we're not out of range if (startIndex < 0 || startIndex >= array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } } // 2nd have of this also catches when startIndex == MAXINT, so MAXINT - 0 + 1 == -1, which is < 0. if (count < 0 || startIndex - count + 1 < 0) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } int endIndex = startIndex - count; for (int i = startIndex; i > endIndex; i--) { if (match(array[i])) { return i; } } return -1; } public static void ForEach<T>(T[] array, Action<T> action) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (action == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.action); } for (int i = 0; i < array.Length; i++) { action(array[i]); } } // Returns the index of the first occurrence of a given value in an array. // The array is searched forwards, and the elements of the array are // compared to the given value using the Object.Equals method. // public static int IndexOf(Array array, object? value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); return IndexOf(array, value, array.GetLowerBound(0), array.Length); } // Returns the index of the first occurrence of a given value in a range of // an array. The array is searched forwards, starting at index // startIndex and ending at the last element of the array. The // elements of the array are compared to the given value using the // Object.Equals method. // public static int IndexOf(Array array, object? value, int startIndex) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); return IndexOf(array, value, startIndex, array.Length - startIndex + lb); } // Returns the index of the first occurrence of a given value in a range of // an array. The array is searched forwards, starting at index // startIndex and upto count elements. The // elements of the array are compared to the given value using the // Object.Equals method. // public static int IndexOf(Array array, object? value, int startIndex, int count) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (array.Rank != 1) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); int lb = array.GetLowerBound(0); if (startIndex < lb || startIndex > array.Length + lb) ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); if (count < 0 || count > array.Length - startIndex + lb) ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); int endIndex = startIndex + count; if (array is object[] objArray) { if (value == null) { for (int i = startIndex; i < endIndex; i++) { if (objArray[i] == null) return i; } } else { for (int i = startIndex; i < endIndex; i++) { object obj = objArray[i]; if (obj != null && obj.Equals(value)) return i; } } return -1; } CorElementType et = array.GetCorElementTypeOfElementType(); if (et.IsPrimitiveType()) { if (value == null) return lb - 1; if (array.IsValueOfElementType(value)) { int adjustedIndex = startIndex - lb; int result = -1; switch (et) { case CorElementType.ELEMENT_TYPE_I1: case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: result = GenericIndexOf<byte>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I2: case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: result = GenericIndexOf<char>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I4: case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif result = GenericIndexOf<int>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I8: case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif result = GenericIndexOf<long>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_R4: result = GenericIndexOf<float>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_R8: result = GenericIndexOf<double>(array, value, adjustedIndex, count); break; default: Debug.Fail("All primitive types should be handled above"); break; } return (result >= 0 ? startIndex : lb) + result; static int GenericIndexOf<T>(Array array, object value, int adjustedIndex, int length) where T : struct, IEquatable<T> => UnsafeArrayAsSpan<T>(array, adjustedIndex, length).IndexOf(Unsafe.As<byte, T>(ref value.GetRawData())); } } for (int i = startIndex; i < endIndex; i++) { object? obj = array.GetValue(i); if (obj == null) { if (value == null) return i; } else { if (obj.Equals(value)) return i; } } // Return one less than the lower bound of the array. This way, // for arrays with a lower bound of -1 we will not return -1 when the // item was not found. And for SZArrays (the vast majority), -1 still // works for them. return lb - 1; } public static int IndexOf<T>(T[] array, T value) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return IndexOf(array, value, 0, array.Length); } public static int IndexOf<T>(T[] array, T value, int startIndex) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return IndexOf(array, value, startIndex, array.Length - startIndex); } public static int IndexOf<T>(T[] array, T value, int startIndex, int count) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if ((uint)startIndex > (uint)array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } if ((uint)count > (uint)(array.Length - startIndex)) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } if (RuntimeHelpers.IsBitwiseEquatable<T>()) { if (Unsafe.SizeOf<T>() == sizeof(byte)) { int result = SpanHelpers.IndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<byte[]>(array)), startIndex), Unsafe.As<T, byte>(ref value), count); return (result >= 0 ? startIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(char)) { int result = SpanHelpers.IndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<char[]>(array)), startIndex), Unsafe.As<T, char>(ref value), count); return (result >= 0 ? startIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(int)) { int result = typeof(T).IsValueType ? SpanHelpers.IndexOfValueType( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<int[]>(array)), startIndex), Unsafe.As<T, int>(ref value), count) : SpanHelpers.IndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<int[]>(array)), startIndex), Unsafe.As<T, int>(ref value), count); return (result >= 0 ? startIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(long)) { int result = typeof(T).IsValueType ? SpanHelpers.IndexOfValueType( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<long[]>(array)), startIndex), Unsafe.As<T, long>(ref value), count) : SpanHelpers.IndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<long[]>(array)), startIndex), Unsafe.As<T, long>(ref value), count); return (result >= 0 ? startIndex : 0) + result; } } #if !CORERT return EqualityComparer<T>.Default.IndexOf(array, value, startIndex, count); #else return IndexOfImpl(array, value, startIndex, count); #endif } // Returns the index of the last occurrence of a given value in an array. // The array is searched backwards, and the elements of the array are // compared to the given value using the Object.Equals method. // public static int LastIndexOf(Array array, object? value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); return LastIndexOf(array, value, array.Length - 1 + lb, array.Length); } // Returns the index of the last occurrence of a given value in a range of // an array. The array is searched backwards, starting at index // startIndex and ending at index 0. The elements of the array are // compared to the given value using the Object.Equals method. // public static int LastIndexOf(Array array, object? value, int startIndex) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); return LastIndexOf(array, value, startIndex, startIndex + 1 - lb); } // Returns the index of the last occurrence of a given value in a range of // an array. The array is searched backwards, starting at index // startIndex and counting uptocount elements. The elements of // the array are compared to the given value using the Object.Equals // method. // public static int LastIndexOf(Array array, object? value, int startIndex, int count) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lb = array.GetLowerBound(0); if (array.Length == 0) { return lb - 1; } if (startIndex < lb || startIndex >= array.Length + lb) ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); if (count < 0) ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); if (count > startIndex - lb + 1) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.endIndex, ExceptionResource.ArgumentOutOfRange_EndIndexStartIndex); if (array.Rank != 1) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); int endIndex = startIndex - count + 1; if (array is object[] objArray) { if (value == null) { for (int i = startIndex; i >= endIndex; i--) { if (objArray[i] == null) return i; } } else { for (int i = startIndex; i >= endIndex; i--) { object obj = objArray[i]; if (obj != null && obj.Equals(value)) return i; } } return -1; } CorElementType et = array.GetCorElementTypeOfElementType(); if (et.IsPrimitiveType()) { if (value == null) return lb - 1; if (array.IsValueOfElementType(value)) { int adjustedIndex = endIndex - lb; int result = -1; switch (et) { case CorElementType.ELEMENT_TYPE_I1: case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: result = GenericLastIndexOf<byte>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I2: case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: result = GenericLastIndexOf<char>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I4: case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif result = GenericLastIndexOf<int>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_I8: case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif result = GenericLastIndexOf<long>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_R4: result = GenericLastIndexOf<float>(array, value, adjustedIndex, count); break; case CorElementType.ELEMENT_TYPE_R8: result = GenericLastIndexOf<double>(array, value, adjustedIndex, count); break; default: Debug.Fail("All primitive types should be handled above"); break; } return (result >= 0 ? endIndex : lb) + result; static int GenericLastIndexOf<T>(Array array, object value, int adjustedIndex, int length) where T : struct, IEquatable<T> => UnsafeArrayAsSpan<T>(array, adjustedIndex, length).LastIndexOf(Unsafe.As<byte, T>(ref value.GetRawData())); } } for (int i = startIndex; i >= endIndex; i--) { object? obj = array.GetValue(i); if (obj == null) { if (value == null) return i; } else { if (obj.Equals(value)) return i; } } return lb - 1; // Return lb-1 for arrays with negative lower bounds. } public static int LastIndexOf<T>(T[] array, T value) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return LastIndexOf(array, value, array.Length - 1, array.Length); } public static int LastIndexOf<T>(T[] array, T value, int startIndex) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } // if array is empty and startIndex is 0, we need to pass 0 as count return LastIndexOf(array, value, startIndex, (array.Length == 0) ? 0 : (startIndex + 1)); } public static int LastIndexOf<T>(T[] array, T value, int startIndex, int count) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (array.Length == 0) { // // Special case for 0 length List // accept -1 and 0 as valid startIndex for compablility reason. // if (startIndex != -1 && startIndex != 0) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } // only 0 is a valid value for count if array is empty if (count != 0) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } return -1; } // Make sure we're not out of range if ((uint)startIndex >= (uint)array.Length) { ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index(); } // 2nd have of this also catches when startIndex == MAXINT, so MAXINT - 0 + 1 == -1, which is < 0. if (count < 0 || startIndex - count + 1 < 0) { ThrowHelper.ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count(); } if (RuntimeHelpers.IsBitwiseEquatable<T>()) { if (Unsafe.SizeOf<T>() == sizeof(byte)) { int endIndex = startIndex - count + 1; int result = SpanHelpers.LastIndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<byte[]>(array)), endIndex), Unsafe.As<T, byte>(ref value), count); return (result >= 0 ? endIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(char)) { int endIndex = startIndex - count + 1; int result = SpanHelpers.LastIndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<char[]>(array)), endIndex), Unsafe.As<T, char>(ref value), count); return (result >= 0 ? endIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(int)) { int endIndex = startIndex - count + 1; int result = SpanHelpers.LastIndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<int[]>(array)), endIndex), Unsafe.As<T, int>(ref value), count); return (result >= 0 ? endIndex : 0) + result; } else if (Unsafe.SizeOf<T>() == sizeof(long)) { int endIndex = startIndex - count + 1; int result = SpanHelpers.LastIndexOf( ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<long[]>(array)), endIndex), Unsafe.As<T, long>(ref value), count); return (result >= 0 ? endIndex : 0) + result; } } #if !CORERT return EqualityComparer<T>.Default.LastIndexOf(array, value, startIndex, count); #else return LastIndexOfImpl(array, value, startIndex, count); #endif } // Reverses all elements of the given array. Following a call to this // method, an element previously located at index i will now be // located at index length - i - 1, where length is the // length of the array. // public static void Reverse(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Reverse(array, array.GetLowerBound(0), array.Length); } // Reverses the elements in a range of an array. Following a call to this // method, an element in the range given by index and count // which was previously located at index i will now be located at // index index + (index + count - i - 1). // Reliability note: This may fail because it may have to box objects. // public static void Reverse(Array array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lowerBound = array.GetLowerBound(0); if (index < lowerBound) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - (index - lowerBound) < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (array.Rank != 1) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); if (length <= 1) return; int adjustedIndex = index - lowerBound; switch (array.GetCorElementTypeOfElementType()) { case CorElementType.ELEMENT_TYPE_I1: case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: UnsafeArrayAsSpan<byte>(array, adjustedIndex, length).Reverse(); return; case CorElementType.ELEMENT_TYPE_I2: case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: UnsafeArrayAsSpan<short>(array, adjustedIndex, length).Reverse(); return; case CorElementType.ELEMENT_TYPE_I4: case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif case CorElementType.ELEMENT_TYPE_R4: UnsafeArrayAsSpan<int>(array, adjustedIndex, length).Reverse(); return; case CorElementType.ELEMENT_TYPE_I8: case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: case CorElementType.ELEMENT_TYPE_U: #endif case CorElementType.ELEMENT_TYPE_R8: UnsafeArrayAsSpan<long>(array, adjustedIndex, length).Reverse(); return; case CorElementType.ELEMENT_TYPE_OBJECT: case CorElementType.ELEMENT_TYPE_ARRAY: case CorElementType.ELEMENT_TYPE_SZARRAY: UnsafeArrayAsSpan<object>(array, adjustedIndex, length).Reverse(); return; } int i = index; int j = index + length - 1; while (i < j) { object? temp = array.GetValue(i); array.SetValue(array.GetValue(j), i); array.SetValue(temp, j); i++; j--; } } public static void Reverse<T>(T[] array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Reverse(array, 0, array.Length); } public static void Reverse<T>(T[] array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - index < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (length <= 1) return; ref T first = ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index); ref T last = ref Unsafe.Add(ref Unsafe.Add(ref first, length), -1); do { T temp = first; first = last; last = temp; first = ref Unsafe.Add(ref first, 1); last = ref Unsafe.Add(ref last, -1); } while (Unsafe.IsAddressLessThan(ref first, ref last)); } // Sorts the elements of an array. The sort compares the elements to each // other using the IComparable interface, which must be implemented // by all elements of the array. // public static void Sort(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Sort(array, null, array.GetLowerBound(0), array.Length, null); } // Sorts the elements of two arrays based on the keys in the first array. // Elements in the keys array specify the sort keys for // corresponding elements in the items array. The sort compares the // keys to each other using the IComparable interface, which must be // implemented by all elements of the keys array. // public static void Sort(Array keys, Array? items) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); Sort(keys, items, keys.GetLowerBound(0), keys.Length, null); } // Sorts the elements in a section of an array. The sort compares the // elements to each other using the IComparable interface, which // must be implemented by all elements in the given section of the array. // public static void Sort(Array array, int index, int length) { Sort(array, null, index, length, null); } // Sorts the elements in a section of two arrays based on the keys in the // first array. Elements in the keys array specify the sort keys for // corresponding elements in the items array. The sort compares the // keys to each other using the IComparable interface, which must be // implemented by all elements of the keys array. // public static void Sort(Array keys, Array? items, int index, int length) { Sort(keys, items, index, length, null); } // Sorts the elements of an array. The sort compares the elements to each // other using the given IComparer interface. If comparer is // null, the elements are compared to each other using the // IComparable interface, which in that case must be implemented by // all elements of the array. // public static void Sort(Array array, IComparer? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Sort(array, null, array.GetLowerBound(0), array.Length, comparer); } // Sorts the elements of two arrays based on the keys in the first array. // Elements in the keys array specify the sort keys for // corresponding elements in the items array. The sort compares the // keys to each other using the given IComparer interface. If // comparer is null, the elements are compared to each other using // the IComparable interface, which in that case must be implemented // by all elements of the keys array. // public static void Sort(Array keys, Array? items, IComparer? comparer) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); Sort(keys, items, keys.GetLowerBound(0), keys.Length, comparer); } // Sorts the elements in a section of an array. The sort compares the // elements to each other using the given IComparer interface. If // comparer is null, the elements are compared to each other using // the IComparable interface, which in that case must be implemented // by all elements in the given section of the array. // public static void Sort(Array array, int index, int length, IComparer? comparer) { Sort(array, null, index, length, comparer); } // Sorts the elements in a section of two arrays based on the keys in the // first array. Elements in the keys array specify the sort keys for // corresponding elements in the items array. The sort compares the // keys to each other using the given IComparer interface. If // comparer is null, the elements are compared to each other using // the IComparable interface, which in that case must be implemented // by all elements of the given section of the keys array. // public static void Sort(Array keys, Array? items, int index, int length, IComparer? comparer) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); if (keys.Rank != 1 || (items != null && items.Rank != 1)) ThrowHelper.ThrowRankException(ExceptionResource.Rank_MultiDimNotSupported); int keysLowerBound = keys.GetLowerBound(0); if (items != null && keysLowerBound != items.GetLowerBound(0)) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_LowerBoundsMustMatch); if (index < keysLowerBound) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (keys.Length - (index - keysLowerBound) < length || (items != null && (index - keysLowerBound) > items.Length - length)) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (length <= 1) return; comparer ??= Comparer.Default; if (keys is object[] objKeys) { object[]? objItems = items as object[]; if (items == null || objItems != null) { new SorterObjectArray(objKeys, objItems, comparer).Sort(index, length); return; } } if (comparer == Comparer.Default) { CorElementType et = keys.GetCorElementTypeOfElementType(); if (items == null || items.GetCorElementTypeOfElementType() == et) { int adjustedIndex = index - keysLowerBound; switch (et) { case CorElementType.ELEMENT_TYPE_I1: GenericSort<sbyte>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_U1: case CorElementType.ELEMENT_TYPE_BOOLEAN: GenericSort<byte>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_I2: GenericSort<short>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_U2: case CorElementType.ELEMENT_TYPE_CHAR: GenericSort<ushort>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_I4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_I: #endif GenericSort<int>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_U4: #if TARGET_32BIT case CorElementType.ELEMENT_TYPE_U: #endif GenericSort<uint>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_I8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_I: #endif GenericSort<long>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_U8: #if TARGET_64BIT case CorElementType.ELEMENT_TYPE_U: #endif GenericSort<ulong>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_R4: GenericSort<float>(keys, items, adjustedIndex, length); return; case CorElementType.ELEMENT_TYPE_R8: GenericSort<double>(keys, items, adjustedIndex, length); return; } static void GenericSort<T>(Array keys, Array? items, int adjustedIndex, int length) where T: struct { Span<T> keysSpan = UnsafeArrayAsSpan<T>(keys, adjustedIndex, length); if (items != null) { keysSpan.Sort<T, T>(UnsafeArrayAsSpan<T>(items, adjustedIndex, length)); } else { keysSpan.Sort<T>(); } } } } new SorterGenericArray(keys, items, comparer).Sort(index, length); } public static void Sort<T>(T[] array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (array.Length > 1) { var span = new Span<T>(ref MemoryMarshal.GetArrayDataReference(array), array.Length); ArraySortHelper<T>.Default.Sort(span, null); } } public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); Sort<TKey, TValue>(keys, items, 0, keys.Length, null); } public static void Sort<T>(T[] array, int index, int length) { Sort<T>(array, index, length, null); } public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, int index, int length) { Sort<TKey, TValue>(keys, items, index, length, null); } public static void Sort<T>(T[] array, System.Collections.Generic.IComparer<T>? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); Sort<T>(array, 0, array.Length, comparer); } public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, System.Collections.Generic.IComparer<TKey>? comparer) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); Sort<TKey, TValue>(keys, items, 0, keys.Length, comparer); } public static void Sort<T>(T[] array, int index, int length, System.Collections.Generic.IComparer<T>? comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - index < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (length > 1) { var span = new Span<T>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), index), length); ArraySortHelper<T>.Default.Sort(span, comparer); } } public static void Sort<TKey, TValue>(TKey[] keys, TValue[]? items, int index, int length, System.Collections.Generic.IComparer<TKey>? comparer) { if (keys == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keys); if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (keys.Length - index < length || (items != null && index > items.Length - length)) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); if (length > 1) { if (items == null) { Sort<TKey>(keys, index, length, comparer); return; } var spanKeys = new Span<TKey>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(keys), index), length); var spanItems = new Span<TValue>(ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(items), index), length); ArraySortHelper<TKey, TValue>.Default.Sort(spanKeys, spanItems, comparer); } } public static void Sort<T>(T[] array, Comparison<T> comparison) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (comparison == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparison); } var span = new Span<T>(ref MemoryMarshal.GetArrayDataReference(array), array.Length); ArraySortHelper<T>.Sort(span, comparison); } public static bool TrueForAll<T>(T[] array, Predicate<T> match) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (match == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match); } for (int i = 0; i < array.Length; i++) { if (!match(array[i])) { return false; } } return true; } /// <summary>Gets the maximum number of elements that may be contained in an array.</summary> /// <returns>The maximum count of elements allowed in any array.</returns> /// <remarks> /// <para>This property represents a runtime limitation, the maximum number of elements (not bytes) /// the runtime will allow in an array. There is no guarantee that an allocation under this length /// will succeed, but all attempts to allocate a larger array will fail.</para> /// <para>This property only applies to single-dimension, zero-bound (SZ) arrays. /// <see cref="Length"/> property may return larger value than this property for multi-dimensional arrays.</para> /// </remarks> public static int MaxLength => // Keep in sync with `inline SIZE_T MaxArrayLength()` from gchelpers and HashHelpers.MaxPrimeArrayLength. 0X7FFFFFC7; // Private value type used by the Sort methods. private readonly struct SorterObjectArray { private readonly object[] keys; private readonly object?[]? items; private readonly IComparer comparer; internal SorterObjectArray(object[] keys, object?[]? items, IComparer comparer) { this.keys = keys; this.items = items; this.comparer = comparer; } internal void SwapIfGreater(int a, int b) { if (a != b) { if (comparer.Compare(keys[a], keys[b]) > 0) { object temp = keys[a]; keys[a] = keys[b]; keys[b] = temp; if (items != null) { object? item = items[a]; items[a] = items[b]; items[b] = item; } } } } private void Swap(int i, int j) { object t = keys[i]; keys[i] = keys[j]; keys[j] = t; if (items != null) { object? item = items[i]; items[i] = items[j]; items[j] = item; } } internal void Sort(int left, int length) { IntrospectiveSort(left, length); } private void IntrospectiveSort(int left, int length) { if (length < 2) return; try { IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1)); } catch (IndexOutOfRangeException) { ThrowHelper.ThrowArgumentException_BadComparer(comparer); } catch (Exception e) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e); } } private void IntroSort(int lo, int hi, int depthLimit) { Debug.Assert(hi >= lo); Debug.Assert(depthLimit >= 0); while (hi > lo) { int partitionSize = hi - lo + 1; if (partitionSize <= IntrosortSizeThreshold) { Debug.Assert(partitionSize >= 2); if (partitionSize == 2) { SwapIfGreater(lo, hi); return; } if (partitionSize == 3) { SwapIfGreater(lo, hi - 1); SwapIfGreater(lo, hi); SwapIfGreater(hi - 1, hi); return; } InsertionSort(lo, hi); return; } if (depthLimit == 0) { Heapsort(lo, hi); return; } depthLimit--; int p = PickPivotAndPartition(lo, hi); IntroSort(p + 1, hi, depthLimit); hi = p - 1; } } private int PickPivotAndPartition(int lo, int hi) { Debug.Assert(hi - lo >= IntrosortSizeThreshold); // Compute median-of-three. But also partition them, since we've done the comparison. int mid = lo + (hi - lo) / 2; // Sort lo, mid and hi appropriately, then pick mid as the pivot. SwapIfGreater(lo, mid); SwapIfGreater(lo, hi); SwapIfGreater(mid, hi); object pivot = keys[mid]; Swap(mid, hi - 1); int left = lo, right = hi - 1; // We already partitioned lo and hi and put the pivot in hi - 1. And we pre-increment & decrement below. while (left < right) { while (comparer.Compare(keys[++left], pivot) < 0) ; while (comparer.Compare(pivot, keys[--right]) < 0) ; if (left >= right) break; Swap(left, right); } // Put pivot in the right location. if (left != hi - 1) { Swap(left, hi - 1); } return left; } private void Heapsort(int lo, int hi) { int n = hi - lo + 1; for (int i = n / 2; i >= 1; i--) { DownHeap(i, n, lo); } for (int i = n; i > 1; i--) { Swap(lo, lo + i - 1); DownHeap(1, i - 1, lo); } } private void DownHeap(int i, int n, int lo) { object d = keys[lo + i - 1]; object? dt = items?[lo + i - 1]; int child; while (i <= n / 2) { child = 2 * i; if (child < n && comparer.Compare(keys[lo + child - 1], keys[lo + child]) < 0) { child++; } if (!(comparer.Compare(d, keys[lo + child - 1]) < 0)) break; keys[lo + i - 1] = keys[lo + child - 1]; if (items != null) items[lo + i - 1] = items[lo + child - 1]; i = child; } keys[lo + i - 1] = d; if (items != null) items[lo + i - 1] = dt; } private void InsertionSort(int lo, int hi) { int i, j; object t; object? ti; for (i = lo; i < hi; i++) { j = i; t = keys[i + 1]; ti = items?[i + 1]; while (j >= lo && comparer.Compare(t, keys[j]) < 0) { keys[j + 1] = keys[j]; if (items != null) items[j + 1] = items[j]; j--; } keys[j + 1] = t; if (items != null) items[j + 1] = ti; } } } // Private value used by the Sort methods for instances of Array. // This is slower than the one for Object[], since we can't use the JIT helpers // to access the elements. We must use GetValue & SetValue. private readonly struct SorterGenericArray { private readonly Array keys; private readonly Array? items; private readonly IComparer comparer; internal SorterGenericArray(Array keys, Array? items, IComparer comparer) { this.keys = keys; this.items = items; this.comparer = comparer; } internal void SwapIfGreater(int a, int b) { if (a != b) { if (comparer.Compare(keys.GetValue(a), keys.GetValue(b)) > 0) { object? key = keys.GetValue(a); keys.SetValue(keys.GetValue(b), a); keys.SetValue(key, b); if (items != null) { object? item = items.GetValue(a); items.SetValue(items.GetValue(b), a); items.SetValue(item, b); } } } } private void Swap(int i, int j) { object? t1 = keys.GetValue(i); keys.SetValue(keys.GetValue(j), i); keys.SetValue(t1, j); if (items != null) { object? t2 = items.GetValue(i); items.SetValue(items.GetValue(j), i); items.SetValue(t2, j); } } internal void Sort(int left, int length) { IntrospectiveSort(left, length); } private void IntrospectiveSort(int left, int length) { if (length < 2) return; try { IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1)); } catch (IndexOutOfRangeException) { ThrowHelper.ThrowArgumentException_BadComparer(comparer); } catch (Exception e) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e); } } private void IntroSort(int lo, int hi, int depthLimit) { Debug.Assert(hi >= lo); Debug.Assert(depthLimit >= 0); while (hi > lo) { int partitionSize = hi - lo + 1; if (partitionSize <= IntrosortSizeThreshold) { Debug.Assert(partitionSize >= 2); if (partitionSize == 2) { SwapIfGreater(lo, hi); return; } if (partitionSize == 3) { SwapIfGreater(lo, hi - 1); SwapIfGreater(lo, hi); SwapIfGreater(hi - 1, hi); return; } InsertionSort(lo, hi); return; } if (depthLimit == 0) { Heapsort(lo, hi); return; } depthLimit--; int p = PickPivotAndPartition(lo, hi); IntroSort(p + 1, hi, depthLimit); hi = p - 1; } } private int PickPivotAndPartition(int lo, int hi) { Debug.Assert(hi - lo >= IntrosortSizeThreshold); // Compute median-of-three. But also partition them, since we've done the comparison. int mid = lo + (hi - lo) / 2; SwapIfGreater(lo, mid); SwapIfGreater(lo, hi); SwapIfGreater(mid, hi); object? pivot = keys.GetValue(mid); Swap(mid, hi - 1); int left = lo, right = hi - 1; // We already partitioned lo and hi and put the pivot in hi - 1. And we pre-increment & decrement below. while (left < right) { while (comparer.Compare(keys.GetValue(++left), pivot) < 0) ; while (comparer.Compare(pivot, keys.GetValue(--right)) < 0) ; if (left >= right) break; Swap(left, right); } // Put pivot in the right location. if (left != hi - 1) { Swap(left, hi - 1); } return left; } private void Heapsort(int lo, int hi) { int n = hi - lo + 1; for (int i = n / 2; i >= 1; i--) { DownHeap(i, n, lo); } for (int i = n; i > 1; i--) { Swap(lo, lo + i - 1); DownHeap(1, i - 1, lo); } } private void DownHeap(int i, int n, int lo) { object? d = keys.GetValue(lo + i - 1); object? dt = items?.GetValue(lo + i - 1); int child; while (i <= n / 2) { child = 2 * i; if (child < n && comparer.Compare(keys.GetValue(lo + child - 1), keys.GetValue(lo + child)) < 0) { child++; } if (!(comparer.Compare(d, keys.GetValue(lo + child - 1)) < 0)) break; keys.SetValue(keys.GetValue(lo + child - 1), lo + i - 1); if (items != null) items.SetValue(items.GetValue(lo + child - 1), lo + i - 1); i = child; } keys.SetValue(d, lo + i - 1); if (items != null) items.SetValue(dt, lo + i - 1); } private void InsertionSort(int lo, int hi) { int i, j; object? t; object? dt; for (i = lo; i < hi; i++) { j = i; t = keys.GetValue(i + 1); dt = items?.GetValue(i + 1); while (j >= lo && comparer.Compare(t, keys.GetValue(j)) < 0) { keys.SetValue(keys.GetValue(j), j + 1); if (items != null) items.SetValue(items.GetValue(j), j + 1); j--; } keys.SetValue(t, j + 1); if (items != null) items.SetValue(dt, j + 1); } } } private static Span<T> UnsafeArrayAsSpan<T>(Array array, int adjustedIndex, int length) => new Span<T>(ref Unsafe.As<byte, T>(ref MemoryMarshal.GetArrayDataReference(array)), array.Length).Slice(adjustedIndex, length); public IEnumerator GetEnumerator() { return new ArrayEnumerator(this); } } }
1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/mono/System.Private.CoreLib/src/System/Array.Mono.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.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { public partial class Array { [StructLayout(LayoutKind.Sequential)] internal sealed class RawData { public IntPtr Bounds; // The following is to prevent a mismatch between the managed and runtime // layouts where MONO_BIG_ARRAYS is false on 64-bit big endian systems #if MONO_BIG_ARRAYS public ulong Count; #else public uint Count; #if !TARGET_32BIT private uint _Pad; #endif #endif public byte Data; } public int Length { [Intrinsic] get => Length; } // This could return a length greater than int.MaxValue internal nuint NativeLength { get => (nuint)Unsafe.As<RawData>(this).Count; } public long LongLength { get { long length = GetLength(0); for (int i = 1; i < Rank; i++) { length *= GetLength(i); } return length; } } public int Rank { [Intrinsic] get => Rank; } public static unsafe void Clear(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); ref byte ptr = ref MemoryMarshal.GetArrayDataReference(array); nuint byteLength = array.NativeLength * (nuint)(uint)array.GetElementSize() /* force zero-extension */; if (RuntimeHelpers.ObjectHasReferences(array)) SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); else SpanHelpers.ClearWithoutReferences(ref ptr, byteLength); } public static unsafe void Clear(Array array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lowerBound = array.GetLowerBound(0); int elementSize = array.GetElementSize(); nuint numComponents = array.NativeLength; int offset = index - lowerBound; if (index < lowerBound || offset < 0 || length < 0 || (uint)(offset + length) > numComponents) ThrowHelper.ThrowIndexOutOfRangeException(); ref byte ptr = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(array), (uint)offset * (nuint)elementSize); nuint byteLength = (uint)length * (nuint)elementSize; if (RuntimeHelpers.ObjectHasReferences(array)) SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); else SpanHelpers.ClearWithoutReferences(ref ptr, byteLength); } public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, true); } public static void Copy(Array sourceArray, Array destinationArray, int length) { if (sourceArray == null) throw new ArgumentNullException(nameof(sourceArray)); if (destinationArray == null) throw new ArgumentNullException(nameof(destinationArray)); Copy(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length); } public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, false); } private static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { if (sourceArray == null) throw new ArgumentNullException(nameof(sourceArray)); if (destinationArray == null) throw new ArgumentNullException(nameof(destinationArray)); if (length < 0) throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum); if (sourceArray.Rank != destinationArray.Rank) throw new RankException(SR.Rank_MultiDimNotSupported); if (sourceIndex < 0) throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0."); if (destinationIndex < 0) throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0."); if (FastCopy(sourceArray, sourceIndex, destinationArray, destinationIndex, length)) return; CopySlow(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } private static void CopySlow(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { int source_pos = sourceIndex - sourceArray.GetLowerBound(0); int dest_pos = destinationIndex - destinationArray.GetLowerBound(0); if (source_pos < 0) throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_ArrayLB); if (dest_pos < 0) throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_ArrayLB); // re-ordered to avoid possible integer overflow if (source_pos > sourceArray.Length - length) throw new ArgumentException(SR.Arg_LongerThanSrcArray, nameof(sourceArray)); if (dest_pos > destinationArray.Length - length) throw new ArgumentException(SR.Arg_LongerThanDestArray, nameof(destinationArray)); Type src_type = sourceArray.GetType().GetElementType()!; Type dst_type = destinationArray.GetType().GetElementType()!; Type dst_elem_type = dst_type; bool dst_type_vt = dst_type.IsValueType && Nullable.GetUnderlyingType(dst_type) == null; bool src_is_enum = src_type.IsEnum; bool dst_is_enum = dst_type.IsEnum; if (src_is_enum) src_type = Enum.GetUnderlyingType(src_type); if (dst_is_enum) dst_type = Enum.GetUnderlyingType(dst_type); if (reliable) { if (!dst_type.Equals(src_type) && !(dst_type.IsPrimitive && src_type.IsPrimitive && CanChangePrimitive(ref dst_type, ref src_type, true))) { throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } else { if (!CanAssignArrayElement(src_type, dst_type)) { throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } if (!ReferenceEquals(sourceArray, destinationArray) || source_pos > dest_pos) { for (int i = 0; i < length; i++) { object srcval = sourceArray.GetValueImpl(source_pos + i); if (dst_type_vt && (srcval == null || (src_type == typeof(object) && !dst_elem_type.IsAssignableFrom (srcval.GetType())))) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); try { destinationArray.SetValueRelaxedImpl(srcval, dest_pos + i); } catch (ArgumentException) { throw CreateArrayTypeMismatchException(); } } } else { for (int i = length - 1; i >= 0; i--) { object srcval = sourceArray.GetValueImpl(source_pos + i); try { destinationArray.SetValueRelaxedImpl(srcval, dest_pos + i); } catch (ArgumentException) { throw CreateArrayTypeMismatchException(); } } } } private static ArrayTypeMismatchException CreateArrayTypeMismatchException() { return new ArrayTypeMismatchException(); } private static bool CanAssignArrayElement(Type source, Type target) { if (!target.IsValueType && !target.IsPointer) { if (!source.IsValueType && !source.IsPointer) { // Reference to reference copy return source.IsInterface || target.IsInterface || source.IsAssignableFrom(target) || target.IsAssignableFrom(source); } else { // Value to reference copy if (source.IsPointer) return false; return target.IsAssignableFrom(source); } } else { if (source.IsEquivalentTo(target)) { return true; } else if (source.IsPointer && target.IsPointer) { return true; } else if (source.IsPrimitive && target.IsPrimitive) { // Allow primitive type widening return CanChangePrimitive(ref source, ref target, false); } else if (!source.IsValueType && !source.IsPointer) { // Source is base class or interface of destination type if (target.IsPointer) return false; return source.IsAssignableFrom(target); } } return false; } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, int length) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); RuntimeType? runtimeType = elementType.UnderlyingSystemType as RuntimeType; if (runtimeType == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); Array? array = null; InternalCreate(ref array, runtimeType._impl.Value, 1, &length, null); GC.KeepAlive(runtimeType); return array; } public static unsafe Array CreateInstance(Type elementType, int length1, int length2) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length1 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length2 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); RuntimeType? runtimeType = elementType.UnderlyingSystemType as RuntimeType; if (runtimeType == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); int* lengths = stackalloc int[] { length1, length2 }; Array? array = null; InternalCreate(ref array, runtimeType._impl.Value, 2, lengths, null); GC.KeepAlive(runtimeType); return array; } public static unsafe Array CreateInstance(Type elementType, int length1, int length2, int length3) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (length1 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length1, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length2 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length2, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); if (length3 < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length3, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); RuntimeType? runtimeType = elementType.UnderlyingSystemType as RuntimeType; if (runtimeType == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); int* lengths = stackalloc int[] { length1, length2, length3 }; Array? array = null; InternalCreate(ref array, runtimeType._impl.Value, 3, lengths, null); GC.KeepAlive(runtimeType); return array; } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, params int[] lengths) { if (elementType is null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (lengths == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths); if (lengths.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank); RuntimeType? runtimeType = elementType.UnderlyingSystemType as RuntimeType; if (runtimeType == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); for (int i = 0; i < lengths.Length; i++) if (lengths[i] < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); Array? array = null; fixed (int* pLengths = &lengths[0]) InternalCreate(ref array, runtimeType._impl.Value, lengths.Length, pLengths, null); GC.KeepAlive(runtimeType); return array; } [RequiresDynamicCode("The code for an array of the specified type might not be available.")] public static unsafe Array CreateInstance(Type elementType, int[] lengths, int[] lowerBounds) { if (elementType == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.elementType); if (lengths == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lengths); if (lowerBounds == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.lowerBounds); if (lengths.Length != lowerBounds!.Length) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RanksAndBounds); if (lengths.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NeedAtLeast1Rank); for (int i = 0; i < lengths.Length; i++) if (lengths[i] < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); RuntimeType? runtimeType = elementType.UnderlyingSystemType as RuntimeType; if (runtimeType == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_MustBeType, ExceptionArgument.elementType); Array? array = null; fixed (int* pLengths = &lengths[0]) fixed (int* pLowerBounds = &lowerBounds[0]) InternalCreate(ref array, runtimeType._impl.Value, lengths.Length, pLengths, pLowerBounds); GC.KeepAlive(runtimeType); return array; } [MethodImpl(MethodImplOptions.InternalCall)] private static extern unsafe void InternalCreate([NotNull] ref Array? result, IntPtr elementType, int rank, int* lengths, int* lowerBounds); private unsafe nint GetFlattenedIndex(ReadOnlySpan<int> indices) { // Checked by the caller Debug.Assert(indices.Length == Rank); nint flattenedIndex = 0; for (int i = 0; i < indices.Length; i++) { int index = indices[i] - GetLowerBound(i); int length = GetLength(i); if ((uint)index >= (uint)length) ThrowHelper.ThrowIndexOutOfRangeException(); flattenedIndex = (length * flattenedIndex) + index; } Debug.Assert((nuint)flattenedIndex < (nuint)LongLength); return flattenedIndex; } internal object? InternalGetValue(nint index) { if (GetType().GetElementType()!.IsPointer) throw new NotSupportedException(SR.NotSupported_Type); return GetValueImpl((int)index); } internal void InternalSetValue(object? value, nint index) { if (GetType().GetElementType()!.IsPointer) throw new NotSupportedException(SR.NotSupported_Type); SetValueImpl(value, (int)index); } public void Initialize() { } private static int IndexOfImpl<T>(T[] array, T value, int startIndex, int count) { return EqualityComparer<T>.Default.IndexOf(array, value, startIndex, count); } private static int LastIndexOfImpl<T>(T[] array, T value, int startIndex, int count) { return EqualityComparer<T>.Default.LastIndexOf(array, value, startIndex, count); } public int GetUpperBound(int dimension) { return GetLowerBound(dimension) + GetLength(dimension) - 1; } [Intrinsic] internal int GetElementSize() => GetElementSize(); [Intrinsic] internal bool IsPrimitive() => IsPrimitive(); [MethodImpl(MethodImplOptions.InternalCall)] internal extern CorElementType GetCorElementTypeOfElementType(); [MethodImpl(MethodImplOptions.InternalCall)] private extern bool IsValueOfElementType(object value); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool CanChangePrimitive(ref Type srcType, ref Type dstType, bool reliable); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern bool FastCopy(Array source, int source_idx, Array dest, int dest_idx, int length); [Intrinsic] // when dimension is `0` constant [MethodImplAttribute(MethodImplOptions.InternalCall)] public extern int GetLength(int dimension); [Intrinsic] // when dimension is `0` constant [MethodImplAttribute(MethodImplOptions.InternalCall)] public extern int GetLowerBound(int dimension); // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern void GetGenericValue_icall<T>(ref Array self, int pos, out T value); // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern object GetValueImpl(int pos); // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern void SetGenericValue_icall<T>(ref Array self, int pos, ref T value); [Intrinsic] private void GetGenericValueImpl<T>(int pos, out T value) { Array self = this; GetGenericValue_icall(ref self, pos, out value); } [Intrinsic] private void SetGenericValueImpl<T>(int pos, ref T value) { Array self = this; SetGenericValue_icall(ref self, pos, ref value); } // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern void SetValueImpl(object? value, int pos); // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern void SetValueRelaxedImpl(object? value, int pos); #pragma warning disable CA1822 /* * These methods are used to implement the implicit generic interfaces * implemented by arrays in NET 2.0. * Only make those methods generic which really need it, to avoid * creating useless instantiations. */ internal int InternalArray__ICollection_get_Count() { return Length; } internal bool InternalArray__ICollection_get_IsReadOnly() { return true; } internal IEnumerator<T> InternalArray__IEnumerable_GetEnumerator<T>() { return Length == 0 ? SZGenericArrayEnumerator<T>.Empty : new SZGenericArrayEnumerator<T>(Unsafe.As<T[]>(this)); } internal void InternalArray__ICollection_Clear() { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } internal void InternalArray__ICollection_Add<T>(T _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } internal bool InternalArray__ICollection_Remove<T>(T _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; } internal bool InternalArray__ICollection_Contains<T>(T item) { return IndexOf((T[])this, item, 0, Length) >= 0; } internal void InternalArray__ICollection_CopyTo<T>(T[] array, int arrayIndex) { Copy(this, GetLowerBound(0), array, arrayIndex, Length); } internal T InternalArray__IReadOnlyList_get_Item<T>(int index) { if ((uint)index >= (uint)Length) ThrowHelper.ThrowArgumentOutOfRange_IndexException(); T value; // Do not change this to call GetGenericValue_icall directly, due to special casing in the runtime. GetGenericValueImpl(index, out value); return value; } internal int InternalArray__IReadOnlyCollection_get_Count() { return Length; } internal void InternalArray__Insert<T>(int _, T _1) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } internal void InternalArray__RemoveAt(int _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } internal int InternalArray__IndexOf<T>(T item) { return IndexOf((T[])this, item, 0, Length); } internal T InternalArray__get_Item<T>(int index) { if ((uint)index >= (uint)Length) ThrowHelper.ThrowArgumentOutOfRange_IndexException(); T value; // Do not change this to call GetGenericValue_icall directly, due to special casing in the runtime. GetGenericValueImpl(index, out value); return value; } internal void InternalArray__set_Item<T>(int index, T item) { if ((uint)index >= (uint)Length) ThrowHelper.ThrowArgumentOutOfRange_IndexException(); if (this is object?[] oarray) { oarray[index] = item; return; } // Do not change this to call SetGenericValue_icall directly, due to special casing in the runtime. SetGenericValueImpl(index, ref item); } #pragma warning restore CA1822 } }
// 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.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System { public partial class Array { [StructLayout(LayoutKind.Sequential)] internal sealed class RawData { public IntPtr Bounds; // The following is to prevent a mismatch between the managed and runtime // layouts where MONO_BIG_ARRAYS is false on 64-bit big endian systems #if MONO_BIG_ARRAYS public ulong Count; #else public uint Count; #if !TARGET_32BIT private uint _Pad; #endif #endif public byte Data; } public int Length { [Intrinsic] get => Length; } // This could return a length greater than int.MaxValue internal nuint NativeLength { get => (nuint)Unsafe.As<RawData>(this).Count; } public long LongLength { get { long length = GetLength(0); for (int i = 1; i < Rank; i++) { length *= GetLength(i); } return length; } } public int Rank { [Intrinsic] get => Rank; } public static unsafe void Clear(Array array) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); ref byte ptr = ref MemoryMarshal.GetArrayDataReference(array); nuint byteLength = array.NativeLength * (nuint)(uint)array.GetElementSize() /* force zero-extension */; if (RuntimeHelpers.ObjectHasReferences(array)) SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); else SpanHelpers.ClearWithoutReferences(ref ptr, byteLength); } public static unsafe void Clear(Array array, int index, int length) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); int lowerBound = array.GetLowerBound(0); int elementSize = array.GetElementSize(); nuint numComponents = array.NativeLength; int offset = index - lowerBound; if (index < lowerBound || offset < 0 || length < 0 || (uint)(offset + length) > numComponents) ThrowHelper.ThrowIndexOutOfRangeException(); ref byte ptr = ref Unsafe.AddByteOffset(ref MemoryMarshal.GetArrayDataReference(array), (uint)offset * (nuint)elementSize); nuint byteLength = (uint)length * (nuint)elementSize; if (RuntimeHelpers.ObjectHasReferences(array)) SpanHelpers.ClearWithReferences(ref Unsafe.As<byte, IntPtr>(ref ptr), byteLength / (uint)sizeof(IntPtr)); else SpanHelpers.ClearWithoutReferences(ref ptr, byteLength); } public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, true); } public static void Copy(Array sourceArray, Array destinationArray, int length) { if (sourceArray == null) throw new ArgumentNullException(nameof(sourceArray)); if (destinationArray == null) throw new ArgumentNullException(nameof(destinationArray)); Copy(sourceArray, sourceArray.GetLowerBound(0), destinationArray, destinationArray.GetLowerBound(0), length); } public static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length) { Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length, false); } private static void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { if (sourceArray == null) throw new ArgumentNullException(nameof(sourceArray)); if (destinationArray == null) throw new ArgumentNullException(nameof(destinationArray)); if (length < 0) throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum); if (sourceArray.Rank != destinationArray.Rank) throw new RankException(SR.Rank_MultiDimNotSupported); if (sourceIndex < 0) throw new ArgumentOutOfRangeException(nameof(sourceIndex), "Value has to be >= 0."); if (destinationIndex < 0) throw new ArgumentOutOfRangeException(nameof(destinationIndex), "Value has to be >= 0."); if (FastCopy(sourceArray, sourceIndex, destinationArray, destinationIndex, length)) return; CopySlow(sourceArray, sourceIndex, destinationArray, destinationIndex, length, reliable); } private static void CopySlow(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable) { int source_pos = sourceIndex - sourceArray.GetLowerBound(0); int dest_pos = destinationIndex - destinationArray.GetLowerBound(0); if (source_pos < 0) throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_ArrayLB); if (dest_pos < 0) throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_ArrayLB); // re-ordered to avoid possible integer overflow if (source_pos > sourceArray.Length - length) throw new ArgumentException(SR.Arg_LongerThanSrcArray, nameof(sourceArray)); if (dest_pos > destinationArray.Length - length) throw new ArgumentException(SR.Arg_LongerThanDestArray, nameof(destinationArray)); Type src_type = sourceArray.GetType().GetElementType()!; Type dst_type = destinationArray.GetType().GetElementType()!; Type dst_elem_type = dst_type; bool dst_type_vt = dst_type.IsValueType && Nullable.GetUnderlyingType(dst_type) == null; bool src_is_enum = src_type.IsEnum; bool dst_is_enum = dst_type.IsEnum; if (src_is_enum) src_type = Enum.GetUnderlyingType(src_type); if (dst_is_enum) dst_type = Enum.GetUnderlyingType(dst_type); if (reliable) { if (!dst_type.Equals(src_type) && !(dst_type.IsPrimitive && src_type.IsPrimitive && CanChangePrimitive(ref dst_type, ref src_type, true))) { throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } else { if (!CanAssignArrayElement(src_type, dst_type)) { throw new ArrayTypeMismatchException(SR.ArrayTypeMismatch_CantAssignType); } } if (!ReferenceEquals(sourceArray, destinationArray) || source_pos > dest_pos) { for (int i = 0; i < length; i++) { object srcval = sourceArray.GetValueImpl(source_pos + i); if (dst_type_vt && (srcval == null || (src_type == typeof(object) && !dst_elem_type.IsAssignableFrom (srcval.GetType())))) throw new InvalidCastException(SR.InvalidCast_DownCastArrayElement); try { destinationArray.SetValueRelaxedImpl(srcval, dest_pos + i); } catch (ArgumentException) { throw CreateArrayTypeMismatchException(); } } } else { for (int i = length - 1; i >= 0; i--) { object srcval = sourceArray.GetValueImpl(source_pos + i); try { destinationArray.SetValueRelaxedImpl(srcval, dest_pos + i); } catch (ArgumentException) { throw CreateArrayTypeMismatchException(); } } } } private static ArrayTypeMismatchException CreateArrayTypeMismatchException() { return new ArrayTypeMismatchException(); } private static bool CanAssignArrayElement(Type source, Type target) { if (!target.IsValueType && !target.IsPointer) { if (!source.IsValueType && !source.IsPointer) { // Reference to reference copy return source.IsInterface || target.IsInterface || source.IsAssignableFrom(target) || target.IsAssignableFrom(source); } else { // Value to reference copy if (source.IsPointer) return false; return target.IsAssignableFrom(source); } } else { if (source.IsEquivalentTo(target)) { return true; } else if (source.IsPointer && target.IsPointer) { return true; } else if (source.IsPrimitive && target.IsPrimitive) { // Allow primitive type widening return CanChangePrimitive(ref source, ref target, false); } else if (!source.IsValueType && !source.IsPointer) { // Source is base class or interface of destination type if (target.IsPointer) return false; return source.IsAssignableFrom(target); } } return false; } private static unsafe Array InternalCreate(RuntimeType elementType, int rank, int* lengths, int* lowerBounds) { Array? array = null; InternalCreate(ref array, elementType._impl.Value, rank, lengths, lowerBounds); GC.KeepAlive(elementType); return array!; } [MethodImpl(MethodImplOptions.InternalCall)] private static extern unsafe void InternalCreate(ref Array? result, IntPtr elementType, int rank, int* lengths, int* lowerBounds); private unsafe nint GetFlattenedIndex(ReadOnlySpan<int> indices) { // Checked by the caller Debug.Assert(indices.Length == Rank); nint flattenedIndex = 0; for (int i = 0; i < indices.Length; i++) { int index = indices[i] - GetLowerBound(i); int length = GetLength(i); if ((uint)index >= (uint)length) ThrowHelper.ThrowIndexOutOfRangeException(); flattenedIndex = (length * flattenedIndex) + index; } Debug.Assert((nuint)flattenedIndex < (nuint)LongLength); return flattenedIndex; } internal object? InternalGetValue(nint index) { if (GetType().GetElementType()!.IsPointer) throw new NotSupportedException(SR.NotSupported_Type); return GetValueImpl((int)index); } internal void InternalSetValue(object? value, nint index) { if (GetType().GetElementType()!.IsPointer) throw new NotSupportedException(SR.NotSupported_Type); SetValueImpl(value, (int)index); } public void Initialize() { } private static int IndexOfImpl<T>(T[] array, T value, int startIndex, int count) { return EqualityComparer<T>.Default.IndexOf(array, value, startIndex, count); } private static int LastIndexOfImpl<T>(T[] array, T value, int startIndex, int count) { return EqualityComparer<T>.Default.LastIndexOf(array, value, startIndex, count); } public int GetUpperBound(int dimension) { return GetLowerBound(dimension) + GetLength(dimension) - 1; } [Intrinsic] internal int GetElementSize() => GetElementSize(); [Intrinsic] internal bool IsPrimitive() => IsPrimitive(); [MethodImpl(MethodImplOptions.InternalCall)] internal extern CorElementType GetCorElementTypeOfElementType(); [MethodImpl(MethodImplOptions.InternalCall)] private extern bool IsValueOfElementType(object value); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool CanChangePrimitive(ref Type srcType, ref Type dstType, bool reliable); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern bool FastCopy(Array source, int source_idx, Array dest, int dest_idx, int length); [Intrinsic] // when dimension is `0` constant [MethodImplAttribute(MethodImplOptions.InternalCall)] public extern int GetLength(int dimension); [Intrinsic] // when dimension is `0` constant [MethodImplAttribute(MethodImplOptions.InternalCall)] public extern int GetLowerBound(int dimension); // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern void GetGenericValue_icall<T>(ref Array self, int pos, out T value); // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern object GetValueImpl(int pos); // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern void SetGenericValue_icall<T>(ref Array self, int pos, ref T value); [Intrinsic] private void GetGenericValueImpl<T>(int pos, out T value) { Array self = this; GetGenericValue_icall(ref self, pos, out value); } [Intrinsic] private void SetGenericValueImpl<T>(int pos, ref T value) { Array self = this; SetGenericValue_icall(ref self, pos, ref value); } // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern void SetValueImpl(object? value, int pos); // CAUTION! No bounds checking! [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern void SetValueRelaxedImpl(object? value, int pos); #pragma warning disable CA1822 /* * These methods are used to implement the implicit generic interfaces * implemented by arrays in NET 2.0. * Only make those methods generic which really need it, to avoid * creating useless instantiations. */ internal int InternalArray__ICollection_get_Count() { return Length; } internal bool InternalArray__ICollection_get_IsReadOnly() { return true; } internal IEnumerator<T> InternalArray__IEnumerable_GetEnumerator<T>() { return Length == 0 ? SZGenericArrayEnumerator<T>.Empty : new SZGenericArrayEnumerator<T>(Unsafe.As<T[]>(this)); } internal void InternalArray__ICollection_Clear() { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } internal void InternalArray__ICollection_Add<T>(T _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } internal bool InternalArray__ICollection_Remove<T>(T _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; } internal bool InternalArray__ICollection_Contains<T>(T item) { return IndexOf((T[])this, item, 0, Length) >= 0; } internal void InternalArray__ICollection_CopyTo<T>(T[] array, int arrayIndex) { Copy(this, GetLowerBound(0), array, arrayIndex, Length); } internal T InternalArray__IReadOnlyList_get_Item<T>(int index) { if ((uint)index >= (uint)Length) ThrowHelper.ThrowArgumentOutOfRange_IndexException(); T value; // Do not change this to call GetGenericValue_icall directly, due to special casing in the runtime. GetGenericValueImpl(index, out value); return value; } internal int InternalArray__IReadOnlyCollection_get_Count() { return Length; } internal void InternalArray__Insert<T>(int _, T _1) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } internal void InternalArray__RemoveAt(int _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } internal int InternalArray__IndexOf<T>(T item) { return IndexOf((T[])this, item, 0, Length); } internal T InternalArray__get_Item<T>(int index) { if ((uint)index >= (uint)Length) ThrowHelper.ThrowArgumentOutOfRange_IndexException(); T value; // Do not change this to call GetGenericValue_icall directly, due to special casing in the runtime. GetGenericValueImpl(index, out value); return value; } internal void InternalArray__set_Item<T>(int index, T item) { if ((uint)index >= (uint)Length) ThrowHelper.ThrowArgumentOutOfRange_IndexException(); if (this is object?[] oarray) { oarray[index] = item; return; } // Do not change this to call SetGenericValue_icall directly, due to special casing in the runtime. SetGenericValueImpl(index, ref item); } #pragma warning restore CA1822 } }
1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/coreclr/tools/superpmi/superpmi-shared/mclist.cpp
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. //---------------------------------------------------------- // MCList.h - MethodContext List utility class //---------------------------------------------------------- #include "standardpch.h" #include "mclist.h" #include "logging.h" bool MCList::processArgAsMCL(char* input, int* count, int** list) { // If it contains only '0-9', '-', ',' try to see it as a range list, else try to load as a file bool isRangeList = true; size_t len = strlen(input); for (unsigned int i = 0; (i < len) && isRangeList; i++) { if ((input[i] != '-') && (input[i] != ',') && (!isdigit((unsigned char)input[i]))) isRangeList = false; } if (isRangeList) { // Count items *count = 0; unsigned rangeStart = 0; bool inRange = false; unsigned scratch = 0; bool foundDigit = false; char* tail = input + len; for (char* head = input; head <= tail; head++) { scratch = 0; foundDigit = false; while ((head <= tail) && (isdigit((unsigned char)*head))) { scratch = (scratch * 10) + ((*head) - '0'); foundDigit = true; head++; } if (foundDigit) { if (inRange) { inRange = false; if (rangeStart >= scratch) { LogError("Invalid range in '%s'", input); return false; } (*count) += scratch - rangeStart; } else { rangeStart = scratch; (*count)++; } } if (*head == '-') inRange = true; } if (*count == 0) { LogError("Didn't find a list!"); return false; } inRange = false; rangeStart = 0; int* ll = new int[*count]; *list = ll; int index = 0; ll[index] = 0; for (char* head = input; head <= tail; head++) { scratch = 0; foundDigit = false; while ((head <= tail) && (isdigit((unsigned char)*head))) { scratch = (scratch * 10) + ((*head) - '0'); foundDigit = true; head++; } if (foundDigit) { if (inRange) { inRange = false; for (unsigned int i = rangeStart + 1; i <= scratch; i++) ll[index++] = i; } else { rangeStart = scratch; ll[index++] = scratch; } } if (*head == '-') inRange = true; } if (inRange) { LogError("Found invalid external range in '%s'", input); return false; } goto checkMCL; } else { char* lastdot = strrchr(input, '.'); if (lastdot != nullptr && _stricmp(lastdot, ".mcl") == 0) { // Read MCLFile if (!getLineData(input, count, list)) return false; if (*count >= 0) goto checkMCL; } return false; } checkMCL: // check that mcl list is increasing only int* ll = (*list); if (ll[0] == 0) { LogError("MCL list needs to start from 1!"); return false; } for (int i = 1; i < *count; i++) { if (ll[i - 1] >= ll[i]) { LogError("MCL list must be increasing.. found %d -> %d", ll[i - 1], ll[i]); return false; } } return true; } // Returns true on success, false on failure. // On success, sets *pIndexCount to the number of indices read, and *pIndexes to a new array with all the indices read. // The caller must free the memory with delete[]. /* static */ bool MCList::getLineData(const char* nameOfInput, /* OUT */ int* pIndexCount, /* OUT */ int** pIndexes) { HANDLE hFile = CreateFileA(nameOfInput, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFile == INVALID_HANDLE_VALUE) { LogError("Unable to open '%s'. GetLastError()=%u", nameOfInput, GetLastError()); return false; } LARGE_INTEGER DataTemp; if (!GetFileSizeEx(hFile, &DataTemp)) { LogError("GetFileSizeEx failed. GetLastError()=%u", GetLastError()); return false; } if (DataTemp.QuadPart > MAXMCLFILESIZE) { LogError("Size %d exceeds max size of %d", DataTemp.QuadPart, MAXMCLFILESIZE); return false; } int sz = DataTemp.u.LowPart; char* buff = new char[sz]; DWORD bytesRead; if (ReadFile(hFile, buff, sz, &bytesRead, nullptr) == 0) { LogError("ReadFile failed. GetLastError()=%u", GetLastError()); delete[] buff; return false; } if (!CloseHandle(hFile)) { LogError("CloseHandle failed. GetLastError()=%u", GetLastError()); delete[] buff; return false; } // Count the lines. Note that the last line better be terminated by a newline. int lineCount = 0; for (int i = 0; i < sz; i++) { if (buff[i] == '\n') { lineCount++; } } int* indexes = new int[lineCount]; int indexCount = 0; int i = 0; while (i < sz) { // seek the first number on the line. This will skip empty lines and lines with no digits. while (!isdigit((unsigned char)buff[i])) i++; // read in the number indexes[indexCount++] = atoi(&buff[i]); // seek to the start of next line while ((i < sz) && (buff[i] != '\n')) i++; i++; } delete[] buff; *pIndexCount = indexCount; *pIndexes = indexes; return true; } void MCList::InitializeMCL(char* filename) { hMCLFile = CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hMCLFile == INVALID_HANDLE_VALUE) { LogError("Failed to open output file '%s'. GetLastError()=%u", filename, GetLastError()); } } void MCList::AddMethodToMCL(int methodIndex) { if (hMCLFile != INVALID_HANDLE_VALUE) { char strMethodIndex[12]; DWORD charCount = 0; DWORD bytesWritten = 0; charCount = sprintf_s(strMethodIndex, sizeof(strMethodIndex), "%d\r\n", methodIndex); if (!WriteFile(hMCLFile, strMethodIndex, charCount, &bytesWritten, nullptr) || bytesWritten != charCount) { LogError("Failed to write method index '%d'. GetLastError()=%u", strMethodIndex, GetLastError()); } } } void MCList::CloseMCL() { if (hMCLFile != INVALID_HANDLE_VALUE) { if (CloseHandle(hMCLFile) == 0) { LogError("CloseHandle failed. GetLastError()=%u", GetLastError()); } } }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. //---------------------------------------------------------- // MCList.h - MethodContext List utility class //---------------------------------------------------------- #include "standardpch.h" #include "mclist.h" #include "logging.h" bool MCList::processArgAsMCL(char* input, int* count, int** list) { // If it contains only '0-9', '-', ',' try to see it as a range list, else try to load as a file bool isRangeList = true; size_t len = strlen(input); for (unsigned int i = 0; (i < len) && isRangeList; i++) { if ((input[i] != '-') && (input[i] != ',') && (!isdigit((unsigned char)input[i]))) isRangeList = false; } if (isRangeList) { // Count items *count = 0; unsigned rangeStart = 0; bool inRange = false; unsigned scratch = 0; bool foundDigit = false; char* tail = input + len; for (char* head = input; head <= tail; head++) { scratch = 0; foundDigit = false; while ((head <= tail) && (isdigit((unsigned char)*head))) { scratch = (scratch * 10) + ((*head) - '0'); foundDigit = true; head++; } if (foundDigit) { if (inRange) { inRange = false; if (rangeStart >= scratch) { LogError("Invalid range in '%s'", input); return false; } (*count) += scratch - rangeStart; } else { rangeStart = scratch; (*count)++; } } if (*head == '-') inRange = true; } if (*count == 0) { LogError("Didn't find a list!"); return false; } inRange = false; rangeStart = 0; int* ll = new int[*count]; *list = ll; int index = 0; ll[index] = 0; for (char* head = input; head <= tail; head++) { scratch = 0; foundDigit = false; while ((head <= tail) && (isdigit((unsigned char)*head))) { scratch = (scratch * 10) + ((*head) - '0'); foundDigit = true; head++; } if (foundDigit) { if (inRange) { inRange = false; for (unsigned int i = rangeStart + 1; i <= scratch; i++) ll[index++] = i; } else { rangeStart = scratch; ll[index++] = scratch; } } if (*head == '-') inRange = true; } if (inRange) { LogError("Found invalid external range in '%s'", input); return false; } goto checkMCL; } else { char* lastdot = strrchr(input, '.'); if (lastdot != nullptr && _stricmp(lastdot, ".mcl") == 0) { // Read MCLFile if (!getLineData(input, count, list)) return false; if (*count >= 0) goto checkMCL; } return false; } checkMCL: // check that mcl list is increasing only int* ll = (*list); if (ll[0] == 0) { LogError("MCL list needs to start from 1!"); return false; } for (int i = 1; i < *count; i++) { if (ll[i - 1] >= ll[i]) { LogError("MCL list must be increasing.. found %d -> %d", ll[i - 1], ll[i]); return false; } } return true; } // Returns true on success, false on failure. // On success, sets *pIndexCount to the number of indices read, and *pIndexes to a new array with all the indices read. // The caller must free the memory with delete[]. /* static */ bool MCList::getLineData(const char* nameOfInput, /* OUT */ int* pIndexCount, /* OUT */ int** pIndexes) { HANDLE hFile = CreateFileA(nameOfInput, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFile == INVALID_HANDLE_VALUE) { LogError("Unable to open '%s'. GetLastError()=%u", nameOfInput, GetLastError()); return false; } LARGE_INTEGER DataTemp; if (!GetFileSizeEx(hFile, &DataTemp)) { LogError("GetFileSizeEx failed. GetLastError()=%u", GetLastError()); return false; } if (DataTemp.QuadPart > MAXMCLFILESIZE) { LogError("Size %d exceeds max size of %d", DataTemp.QuadPart, MAXMCLFILESIZE); return false; } int sz = DataTemp.u.LowPart; char* buff = new char[sz]; DWORD bytesRead; if (ReadFile(hFile, buff, sz, &bytesRead, nullptr) == 0) { LogError("ReadFile failed. GetLastError()=%u", GetLastError()); delete[] buff; return false; } if (!CloseHandle(hFile)) { LogError("CloseHandle failed. GetLastError()=%u", GetLastError()); delete[] buff; return false; } // Count the lines. Note that the last line better be terminated by a newline. int lineCount = 0; for (int i = 0; i < sz; i++) { if (buff[i] == '\n') { lineCount++; } } int* indexes = new int[lineCount]; int indexCount = 0; int i = 0; while (i < sz) { // seek the first number on the line. This will skip empty lines and lines with no digits. while (!isdigit((unsigned char)buff[i])) i++; // read in the number indexes[indexCount++] = atoi(&buff[i]); // seek to the start of next line while ((i < sz) && (buff[i] != '\n')) i++; i++; } delete[] buff; *pIndexCount = indexCount; *pIndexes = indexes; return true; } void MCList::InitializeMCL(char* filename) { hMCLFile = CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hMCLFile == INVALID_HANDLE_VALUE) { LogError("Failed to open output file '%s'. GetLastError()=%u", filename, GetLastError()); } } void MCList::AddMethodToMCL(int methodIndex) { if (hMCLFile != INVALID_HANDLE_VALUE) { char strMethodIndex[12]; DWORD charCount = 0; DWORD bytesWritten = 0; charCount = sprintf_s(strMethodIndex, sizeof(strMethodIndex), "%d\r\n", methodIndex); if (!WriteFile(hMCLFile, strMethodIndex, charCount, &bytesWritten, nullptr) || bytesWritten != charCount) { LogError("Failed to write method index '%d'. GetLastError()=%u", strMethodIndex, GetLastError()); } } } void MCList::CloseMCL() { if (hMCLFile != INVALID_HANDLE_VALUE) { if (CloseHandle(hMCLFile) == 0) { LogError("CloseHandle failed. GetLastError()=%u", GetLastError()); } } }
-1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/tests/JIT/Math/Functions/Single/SinhSingle.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 Single { // Tests MathF.Sinh(float) over 5000 iterations for the domain -1, +1 private const float sinhDelta = 0.0004f; private const float sinhExpectedResult = 1.26028216f; /// <summary> /// this benchmark is dependent on loop alignment /// </summary> public void Sinh() => SinhTest(); public static void SinhTest() { float result = 0.0f, value = -1.0f; for (int iteration = 0; iteration < MathTests.Iterations; iteration++) { value += sinhDelta; result += MathF.Sinh(value); } float diff = MathF.Abs(sinhExpectedResult - result); if (diff > MathTests.SingleEpsilon) { throw new Exception($"Expected Result {sinhExpectedResult,10:g9}; Actual Result {result,10:g9}"); } } } }
// 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 Single { // Tests MathF.Sinh(float) over 5000 iterations for the domain -1, +1 private const float sinhDelta = 0.0004f; private const float sinhExpectedResult = 1.26028216f; /// <summary> /// this benchmark is dependent on loop alignment /// </summary> public void Sinh() => SinhTest(); public static void SinhTest() { float result = 0.0f, value = -1.0f; for (int iteration = 0; iteration < MathTests.Iterations; iteration++) { value += sinhDelta; result += MathF.Sinh(value); } float diff = MathF.Abs(sinhExpectedResult - result); if (diff > MathTests.SingleEpsilon) { throw new Exception($"Expected Result {sinhExpectedResult,10:g9}; Actual Result {result,10:g9}"); } } } }
-1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.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.Reflection; namespace System.Runtime.CompilerServices { public static partial class RuntimeHelpers { // The special dll name to be used for DllImport of QCalls internal const string QCall = "QCall"; public delegate void TryCode(object? userData); public delegate void CleanupCode(object? userData, bool exceptionThrown); /// <summary> /// Slices the specified array using the specified range. /// </summary> public static T[] GetSubArray<T>(T[] array, Range range) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } (int offset, int length) = range.GetOffsetAndLength(array.Length); if (length == 0) { return Array.Empty<T>(); } T[] dest = new T[length]; // Due to array variance, it's possible that the incoming array is // actually of type U[], where U:T; or that an int[] <-> uint[] or // similar cast has occurred. In any case, since it's always legal // to reinterpret U as T in this scenario (but not necessarily the // other way around), we can use Buffer.Memmove here. Buffer.Memmove( ref MemoryMarshal.GetArrayDataReference(dest), ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), offset), (uint)length); return dest; } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void ExecuteCodeWithGuaranteedCleanup(TryCode code!!, CleanupCode backoutCode!!, object? userData) { bool exceptionThrown = true; try { code(userData); exceptionThrown = false; } finally { backoutCode(userData, exceptionThrown); } } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void PrepareContractedDelegate(Delegate d) { } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void ProbeForSufficientStack() { } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void PrepareConstrainedRegions() { } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void PrepareConstrainedRegionsNoOP() { } internal static bool IsPrimitiveType(this CorElementType et) // COR_ELEMENT_TYPE_I1,I2,I4,I8,U1,U2,U4,U8,R4,R8,I,U,CHAR,BOOLEAN => ((1 << (int)et) & 0b_0011_0000_0000_0011_1111_1111_1100) != 0; /// <summary>Provide a fast way to access constant data stored in a module as a ReadOnlySpan{T}</summary> /// <param name="fldHandle">A field handle that specifies the location of the data to be referred to by the ReadOnlySpan{T}. The Rva of the field must be aligned on a natural boundary of type T</param> /// <returns>A ReadOnlySpan{T} of the data stored in the field</returns> /// <exception cref="ArgumentException"><paramref name="fldHandle"/> does not refer to a field which is an Rva, is misaligned, or T is of an invalid type.</exception> /// <remarks>This method is intended for compiler use rather than use directly in code. T must be one of byte, sbyte, char, short, ushort, int, long, ulong, float, or double.</remarks> [Intrinsic] public static unsafe ReadOnlySpan<T> CreateSpan<T>(RuntimeFieldHandle fldHandle) => new ReadOnlySpan<T>(GetSpanDataFrom(fldHandle, typeof(T).TypeHandle, out int length), length); // The following intrinsics return true if input is a compile-time constant // Feel free to add more overloads on demand #pragma warning disable IDE0060 [Intrinsic] internal static bool IsKnownConstant(string? t) => false; [Intrinsic] internal static bool IsKnownConstant(char t) => false; [Intrinsic] internal static bool IsKnownConstant(int t) => false; #pragma warning restore IDE0060 } }
// 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.Reflection; namespace System.Runtime.CompilerServices { public static partial class RuntimeHelpers { // The special dll name to be used for DllImport of QCalls internal const string QCall = "QCall"; public delegate void TryCode(object? userData); public delegate void CleanupCode(object? userData, bool exceptionThrown); /// <summary> /// Slices the specified array using the specified range. /// </summary> public static T[] GetSubArray<T>(T[] array, Range range) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } (int offset, int length) = range.GetOffsetAndLength(array.Length); if (length == 0) { return Array.Empty<T>(); } T[] dest = new T[length]; // Due to array variance, it's possible that the incoming array is // actually of type U[], where U:T; or that an int[] <-> uint[] or // similar cast has occurred. In any case, since it's always legal // to reinterpret U as T in this scenario (but not necessarily the // other way around), we can use Buffer.Memmove here. Buffer.Memmove( ref MemoryMarshal.GetArrayDataReference(dest), ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(array), offset), (uint)length); return dest; } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void ExecuteCodeWithGuaranteedCleanup(TryCode code!!, CleanupCode backoutCode!!, object? userData) { bool exceptionThrown = true; try { code(userData); exceptionThrown = false; } finally { backoutCode(userData, exceptionThrown); } } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void PrepareContractedDelegate(Delegate d) { } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void ProbeForSufficientStack() { } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void PrepareConstrainedRegions() { } [Obsolete(Obsoletions.ConstrainedExecutionRegionMessage, DiagnosticId = Obsoletions.ConstrainedExecutionRegionDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void PrepareConstrainedRegionsNoOP() { } internal static bool IsPrimitiveType(this CorElementType et) // COR_ELEMENT_TYPE_I1,I2,I4,I8,U1,U2,U4,U8,R4,R8,I,U,CHAR,BOOLEAN => ((1 << (int)et) & 0b_0011_0000_0000_0011_1111_1111_1100) != 0; /// <summary>Provide a fast way to access constant data stored in a module as a ReadOnlySpan{T}</summary> /// <param name="fldHandle">A field handle that specifies the location of the data to be referred to by the ReadOnlySpan{T}. The Rva of the field must be aligned on a natural boundary of type T</param> /// <returns>A ReadOnlySpan{T} of the data stored in the field</returns> /// <exception cref="ArgumentException"><paramref name="fldHandle"/> does not refer to a field which is an Rva, is misaligned, or T is of an invalid type.</exception> /// <remarks>This method is intended for compiler use rather than use directly in code. T must be one of byte, sbyte, char, short, ushort, int, long, ulong, float, or double.</remarks> [Intrinsic] public static unsafe ReadOnlySpan<T> CreateSpan<T>(RuntimeFieldHandle fldHandle) => new ReadOnlySpan<T>(GetSpanDataFrom(fldHandle, typeof(T).TypeHandle, out int length), length); // The following intrinsics return true if input is a compile-time constant // Feel free to add more overloads on demand #pragma warning disable IDE0060 [Intrinsic] internal static bool IsKnownConstant(string? t) => false; [Intrinsic] internal static bool IsKnownConstant(char t) => false; [Intrinsic] internal static bool IsKnownConstant(int t) => false; #pragma warning restore IDE0060 } }
-1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptAcquireContext_IntPtr.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 { internal static partial class Advapi32 { [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] [return: MarshalAs(UnmanagedType.Bool)] internal static unsafe partial bool CryptAcquireContext( out IntPtr psafeProvHandle, char* pszContainer, char* pszProvider, int dwProvType, Interop.Crypt32.CryptAcquireContextFlags dwFlags); } }
// 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 { internal static partial class Advapi32 { [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] [return: MarshalAs(UnmanagedType.Bool)] internal static unsafe partial bool CryptAcquireContext( out IntPtr psafeProvHandle, char* pszContainer, char* pszProvider, int dwProvType, Interop.Crypt32.CryptAcquireContextFlags dwFlags); } }
-1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/tests/JIT/Performance/CodeQuality/Benchstones/BenchI/Midpoint/Midpoint.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.CompilerServices; namespace Benchstone.BenchI { public static class Midpoint { #if DEBUG public const int Iterations = 1; #else public const int Iterations = 70000; #endif static T[][] AllocArray<T>(int n1, int n2) { T[][] a = new T[n1][]; for (int i = 0; i < n1; ++i) { a[i] = new T[n2]; } return a; } static int Inner(ref int x, ref int y, ref int z) { int mid; if (x < y) { if (y < z) { mid = y; } else { if (x < z) { mid = z; } else { mid = x; } } } else { if (x < z) { mid = x; } else { if (y < z) { mid = z; } else { mid = y; } } } return (mid); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Bench() { int[][] a = AllocArray<int>(2001, 4); int[] mid = new int[2001]; int j = 99999; for (int i = 1; i <= 2000; i++) { a[i][1] = j & 32767; a[i][2] = (j + 11111) & 32767; a[i][3] = (j + 22222) & 32767; j = j + 33333; } for (int k = 1; k <= Iterations; k++) { for (int l = 1; l <= 2000; l++) { mid[l] = Inner(ref a[l][1], ref a[l][2], ref a[l][3]); } } return (mid[2000] == 17018); } static bool TestBase() { bool result = Bench(); return result; } public static int Main() { bool result = TestBase(); return (result ? 100 : -1); } } }
// 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.CompilerServices; namespace Benchstone.BenchI { public static class Midpoint { #if DEBUG public const int Iterations = 1; #else public const int Iterations = 70000; #endif static T[][] AllocArray<T>(int n1, int n2) { T[][] a = new T[n1][]; for (int i = 0; i < n1; ++i) { a[i] = new T[n2]; } return a; } static int Inner(ref int x, ref int y, ref int z) { int mid; if (x < y) { if (y < z) { mid = y; } else { if (x < z) { mid = z; } else { mid = x; } } } else { if (x < z) { mid = x; } else { if (y < z) { mid = z; } else { mid = y; } } } return (mid); } [MethodImpl(MethodImplOptions.NoInlining)] static bool Bench() { int[][] a = AllocArray<int>(2001, 4); int[] mid = new int[2001]; int j = 99999; for (int i = 1; i <= 2000; i++) { a[i][1] = j & 32767; a[i][2] = (j + 11111) & 32767; a[i][3] = (j + 22222) & 32767; j = j + 33333; } for (int k = 1; k <= Iterations; k++) { for (int l = 1; l <= 2000; l++) { mid[l] = Inner(ref a[l][1], ref a[l][2], ref a[l][3]); } } return (mid[2000] == 17018); } static bool TestBase() { bool result = Bench(); return result; } public static int Main() { bool result = TestBase(); return (result ? 100 : -1); } } }
-1
dotnet/runtime
66,025
Move Array.CreateInstance methods to shared CoreLib
jkotas
2022-03-01T20:10:54Z
2022-03-09T15:56:10Z
6187fdfad1cc8670454a80776f0ee6a43a979fba
f97788194aa647bf46c3c1e3b0526704dce15093
Move Array.CreateInstance methods to shared CoreLib.
./src/tests/JIT/Regression/JitBlue/Runtime_51612/Runtime_51612.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.CompilerServices; namespace Runtime_51612 { class Program { struct PassedViaReturnBuffer { public int _0; public int _1; } abstract class Base { public unsafe abstract PassedViaReturnBuffer HasEspBasedFrame(); } class Derived : Base { public Derived(Exception ex) { _ex = ex; } readonly Exception _ex; public override PassedViaReturnBuffer HasEspBasedFrame() { DoesNotReturn(); PassedViaReturnBuffer retBuf; retBuf = RequiresGuardStack(); return retBuf; } [MethodImpl(MethodImplOptions.AggressiveInlining)] static unsafe PassedViaReturnBuffer RequiresGuardStack() { int* p = stackalloc int[2]; p[0] = 1; p[1] = 2; PassedViaReturnBuffer retBuf; retBuf._0 = p[0]; retBuf._1 = p[1]; return retBuf; } [MethodImpl(MethodImplOptions.AggressiveInlining)] void DoesNotReturn() { throw _ex; } } [MethodImpl(MethodImplOptions.NoInlining)] static void AssertsThatGuardStackCookieOffsetIsInvalid(Base x) { x.HasEspBasedFrame(); } static int Main(string[] args) { try { AssertsThatGuardStackCookieOffsetIsInvalid(new Derived(new Exception())); } catch (Exception ex) { return 100; } return 0; } } }
// 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.CompilerServices; namespace Runtime_51612 { class Program { struct PassedViaReturnBuffer { public int _0; public int _1; } abstract class Base { public unsafe abstract PassedViaReturnBuffer HasEspBasedFrame(); } class Derived : Base { public Derived(Exception ex) { _ex = ex; } readonly Exception _ex; public override PassedViaReturnBuffer HasEspBasedFrame() { DoesNotReturn(); PassedViaReturnBuffer retBuf; retBuf = RequiresGuardStack(); return retBuf; } [MethodImpl(MethodImplOptions.AggressiveInlining)] static unsafe PassedViaReturnBuffer RequiresGuardStack() { int* p = stackalloc int[2]; p[0] = 1; p[1] = 2; PassedViaReturnBuffer retBuf; retBuf._0 = p[0]; retBuf._1 = p[1]; return retBuf; } [MethodImpl(MethodImplOptions.AggressiveInlining)] void DoesNotReturn() { throw _ex; } } [MethodImpl(MethodImplOptions.NoInlining)] static void AssertsThatGuardStackCookieOffsetIsInvalid(Base x) { x.HasEspBasedFrame(); } static int Main(string[] args) { try { AssertsThatGuardStackCookieOffsetIsInvalid(new Derived(new Exception())); } catch (Exception ex) { return 100; } return 0; } } }
-1